Reputation: 15922
In VIM in command line mode a "%" denotes the current file, "cword" denotes the current word under the cursor. I want to create a shortcut where I need the current line number. What is the symbol which denotes this?
Upvotes: 13
Views: 4286
Reputation: 72926
If you want to pass the current line number to a shell command, you could do
:exe "!echo " . line(".")
Upvotes: 11
Reputation: 12971
. (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.
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 .
You can find out about the expansions that are done (like %
and #
for example) in :he cmdline-special
.
Upvotes: 14
Reputation: 338228
To return the line number of current line at bottom of screen, use:
:.=
Upvotes: 2
Reputation: 15940
Commands in vim works on the current line so:
:s/foo/bar/g
will transform every foo in bar on the line you are currently on.
Upvotes: 1