vim 使箭头键像大多数普通程序一样工作

发布于 2024-12-23 09:54:29 字数 139 浏览 3 评论 0原文

我最近发现了 VIM 并开始使用它。我发现箭头和退格键有缺陷。 所以我对退格键执行了此操作,

set backspace+=indent,eol,start

如何对箭头键执行此操作以允许正常导航?

I recently found VIM and started using it. I found the arrows and backspace to be flawed.
so I did this to the backspace

set backspace+=indent,eol,start

how can this be done to the arrow key to allow normal navigation?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一个人的夜不怕黑 2024-12-30 09:54:29

您没有确切地说您认为箭头键的哪一方面是“有缺陷的”,所以我只能猜测。

您可以使用 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+=<,>

这将使左右环绕行结尾。

您还可以尝试在正常和视觉状态下将 映射到 gkgj如果逻辑线和显示线之间的区别让您感到困惑。或者,您可以 :set nowrap 完全消除区别。

You don't say exactly what aspect of the arrow keys you think is "flawed", so I'll just have to guess.

You can use the whichwrap setting to get part of what you probably want. From :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.

In your case, you probably want:

:set whichwrap+=<,>

This will make left and right wrap around line endings.

You can also try mapping <Up> and <Down> to gk and gj in normal and visual modes if the distinction between logical and display lines is confusing you. Alternatively, you could :set nowrap to remove the distinction altogether.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文