将光标移动到vim中的文件末尾
When I want the cursor to go to the end of the file (ie the end of the last line) in Vim, I have to
本文翻译自:Move cursor to end of file in vim
When I want the cursor to go to the end of the file (ie the end of the last line) in Vim, I have to type six keystrokes: 当我希望光标在Vim中转到文件的末尾(即最后一行的末尾)时,我必须输入六个键击:
<ESC>G$a
- which translates to ESC + Shift g + Shift 4 + a on my keyboard layout. <ESC>G$a
- 在我的键盘布局上转换为ESC + Shift g + Shift 4 + a 。
How can I do this more efficiently? 我怎样才能更有效地做到这一点?
Since I regularly work on many different machines, I cannot always change .vimrc, so I'm looking for answers without having to edit or create that file. 由于我经常在许多不同的机器上工作,我不能总是改变.vimrc,所以我在寻找答案而不必编辑或创建该文件。
#1楼
参考:https://stackoom.com/question/19Ng4/将光标移动到vim中的文件末尾
#2楼
You could map it to a key, for instance F3, in .vimrc 您可以将它映射到.vimrc中的键,例如F3
map <F3> <Esc>Shift+G<CR>Shift+4<CR>a
I'm really not sure about the Shift+ syntax, you'll need to look that up, but the idea should be sound. 我真的不确定Shift +语法,你需要查看它,但这个想法应该是合理的。
#3楼
No need to explicitly go to the end of line before doing a
, use A
; 无需显式地去行结束前做a
,使用A
;
Append text at the end of line [count] times 在行[count]次结束时附加文本
<ESC>GA
#4楼
For starters, there's no need for the return. 对于初学者来说,没有必要返回。 G$
will do. G$
会的。 And you're being misleading by counting <Esc>
and a
in the length of a normal mode command. 和你被计数误导<Esc>
和a
在正常模式命令的长度。
However, you can use <C-End>
if you like. 但是,如果您愿意,可以使用<C-End>
。
#5楼
The best way to go to the last line of the file is with G
. 转到文件最后一行的最佳方法是使用G
This will move the cursor to the last line of the file. 这会将光标移动到文件的最后一行。
The best way to go to the last column in the line is with $
. 转到该行最后一列的最佳方法是使用$
。 This will move the cursor to the last column of the current line. 这会将光标移动到当前行的最后一列。
So just by doing G$
you get to the end of the file and the last line. 所以只需要做G$
可以到达文件末尾和最后一行。
And if you want to enter insert mode at the end of the file then you just do GA
. 如果您想在文件末尾进入插入模式,那么您只需执行GA
。 By doing this you go to the last line of the file, and enter insert mode by appending to the last column. 通过执行此操作,您转到文件的最后一行,并通过附加到最后一列进入插入模式。 :) :)
#6楼
这更快:
<ESC>GA
更多推荐
所有评论(0)