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?
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.
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.
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.
I find these to be the most natural indentation keymaps for both normal and visual modes
" Normal mode
nnoremap > >>
nnoremap < <<
" Visual mode
vnoremap < <gv
vnoremap > >gv
© 2022 - 2024 — McMap. All rights reserved.
>>
, you can press.
to repeat the action. Just about as good as remapping to a single keystroke. – Swifter<
or>
performs the indentation already. – Swifter=
to fix indentation as well... – Swifter