1

I often escape insert mode only to change the current line's indent by pressing >> or << and then immediately go back to writing. I wanted to make this easier, so I included these lines on my config:

inoremap <tab> <esc>>>a
inoremap <S-tab> <esc><<a

But, for some reason, whenever you << or >>, Vim moves the cursor to the start of the line as if you had pressed ^. Is there a way to prevent this?

1

This behavior is determined by the 'startofline' option. Set it to off, if you don't want that.

0

Found it! <C-t> and <C-d> are used to indent and outdent from insert mode.

This snippet creates the behavior I was looking for:

inoremap <tab> <C-t>
inoremap <S-tab> <C-d>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.