我试图在vim中学习一些新的整齐快捷键,并且我发现了g_。据 http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively/
$ → go to the end of line
g_ → go to the last non-blank character of line
我当会改用$的G_?
我试图在vim中学习一些新的整齐快捷键,并且我发现了g_。据 http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively/
$ → go to the end of line
g_ → go to the last non-blank character of line
我当会改用$的G_?
我觉得最重要的区别仅仅是在帮助文件中指出:
:h $
In Visual mode the cursor goes to just after the last character in the line.
所以,如果你v$d它删除,包括这是“最后一个字符后”换行符,所以它会把它下面的行带到当前行。但如果你这样做vg_d它将保持换行。
我其实并不知道g_
,似乎很有用。
编辑由于这个答案得到upvotes,因为我已经使用g_
(和它的反面,_
),以使该猛拉/删除当前行不包括前导/尾随空格,不包括换行的映射:
" delete/yank line, but only whitespace-trimmed version
nnoremap <Leader>dd _yg_"_dd
nnoremap <Leader>yy _yg_
g_
当您将文本粘贴到不希望包含换行符的地方时,您可以使用g_
,例如命令行将自动运行该命令。
...当你想要去行中的最后一个非空白字符,以防行尾有空格吗? – 2012-08-11 21:33:25