This is a summary of both the content of the youtube video by typecraft and also the various tips and examples in the comments below.
From The Video
0:39 - (1) rot-13
1:46 - (2) Insert random data
2:38 - (3) Web browsing using netrw
3:52 - (4) Convert file to html
5:02 - (5) Hex-edit files
5:57 - (6) :Q, old-ex mode as in VI
7:08 - (7) Filter text through shell commands using !
8:08 - (8) Do math in insert mode using
- rot-13:
g?apply rot-13 to alphabetical chars - random data:
:r! head -c 128 /dev/urandom- Also
:r! head -c 128 /dev/urandom | xxd -pto convert to hex
- Also
- web browsing:
:e https://pt2.allsup.co/(uses curl or libcurl or wget) - convert to html:
TOhtml - hex edit files: not actually vim, but a consequence of being able to pipe through a command and replace with the output
:%!xxdto convert to hex, and:%!xxd -rto convert back.
- ex mode:
Qthough this doesn't work in neovim - filter through shell commands: select with
V, then:!jqfor example. vim will pipe the selected lines through the command and replace the selection with the output.v10j:!sortwill sort the 11 lines starting from the cursor (start at cursor line and stop ten lines down from cursor line), orv10j:!sort -Rto shuffle lines.v...:!bashwill treat the selected lines as a bash script, execute it and replace with the result.
- math in insert mode:
<C-r>=and type some expression - use vim as a diary:
:r! date - help 42:
:help 42is an easter egg. Try it.
From The Comments
- bang bang:
!!is shorthand for:.!. So e.g. select lines with some JSON and then!!jqwill pretty print int.!!bcwill treat the line as a math expression and evaluate it.
- visual insert: go into visual mode with
v, then:r!lswill insert the output. So essentiallyv!ls. - open named file:
gfopens in editor, including downloading web links;gxopens usingxdg-open. - C-[:
<C-[>is an alternative to escape. possibly easier to type since esc is a longer distance from home position. - increment/decrement:
C-ato increment first number on the line at or after the cursor;C-xto decrement. - smile:
:smileis an easter egg in neovim.