(NEO)VIM
Redirect output of Ex commands to register
:redir @a:__commands__:redir END"ap
Redirect output of telesope to quickfix:
C-q
Run bash (or any shell) for buffer content
:%!bash
Convert textfile to pdf (via ps)
vim filename.txt -c "hardcopy > filename.ps | q"; pstopdf filename.ps
pstopdf may be names ps2pdf on other OSes
Alternative undo redo
:earlier __time__
:later __time__
where time = x(s|m|h|d) (s = second, m = minute, h = hour, day)
to go back and forth on state of buffer in time of x units
Remote editing (using ssh config)
:e scp://remote-host/~/path/to/file.ext
Assuming a Host for ‘remote-host’ is set in ~/.ssh/config
Delete other buffers except current
:% bd | e # | bd #
where
- % bd = delete all buffers (creates a new no-name buffer),
- e # = edit previous buffer (since current is no-name),
- bd # = delete previous buffer (no-name)
spaces are optional
Ex mode completion options
TAB cycles through options; Ctrl-a inputs all options.
Example: To delete all *.js files in buffer list
:bd js Ctrl-a
Can use
:bwipeoutto completely remove a buffer
Search and Replace (Using neovim telesope)
- Search for a term
:Telescope live_grep - Put all results in quickfix buffer
<C-q> - Run replace interactive on all results
:cdo s/<sterm>/<rterm>/g[ci] | update - Capture groups are defined by
\1\2etc and original string by&
Check diff of files
nvim -d -R file_one file_two
- -d = diff
- -R = Readonly
Set filetype in a comment
# vi: ft=bash