views:

656

answers:

2

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.)

+7  A: 

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
mopoke
Great. Thanks a lot. Looks like it’s exactly the thing I’ve been looking for.
Debilski
One minor annoyance though is that now I’ll need to press shift even in visual mode when using the arrow keys. Time to get used to ‘hjkl’…
Debilski
A: 

As a note to self and a neat hint for others:

Since SHIFT+Arrow selection and mouse selection now automatically starts SELECT mode, this means that it is apparently not as easy to make a VISUAL selection by using the mouse or arrow keys. (Even when already in VISUAL mode a mouse selection will still trigger SELECT mode.) Therefore, whenever one wants to apply commands to the selection, the following method helps.

  • Select the text using mouse or SHIFT+Arrow
  • Unselect by pressing ESC
  • Press gv to automatically reselect the previous selection and trigger VISUAL mode
Debilski