Automatically go to next line in vim

后端 未结 2 1193
不知归路
不知归路 2020-12-08 09:48

One frustrating behavior in vim is that when i move my cursor right or left (respectively \"l\" or \"h)\" and i am at the end or the beginning of the line, my cursor doesn\'

相关标签:
2条回答
  • 2020-12-08 10:36

    Put the following into your .vimrc:

    set whichwrap+=<,>,[,]
    
    0 讨论(0)
  • 2020-12-08 10:43

    You can use the whichwrap setting to make h and l wrap around the start and end of individual lines:

    set whichwrap+=h,l
    

    However, Vim's documentation recommends against this, probably because it could have unexpected side effects (like breaking plugins, or changing how common key mappings work).

    As an alternative, you can do what what Matti Virkkunen recommended:

    set whichwrap+=<,>,[,]
    

    This leaves h and l with their default behavior, but allows the left and right arrow keys to wrap around lines. (This is what I do, and it works well.)

    You might also want to take a look at the backspace setting, to control how Backspace, Delete, Control+W, and Control+U work in Insert mode. I set mine like this:

    set backspace=indent,eol,start
    

    That allows me to backspace over pretty much everything.

    For more info, see these topics in the Vim help:

    :help 'whichwrap
    :help 'backspace
    
    0 讨论(0)
提交回复
热议问题