Using SHIFT+Arrows to select text in vim / MacVim

Debilski picture Debilski · Jan 25, 2010 · Viewed 13.4k times · Source

One of the nicer features in MacVim is that it is possible to use the usual OS commands for copying and pasting text (namely command+C and command+V) in it.

This is especially nice in situations when you’ve worked in another editor just a minute before and your brain isn’t ready yet to advise your fingers on how to type the real thing.

However, there’s one thing my brain needs to do quite a little thinking on: It’s the text selecting mode. In non-vi editors, I’d use Shift+Arrow for this and trying this in MacVim doesn’t work. But on the other hand it does not look to me that Shift+Arrow is being used for anything else either. Is it possible to remap the keys in order to make this possible?

(Ideally, the editor would still be in insertion mode after having selected the text; that would spare some additional key strokes.)

Answer

mopoke picture mopoke · Jan 25, 2010

From the manual:

Text editors on Mac OS X lets the user hold down shift+movement key to extend the selection. Also, pressing a printable key whilst selecting replaces the current selection with that character. MacVim can emulate this kind of behaviour (by providing key bindings and by setting 'keymodel' and 'selectmode' to non-default values) although it is not enabled by default. To make MacVim behave more like TextEdit and less like Vim, add the following lines to your "~/.vimrc" (not .gvimrc) file:

if has("gui_macvim")
    let macvim_hig_shift_movement = 1
endif