Using Vim’s persistent undo?

Put this in your .vimrc to create an undodir if it doesn’t exist and enable persistent undo. Tested on both Windows and Linux. ” Put plugins and dictionaries in this dir (also on Windows) let vimDir=”$HOME/.vim” if stridx(&runtimepath, expand(vimDir)) == -1 ” vimDir is not on runtimepath, add it let &runtimepath.=’,’.vimDir endif ” Keep undo …

Read more

How do I set the default font size in Vim?

For the first one remove the spaces. Whitespace matters for the set command. set guifont=Monaco:h20 For the second one it should be (the h specifies the height) set guifont=Monospace:h20 My recommendation for setting the font is to do (if your version supports it) set guifont=* This will pop up a menu that allows you to …

Read more

Change 2-space indent to 4-space in vim

A general way of changing the indent is by changing the tabstop: Paste your file into an empty buffer, then: :set ts=2 sts=2 noet :retab! This changes every 2 spaces to a TAB character, then: :set ts=4 sts=4 et :retab This changes every TAB to 4 spaces. The advantage of this method is that you …

Read more

Paste multiple times

I have this in my .vimrc: xnoremap p pgvy (note: this will work only with the default register, but this mapping is easy to remember). Writing a more elaborate version would be possible. Also, you still can use P to get the old behaviour.

What specific productivity gains do Vim/Emacs provide over GUI text editors?

For Vim: Vim has better integration with other tools (shell commands, scripts, compilers, version control systems, ctags, etc.) than most editors. Even something simple like :.!, to pipe a command’s output into a buffer, is something you won’t find in most GUI editors. A tabbed interface is not as nice as the “windowed” interface that …

Read more

Copy from one register to another

To copy or swap values between registers you can use the :let command, for example to copy the contents of the b register to a: :let @a=@b Or copy the contents of the ” register to a: :let @a=@” Check this Vim Tip for some good key mapping suggestions: Comfortable handling of registers

How to copy selected lines to clipboard in vim

SHIFTV puts you in select lines mode. Then “+y yanks the currently selected lines to the + register which is the clipboard. There are quite a few different registers, for different purposes. See the section on selection and drop registers for details on the differences between * and + registers on Windows and Linux. Note …

Read more