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?
vim has two "modes": COMMAND mode and INSERT mode. In COMMAND mode, you execute commands (like undo, redo, find and replace, quit, etc.). In INSERT mode, you type text. There is a third mode, VISUAL mode, that is used to highlight and edit text in bulk.
Once in insert mode, typing inserts characters just like a regular text editor. You can enter it by using an insert command from normal mode. Insert commands include: i for 'insert', this immediately switches vim to insert mode.
. (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
.
If you want to pass the current line number to a shell command, you could do
:exe "!echo " . line(".")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With