When I added a vim plugin, VimAwesome document said that
:source %. What does this mean? I'd like to understand
% expands to the name (path) of the file opened in the current buffer. In this case, it seems the file in the current buffer is the script that implements VimAwesome.
:source command will read the file and interpret the VimScript instructions in it, so this command will effectively load the vim plug-in into your current vim session.
vim uses vi's keys for the
% (current file/buffer) and
# (alternate file/buffer).
In any vi-(imitation/emulation/clone) you can use those characters for referring to the current filename and the "other" file. On most terminals/keyboards you can use controlshift
6 for switching between current/alternate buffers, although that is not mentioned in POSIX vi. It only goes as far as this:
>-escaped '%' characters appearing in file arguments to any ex command shall be replaced by the current pathname; unescaped '#' characters shall be replaced by the alternate pathname. It shall be an error if '%' or '#' characters appear unescaped in an argument and their corresponding values are not set.
vi already supported special symbols as shortcuts to certain files in the command-line. Vim builds on top of that; you'll find the information at
% symbol in particular refers to the current buffer's filespec. There's also an eponymous register (
:help quote_%), so you can alternatively insert the value into the command-line via
<C-r>%. Or, as the first help topic mentions, you can use this to print the resolved value:
:source % command, when used on the
~/.vimrc configuration, will reload the config. You can achieve the same effect by quitting and restarting Vim, but this is faster. Note that your Vim configuration needs to be cleanly written for that to work. If not,
:autocmds may be duplicated, or you might get errors about existing mappings.