I think that there should be lots of people like me that even having Gnome Text Editor, or some KDE tool for the same goal, still uses vim as their primary text editor.

I use vim since my first days with Linux on ‘97, I think on that time that was maybe the only or one of the few options, was not easy but being used to WordStar or WordPerfect, it did not look as intimidating as it may look to people now a days.

vim is a very powerfull editor, and I want to put here just some commands which are the ones I use the most.

  1. Opening a file
  2. You may open a file to edit, just by entering its name after vim

    vim [file]

    Or once vim is opened :e file
  3. Saving the file
  4. :w file
  5. Quiting vim
  6. :q vim will refuse to exit if there are changes to a file and those are unsaved. :q! Will quit no matter the changes. :wq Will quit after saving the file, I also use this other way to exit saving the file, being in normal mode (on insert mode, or command mode) ZZ (Shift+zz) will exit vim and save the file if any changes occured to it.
  7. Deleting text
  8. dl will delete one character, the one that is below the cursor dd will delete the complete row where the cursor is :d Will work as dd
  9. Search and replace
  10. :/pattern Will look for the given pattern below the cursor Then pressing n will go forward looking for that same pattern or N will look for it upwards. r[letter] Will replace the character where the cursor is with the given 'letter'. :[range]s[substitute]/{pattern}/{pattern2}/[c][e][g][p][i][I] This will search for pattern and replace it with pattern2, for each line in the range (use % for the whole file) the options are:
    Confirm each substitution. Vim positions the cursor on the matching string. Your have to choose: 'y' yes 'n' no 'a' yes to all next matches 'q' stop substitutions
    silent mode, do not shows errors when the search fails
    Replace all occurrences in the line, otherwise only the first occurence will be changed
    case insensitive
    case sensitive
    Print the line containing the last substitute
    On next posts, I will be showing more commands of vim, and also some of its configuration command.