[英]In VIM command line mode what is the special character/symbol for current line?
In VIM in command line mode a "%" denotes the current file, "cword" denotes the current word under the cursor. 在命令行模式下的VIM中,“%”表示当前文件,“ cword”表示光标下的当前单词。 I want to create a shortcut where I need the current line number.
我想在需要当前行号的地方创建一个快捷方式。 What is the symbol which denotes this?
表示这个的符号是什么?
. 。 (dot) stands for the current line.
(点)代表当前行。
To clarify: This is meant for stuff like :1,.s/foo/bar/g
which will transform every foo
to bar
from the beginning of the file up to the current line. 需要说明的是:这是用于
:1,.s/foo/bar/g
,它将把从文件开头到当前行的每个foo
转换为bar
。
I don't know know of a way to get the current line number expanded for a shell command, which is what you are trying to do by doing :!echo .
我不知道一种为shell命令扩展当前行号的方法,这是您尝试通过
:!echo .
要做的事情:!echo .
You can find out about the expansions that are done (like %
and #
for example) in :he cmdline-special
. 您可以在
:he cmdline-special
找到有关完成的扩展(例如%
和#
)的信息。
如果要将当前行号传递给shell命令,可以执行
:exe "!echo " . line(".")
要返回屏幕底部当前行的行号,请使用:
:.=
Commands in vim works on the current line so: vim中的命令在当前行上有效,因此:
:s/foo/bar/g
will transform every foo in bar on the line you are currently on. 将转换您当前所在行上的bar中的每个foo 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.