-
Read the output of a bash command
:read !bashcommand <CR> -
Copy/paste from one session to another
In source file (start in normal mode):
- Use
mato mark first line - Use
mbto mark last line - Use
:'a,'b w! xferto write out range to a scratch file
In destination file:
- Move cursor to desired paste location
- Ensure you're in normal mode
- Use
:r xferto read in text
- Search and Replace Tricks
- Capture Groups: enclose portion between
\(and\), refer to it with\1,\2, etc. sequential. - Visual Mode:
v, select desired text,:s(will create a command that looks like'<,'>s/find/replace with/flags) - Scope:
:srefers to current line,:5,9srefers to lines 5-9 inclusive,:%srefers to entire file.
Examples:
'<,'>s/,\(\d\),/, \1,/glooks for a comma followed by a single digit followed by another comma and inserts a space between the first comma and the digit. Command will apply to a visual selection.
- Put Vim in the background and execute some terminal commands
<Ctrl-z>Run terminal commands$ fgto go back to Vim.
Append Output of an External Command
Vim Regex
This page was last updated: Sun 20 May 2018 10:46:50 PM EDT