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.
Maybe I'm missing something, but this is what ":r!pwd" is usually used for. Simply r(ead)ing the output of a command doesn't replace a visually selected line, but that would normally be a feature.
Why visually select the line....and why :r!pwd even. Simply !!pwd on a line will replace it with the output of the pwd command. Personally my favorite external command setup is to mark the top of the region with an "a" mark the bottom of the region with a "s" and then
:`a,`s !sort or any other command. Even better if you map a key to :`a,`s. E.g.
map - :`a,`s mark region with "a" and "s" - !sort
On Windows, instead of "pwd" use "cd", and instead of "ls" use "dir".
On Windows in normal mode, type
!!cd and press Enter, to replace the current line with the name of the current directory.