About a year ago I finally bit the bullet and commited to learning a real text editor. I went with Vim. Once you break through its initial steep learning curve, its truly life changing. Level up to text surgeon today.
I usually clone my
scripts git repo straight into my home directory i.e.
~/git/scripts/linux/vim. A couple of symlinks later, I’m away:
ln -nfs ~/git/scripts/linux/vim/vimrc ~/.vimrc ln -nfs ~/git/scripts/linux/vim ~/.vim
Vim has brilliant built-in help. Its only one
:h operator or
Vim is incredibly customisable. Its important to craft your own .vimrc. Type
:options to understand the various levers you can pull to make Vim your editor.
|!||filter through a program|
:h operator for more. All combine with a motion (or a visual mode selection). Some examples:
- gUaw - make a word shout case
- dap - delete entire paragraph
- g?ap - ROT13 encode paragraph
- gUgU - shout case entire line (when two operators are invoked in duplicate, applies to current line)
- To select a word
aw(a word) or
- To select a sentence
as(a sentence) or
is(inner sentence). See the pattern here.
- To select a paragraph
- A block
- A block (parentheses)
This is important to me. Coming from bukly powertools like IntelliJ or Resharper, in order to be remotely productive, I need to be able to efficiency locate and jump between files within a large code base.
- CtrlP my personal favourite, for text based fuzzy file, buffer, MRU file navigation. Its pure Vimscript so very portable.
- NERDTree add’s a visual file system based tree.
Leverage the built-in windows manager, which can do splits to view multiple files at the same time.
- Ctrl-w o - close all windows other than the active one.
- Ctrl-w x - exchange active window with the next one.
- Ctrl-w c - close the current window.
- Ctrl-w r (R) - rotate windows clockwise (or counter clockwise).
The Edit (e) Command
Vim’s built-in edit command, will present you with a nice file system explorer, for example
:e . to present the current working directory.
Makes line numbering relative. So good! Makes it fast to figure out how many lines up or down you need to move, to get to the line you want. Example,
14j to jump 14 lines down.
2 I usually clone my `scripts` git repo straight into my home 1 ¬ 13 ln -nfs ~/git/scripts/linux/vim/vimrc ~/.vimrc¬ 1 ln -nfs ~/git/scripts/linux/vim ~/.vim¬ 2 ¬ 3 Vim has brilliant built-in help. Its only one `:help` away.
Editing a file, but don’t have privileges to save.
:w !sudo tee %
:w writes to
sudo tee %.
tee flows the output of the file write to
%, the name of the current file.