Vim
I'm a big fan of modal editing and specifically Vim.
Resources
Videos
Derek Wyatt Vim Videos - The first
time I came across their videos was on global commands - Globals, Command Line and Functions.
This is a pretty good video to show some magic of Vim and it is very funny to boot! This would be my
current video of choice to show someone the power of Vim at the hands of an advanced user.
Greg Hurrell - Greg's channel is not exclusively about Vim,
but his channel full of Vim tips and tricks.
Tips
Map
CapsLock
toEsc
In Linux I've used xmodmap based method for mapping for this.
On macOS this could be done via settings -
https://stackoverflow.com/questions/127591/using-caps-lock-as-esc-in-mac-os-x.
Appending result from an external command to the buffer - https://vim.fandom.com/wiki/Append_output_of_an_external_command
read !<external command>
For example, to get CPU info into the current buffer,
read !cat /proc/cpuinfo
.Format JSON,
with
python
-:%!python -m json.tool
with
jq
tool -:%!jq '.'
Change
Tabs
toSpaces
- https://stackoverflow.com/questions/426963/replace-tabs-with-spaces-in-vimAnother option to would be to reindent the whole file with
gg=G
.Enabling mouse scroll support - https://stackoverflow.com/questions/7225057/use-mouse-scroll-wheel-in-vim.
Opening files based on a command line search. This is more of a command line tip, but I find this pattern to be quite useful. To open all Dockerfiles in a directory,
Another adaptation of this pattern is to use a temporary vim buffer to put the search results and then open files based from buffer contents.
Write a file as superuser,
How this works - https://stackoverflow.com/questions/2600783/how-does-the-vim-write-with-sudo-trick-work.
Last updated