Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using SHIFT+Arrows to select text in vim / MacVim

Tags:

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

like image 706
Debilski Avatar asked Jan 25 '10 01:01

Debilski


People also ask

How do I select part of text in vim?

If you want to select the entire line in a file, press V. Now when you press k or j to go up and down, vim will select the entire line above and below your cursor. Finally, you can select text in columns by pressing ctrl+v and moving up or down the block.

How do I select a block of text in vim?

Press v to begin character-based visual selection, or V to select whole lines, or Ctrl-v or Ctrl-q to select a block.

How do you highlight text in vim?

Press 1 to highlight the current visually selected text, or the current word (if nothing is selected). Highlight group hl1 is used. Press 2 for highlight hl2 , 3 for highlight hl3 , etc. Press 0 to remove all highlights from the current visually selected text, or the current word.

How do I copy an entire text in vi editor?

You can use a movement command or up, down, right, and left arrow keys. Press y to copy, or d to cut the selection. Move the cursor to the location where you want to paste the contents. Press P to paste the contents before the cursor, or p to paste it after the cursor.


1 Answers

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 
like image 82
mopoke Avatar answered Oct 07 '22 19:10

mopoke