This tip is very similar to the following:
These tips need to be merged – see the merge guidelines.
created 2006 · complexity basic · author Robert · version 5.7
Silly little tip, but could save tons of typing:
Move to a blank line, "V" to visually select it, then "!pwd"
Basically you're using the filter command "!" to filter a null selection and replace it with the output of that command. "pwd" on Unix-like systems returns the current directory, so you can use it to grab the current directory name with "!pwd", listing of files with "!ls", etc.
Another way is to use "CTRL-R = getcwd()". This is more typing but executes faster because it's not spawning an external command (the pwd command). If you do this a lot it's better to use inoremap to bind that sequence to a dedicated key.
:inoremap \fp <C-R>=getcwd()<CR>
Then in insert mode, the key sequence backslash f p will insert the current working directory.