Register %
contains the name of the current file, and register #
contains the name of the alternate file. These registers allow the name of the current or alternate files to be displayed or inserted. The name, or full path, or directory containing the file can be used.
For example, in directory /abc
the command vim def/my.txt
would edit file /abc/def/my.txt
. The following commands could be entered to display the information shown.
:echo @% def/my.txt directory/name of file
I want to know what does @
mean here.
The @
is a sigil, or special prefix attached to a variable name, that interprets a register like a variable. Other sigils are $
for environment variables, and &
for Vim options.
:echo f " prints variable named f
:echo @f " prints contents of register f
:echo $f " prints contents of environment variable f
:echo &fenc " prints the value of :set fileencodings?
Instead of @a
, you could also use getreg('a')
, which is the corresponding Vimscript function. The @
is just a convenient shortcut.
You'll find this in the help under :help expression-syntax
(expr9
)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments