【发布时间】:2012-01-29 16:32:35
【问题描述】:
我最近发现了 VIM 并开始使用它。我发现箭头和退格键有缺陷。 所以我对退格键做了这个
set backspace+=indent,eol,start
如何对箭头键执行此操作以允许正常导航?
【问题讨论】:
我最近发现了 VIM 并开始使用它。我发现箭头和退格键有缺陷。 所以我对退格键做了这个
set backspace+=indent,eol,start
如何对箭头键执行此操作以允许正常导航?
【问题讨论】:
你没有确切地说出你认为箭头键的哪个方面是“有缺陷的”,所以我只能猜测。
您可以使用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> 映射到gk 和gj。或者,您可以:set nowrap 完全消除这种区别。
【讨论】: