vim家教箭头键v/s hjkl。

时间:2022-06-26 17:26:10

VimTutor says in its first lesson:

维姆导师在第一课中说:

NOTE: The cursor keys should also work. But using hjkl you will be able to move around much faster, once you get used to it. Really!

注意:光标键也应该工作。但是使用hjkl,一旦你习惯了它,你就能更快地移动。真的!

However, I find no difference at all between them. Is there really a difference between using hjkl v/s the arrow keys?

然而,我发现他们之间没有什么不同。使用hjkl v/s的箭头键真的有区别吗?

3 个解决方案

#1


8  

You don't have to move your hand from the touch type position to use hjkl, whereas you do if you use the arrow keys.

您不需要将您的手从触摸类型位置移动到使用hjkl,而如果您使用的是箭头键。

#2


5  

The thing is that you start out using the "hjkl" key just as a slightly better way to move your cursor, but the truth is that they are actually motions.

问题是,您开始使用“hjkl”键作为移动光标的更好方法,但事实是它们实际上是运动。

  • h motions one character left
  • h动议一个角色离开。
  • j motions one line down
  • j向下移一行。
  • k motions one line up
  • k运动一排。
  • l motions one character right
  • 我动议一个角色,对吧。

So for example, with the delete operator d: dl deletes the current character, dh deletes the previous character, dj deletes the current line and a line below it, and dk deletes the current line and a line above it. The same is of course true for the y, c, V, gU and any operator.

例如,删除操作符d: dl删除当前字符,dh删除前一个字符,dj删除当前行和它下面的一行,dk删除当前行和上面的一行。当然对于y, c, V, gU和任何运算符也是一样的。

Another example are split windows. You can create a couple of windows using Control-w+s and Control-w+v, then use your trusty hjkl to move around between your windows, Control-w+h moves a window left, Control-w+j moves a window down, etcetera.

另一个例子是拆分窗口。你可以用Control-w+s和Control-w+v创建几个窗口,然后使用你的trusty hjkl在你的窗口之间移动,Control-w+h移动一个窗口,Control-w+j移动一个窗口,等等。

So it's not just that they are an improvement over the arrow keys. As your understanding of Vim grows, you'll learn that the hjkl keys can be combined with other commands in many ways, and you will be happy you can use them.

所以这不仅仅是对方向键的改进。随着您对Vim的理解的增长,您将了解到hjkl键可以在许多方面与其他命令组合在一起,您将很高兴您可以使用它们。

#3


1  

In fact, using h j k l keys makes a good practice to avoid to much of right hand movimentation on your keyboard when you have to reach the arrow keys but, there are more efficient ways to navigate through a text file using vim:

事实上,使用hj k l键可以很好地避免在键盘上出现大量的右手移动,但在使用vim时,有更有效的方法来浏览文本文件:

  • f <char> : Go to the next occurrence of a character<char> on the current line. Cursor is placed above the character;
  • f :下一个字符 在当前行上出现。光标置于字符上方;
  • t <char> : Go to the next occurrence of a character<char> on the current line. Cursor is placed right before the character;
  • t :下一个字符 在当前行上出现。光标置于字符之前;
  • T and F: Backward your character search on this line, however T will put the cursor right after the character(or before if you think backwards ;) ), and F will put it above of it.
  • T和F:在这一行上,你的字符搜索后退,但是T将会把光标放在字符后面(如果你想向后看的话),F会把它放在上面。
  • / <char> <Enter>: Go the next occurrence of a character independent of line. After you do this one time, pressing n or N goes to the next and previous occurrence.
  • / <输入> :下一个字符独立于行。在你做了这个之后,按n或n就会进入下一个和之前的事件。
  • ? <char> <Enter>: Go to the next occurrence of a character independent of line, backwards. n will search next occurrence(backwards) and N will go to the previous.
  • 吗? : Go to the next occurrence of a character independent of line,后退。n将搜索下一个事件(向后),而n将转到前面。
  • { and } : Navigate on paragraphs. Paragraphs are basically blocks divided by an empty line. See :help paragraph for further details.
  • {和}:在段落中导航。段落基本上是由空行分隔的块。参见:帮助段落了解更多细节。
  • ( and ) : Navigate back and forward on Sentences(:help sentence). A sentence is a group of words ended by . ! or ? followed by a space, tab or endline.
  • (和):在句子(帮助句)上来回导航。一个句子是一组单词的结尾。!还是?接着是空格、制表符或endline。
  • e : next word, place the cursor at the end of the word
  • e:下一个单词,把光标放在单词的末尾。
  • w : next word, place the cursor at the start of the word
  • w:下一个单词,把光标放在单词的开头。
  • b : back 1 word, place the cursor at the start of the word
  • 返回一个单词,把光标放在单词的开头。
  • ge : back 1 word, place the cursor at the end of the word
  • 返回一个单词,把光标放在单词的末尾。
  • E W B and gE : Same as e w b ge, but with WORD. See :help word for further details.
  • E W B和gE:和ew B gE一样,但是用WORD。参见:帮助单词获取更多细节。

