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

时间:2011-12-29 06:45:09

标签: vim vi macvim

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

set backspace+=indent,eol,start

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

1 个答案:

答案 0 :(得分: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.

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

:set whichwrap+=<,>

这将使左右缠绕行结束。

如果逻辑和显示行之间的区别让您感到困惑,您还可以尝试在正常和可视模式下将<Up><Down>映射到gkgj。或者,您可以:set nowrap完全删除区别。