Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim - remapping >> << (indent commands)

I would love to map << and >> to single keys to speed up my workflow, but I can't find any info on how to write the remap in my vimrc. Any idea how I can get my remap on?

like image 687
tester Avatar asked Dec 06 '11 02:12

tester


2 Answers

The other responses given answer your immediate question. I would just like to suggest that you remap that to indent and dedent to and respectively, in both normal and visual modes (making sure to add gv to reselect in visual selection mode):

nnoremap <TAB> >>
nnoremap <S-TAB> <<
vnoremap <TAB> >gv
vnoremap <S-TAB> <gv

In insert mode of course, as you probably might know already, you can just use Ctrl-t and Ctrl-d to indent/dedent.

like image 87
Jeet Avatar answered Oct 21 '22 16:10

Jeet


You're probably looking for :noremap:

:noremap > >>
:noremap < <<

If you just use :map, you of course get recursively defined function, which is hilarious. (^C will stop it.) The :noremap variant doesn't recursively expand mappings.

like image 22
sarnold Avatar answered Oct 21 '22 14:10

sarnold