vim, git, aws and other three-letter words

Software Development Notes

Vim: The useful Ctrl-R

I often use Ctrl-R % to insert the current file name, for example, to make a copy of the current file:

:saveas [Ctrl-R %]
# turns into
:saveas /Users/my/blog/posts/2026-17-10-vim-ctrl-r-is-good.org

Ctrl-R can be used in insert mode or on the command line to paste:

The % and # also work as current file and alternate file aliases on the command line.

For example, :!ls % will show the current file name. A more useful example: :!git add % stages the current file with git.

Only in command-line mode:

See :help i_CTRL-R and :help c_CTRL-R.

Tags: vim