In Vim while in the INSERT mode, I would like to be able to move between lines using the left and right arrow keys. For example, if the cursor is at the beginning of a line and I press the left arrow key, I would like the cursor to move to the last character of the previous line.

This is trivial to set up for the NORMAL mode (set whichwrap+=<,>,h,l in .vimrc), but how do I make it work also in the INSERT mode?

Similarly, it would be nice if also Ctrl+Left and Ctrl+Right (to move between words) worked the same way (e.g., Ctrl+Left would move the cursor from the beginning of the first word on a given line to the beginning of the last word on the previous line).


  • :help 'whichwrap' also affects insert mode so you have nothing to do, Vim already behaves the way you want.
    – romainl
    Commented May 12 at 6:45
  • 1
    Thank you! Adding ,[,] to whichwrap in .vimrc (–> set whichwrap+=<,>,[,],h,l) does the trick.
    – nvx
    Commented May 12 at 7:36

1 Answer 1


As mentioned in the comments, you can add [ and ] to 'whichwrap' to make the Left and Right keys work in Insert (and Replace) mode:

    Allow specified keys that move the cursor left/right to move to the
    previous/next line when the cursor is on the first/last character in
    the line.  Concatenate characters to allow this for these keys:
        char   key    mode  ~
         b    <BS>   Normal and Visual
         s    <Space>    Normal and Visual
         h    "h"    Normal and Visual (not recommended)
         l    "l"    Normal and Visual (not recommended)
         <    <Left>     Normal and Visual
         >    <Right>    Normal and Visual
         ~    "~"    Normal
         [    <Left>     Insert and Replace
         ]    <Right

These are not present by default.

  • Thanks. After @romainl pointed me in the right direction, I added the salient bit to my comment so that others do not need to look through the manual themselves.
    – nvx
    Commented May 13 at 5:04
  • @nvx btw, welcome to Vi and Vim! We prefer to put answers in "Answers" so they can be voted on, accepted, etc. Comments are typically transient and have other purposes. (As a meta comment, reading the manual is a skill well worth honing: :help 'whichwrap' would have answered your question immediately.)
    – D. Ben Knoble
    Commented May 13 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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