Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mapping <Shift>-Arrows to selecting characters/lines

Tags:

vim

vi

I started to use vim recently, but I miss the character/line selection methods from other text editors. By default vim maps <S-Up>, <S-Down> to jumping one page up/down and I want to remap these to text selection.

Is there a way to do that?

like image 358
Alexei Danchenkov Avatar asked Mar 15 '12 14:03

Alexei Danchenkov


1 Answers

I completed @escrafford mapping with insert mode's ones:

" shift+arrow selection nmap <S-Up> v<Up> nmap <S-Down> v<Down> nmap <S-Left> v<Left> nmap <S-Right> v<Right> vmap <S-Up> <Up> vmap <S-Down> <Down> vmap <S-Left> <Left> vmap <S-Right> <Right> imap <S-Up> <Esc>v<Up> imap <S-Down> <Esc>v<Down> imap <S-Left> <Esc>v<Left> imap <S-Right> <Esc>v<Right> 

Also mapping usual copy/cut/paste like this you can return to insert mode after select+copy, for example.

vmap <C-c> y<Esc>i vmap <C-x> d<Esc>i map <C-v> pi imap <C-v> <Esc>pi imap <C-z> <Esc>ui 

Now you can start a shift+arrow selection from any mode, then C-c to copy, and then C-v to paste. You always end in insert mode, so you have also C-z to undo.

I think this approaches more to the 'expected standard' behaviour for a text editor yu are asking for.

like image 53
RubenCaro Avatar answered Sep 28 '22 12:09

RubenCaro