(remove deleted tip) |
(Change <tt> to <code>, perhaps also minor tweak.) |
||
Line 5: | Line 5: | ||
|previous=1321 |
|previous=1321 |
||
|next=1323 |
|next=1323 |
||
− | |created= |
+ | |created=2006 |
|complexity=basic |
|complexity=basic |
||
|author=Robert |
|author=Robert |
||
Line 23: | Line 23: | ||
---- |
---- |
||
− | 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 < |
+ | 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 <code>:`a,`s !sort</code> or any other command. Even better if you map a key to :`a,`s. E.g. |
<pre> |
<pre> |
||
Line 34: | Line 34: | ||
On Windows, instead of "pwd" use "cd", and instead of "ls" use "dir". |
On Windows, instead of "pwd" use "cd", and instead of "ls" use "dir". |
||
− | On Windows in normal mode, type < |
+ | On Windows in normal mode, type <code>!!cd</code> and press Enter, to replace the current line with the name of the current directory. |
---- |
---- |
Revision as of 06:20, 13 July 2012
Duplicate tip
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.
Comments
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.