vim使箭头键像大多数正常程序一样工作

zei*_*tue 2 vi vim macvim

我最近找到了VIM并开始使用它.我发现箭头和退格有缺陷.所以我这样做了退格

set backspace+=indent,eol,start
Run Code Online (Sandbox Code Playgroud)

如何对箭头键进行正常导航?

Lau*_*ves 7

你没有确切地说你认为箭头键的哪个方面是"有缺陷的",所以我只需要猜测.

您可以使用该whichwrap设置获取您可能想要的部分.来自:help whichwrap:

'whichwrap' 'ww'    string  (Vim default: "b,s", Vi default: "")
            global
            {not in Vi}
    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>    Insert and Replace
    For example: >
        :set ww=<,>,[,]
    allows wrap only when cursor keys are used.
    When the movement keys are used in combination with a delete or change
    operator, the <EOL> also counts for a character.  This makes "3h"
    different from "3dh" when the cursor crosses the end of a line.  This
    is also true for "x" and "X", because they do the same as "dl" and
    "dh".  If you use this, you may also want to use the mapping
    ":map <BS> X" to make backspace delete the character in front of the
    cursor.
    When 'l' is included and it is used after an operator at the end of a
    line then it will not move to the next line.  This makes "dl", "cl",
    "yl" etc. work normally.
    NOTE: This option is set to the Vi default value when 'compatible' is
    set and to the Vim default value when 'compatible' is reset.
Run Code Online (Sandbox Code Playgroud)

在您的情况下,您可能想要:

:set whichwrap+=<,>
Run Code Online (Sandbox Code Playgroud)

这将使左右缠绕线末端.

您也可以尝试映射<Up><Down>gkgj在正常和视觉模式,如果逻辑和显示行之间的区别混淆你.或者,您可以:set nowrap完全消除这种区别.