Useful commands in Vim and Emacs

So you’re not exactly a text-editor geek and one of the factors stopping you from adopting a more powerful editor is that you can’t remember those damned shortcuts.

This table will help you.

(1) In Vim, if you are in writing mode, you need to press Esc before you can enter some commands. Then, to type again text, you need to press a (append, to position the cursor after the selected character) or i (insert, cursor before the selected character).

(2) Vim by default saves data in a separate clipboard, not the OS’ generic one, so if you want to send data to other applications, or paste in Vim data coming from other software, you need to use the mentioned commands (or the toolbar icons, if you use Vim with GUI). The syntax (note the double quotes) is the same of registers, but in this case you use a special register which is identified by the “plus” sign: +.

(3) In this case the command is entered through a sequence: you don’t have to press all the keys at the same time. To make visible the different steps of said sequence, you can see a space: this just means that the next key is not to be pressed at the same time as the previous one, this doesn’t mean that you have to press the spacebar on your keyboard! This kind of sequences is quite common in Emacs.

(4) Emacs not only saves data from the last last cut or copy operation, but also the previous strings: to paste them, you need to press CTRL-Y just once, then keep pressing ALT-Y, until the desired string is visualized.

(5) Vim just saves the last cut or copied string, so it is useful to save a string to use it later: to do so, you need to insert your data in a register. Here, as an example, the syntax used is related to a register named after the letter c, but you can name a register after each of the letters of the alphabet, or numbers from 0 to 9. To use any of the aforementioned registers, just type the desired letter or number right after the double quotes.