If you want to start by getting the first good habits of using h j k l or other movements and avoid the arrow keys, pleace the following lines on your .vimrc file inside your home to disable them:

如果你想从使用hj k或其他动作的第一个好习惯开始,并避免使用箭头键,请在你家里的.vimrc文件上列出以下几行来禁用它们:

noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>

#1


8  

You don't have to move your hand from the touch type position to use hjkl, whereas you do if you use the arrow keys.

您不需要将您的手从触摸类型位置移动到使用hjkl,而如果您使用的是箭头键。

#2


5  

The thing is that you start out using the "hjkl" key just as a slightly better way to move your cursor, but the truth is that they are actually motions.

问题是,您开始使用“hjkl”键作为移动光标的更好方法,但事实是它们实际上是运动。

  • h motions one character left
  • h动议一个角色离开。
  • j motions one line down
  • j向下移一行。
  • k motions one line up
  • k运动一排。
  • l motions one character right
  • 我动议一个角色,对吧。

So for example, with the delete operator d: dl deletes the current character, dh deletes the previous character, dj deletes the current line and a line below it, and dk deletes the current line and a line above it. The same is of course true for the y, c, V, gU and any operator.

例如,删除操作符d: dl删除当前字符,dh删除前一个字符,dj删除当前行和它下面的一行,dk删除当前行和上面的一行。当然对于y, c, V, gU和任何运算符也是一样的。

Another example are split windows. You can create a couple of windows using Control-w+s and Control-w+v, then use your trusty hjkl to move around between your windows, Control-w+h moves a window left, Control-w+j moves a window down, etcetera.

另一个例子是拆分窗口。你可以用Control-w+s和Control-w+v创建几个窗口,然后使用你的trusty hjkl在你的窗口之间移动,Control-w+h移动一个窗口,Control-w+j移动一个窗口,等等。

So it's not just that they are an improvement over the arrow keys. As your understanding of Vim grows, you'll learn that the hjkl keys can be combined with other commands in many ways, and you will be happy you can use them.

所以这不仅仅是对方向键的改进。随着您对Vim的理解的增长,您将了解到hjkl键可以在许多方面与其他命令组合在一起,您将很高兴您可以使用它们。

#3


1  

In fact, using h j k l keys makes a good practice to avoid to much of right hand movimentation on your keyboard when you have to reach the arrow keys but, there are more efficient ways to navigate through a text file using vim:

事实上,使用hj k l键可以很好地避免在键盘上出现大量的右手移动,但在使用vim时,有更有效的方法来浏览文本文件:

  • f <char> : Go to the next occurrence of a character<char> on the current line. Cursor is placed above the character;
  • f :下一个字符 在当前行上出现。光标置于字符上方;
  • t <char> : Go to the next occurrence of a character<char> on the current line. Cursor is placed right before the character;
  • t :下一个字符 在当前行上出现。光标置于字符之前;
  • T and F: Backward your character search on this line, however T will put the cursor right after the character(or before if you think backwards ;) ), and F will put it above of it.
  • T和F:在这一行上,你的字符搜索后退,但是T将会把光标放在字符后面(如果你想向后看的话),F会把它放在上面。
  • / <char> <Enter>: Go the next occurrence of a character independent of line. After you do this one time, pressing n or N goes to the next and previous occurrence.
  • / <输入> :下一个字符独立于行。在你做了这个之后,按n或n就会进入下一个和之前的事件。
  • ? <char> <Enter>: Go to the next occurrence of a character independent of line, backwards. n will search next occurrence(backwards) and N will go to the previous.
  • 吗? : Go to the next occurrence of a character independent of line,后退。n将搜索下一个事件(向后),而n将转到前面。
  • { and } : Navigate on paragraphs. Paragraphs are basically blocks divided by an empty line. See :help paragraph for further details.
  • {和}:在段落中导航。段落基本上是由空行分隔的块。参见:帮助段落了解更多细节。
  • ( and ) : Navigate back and forward on Sentences(:help sentence). A sentence is a group of words ended by . ! or ? followed by a space, tab or endline.
  • (和):在句子(帮助句)上来回导航。一个句子是一组单词的结尾。!还是?接着是空格、制表符或endline。
  • e : next word, place the cursor at the end of the word
  • e:下一个单词,把光标放在单词的末尾。
  • w : next word, place the cursor at the start of the word
  • w:下一个单词,把光标放在单词的开头。
  • b : back 1 word, place the cursor at the start of the word
  • 返回一个单词,把光标放在单词的开头。
  • ge : back 1 word, place the cursor at the end of the word
  • 返回一个单词,把光标放在单词的末尾。
  • E W B and gE : Same as e w b ge, but with WORD. See :help word for further details.
  • E W B和gE:和ew B gE一样,但是用WORD。参见:帮助单词获取更多细节。

If you want to start by getting the first good habits of using h j k l or other movements and avoid the arrow keys, pleace the following lines on your .vimrc file inside your home to disable them:

如果你想从使用hj k或其他动作的第一个好习惯开始,并避免使用箭头键,请在你家里的.vimrc文件上列出以下几行来禁用它们:

noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>