how can i intuitively move cursor in vim?(not by line)

后端 未结 4 949
误落风尘
误落风尘 2020-12-15 22:07

if some lines are too long, it will be forced to be newlined.

for example, normally a long line will looks like this

1 first line
2 this is the long          


        
4条回答
  •  忘掉有多难
    2020-12-15 22:29

    This answer is derived from @mario-rossi 's answer (Kudo to him), with minor midification.

    I use the normal UP and DOWN arrow key, rather than CTRL+up and CTRL+down. And somehow I need to remove one excess space in the INSERT mode mapping to avoid an off-by-one behavior.

    Put the following into your ~/.vimrc:

    " When a long line is wrapped, the "gk" and "gj" allow you to move up and down
    " a visual line, while normal "k" and "j" move a physical line.
    " The following settings map "gk" and "gj" to cursor  and .
    map  gk
    map  gj
    " And the following lines enables same  and  behavior in INSERT mode
    imap   i
    imap   i
    

提交回复
热议问题