
Vim: hate it then love it
So I’ve been using vim every day for about 6 months now. It was an exercise in frustration for most of that time, until it became second nature; so much so that I then found other editors and word-processors less effective to use as I’d keep trying vim commands…

Starting to use vim is easy with vimtutor, which is simply a clever text file that you learn to manipulate with vim. Here are a few tips:
- Use tabs.
:tabffollowed by a file name will open a file in a new tab — with tab completion.:tabnewis self explanatory.gtselects the next tab,gTthe previous - Use Buffers. This allows you to split a window to view another part of the file for reference.
CTRL+w, wfollowed byssplits horizontally,vvertically.qwill close the window. To open a new file in a buffer,:sp. You may switch windows withCTRL+w, w.opens a split buffer vertically. CTRL+aandCTRL+xincrement and decrement a (decimal) number under the cursor. Precede it with a number to repeat the operation- Use
–VISUAL BLOCK–mode (CTRL+v) combined withIto prepend something to several lines at once. It will take effect when you go back to normal mode. You can also search and replace in the block in any visual mode! ccblanks the line and puts you into insert modeOandocreates a newline above and below the current line respectivelyddpswaps the current line with the nextcifollowed by a delimiter will change text within that delimiter. For example,ci"will changebeansin"beans"cwwill change the current wordvim -pwill open a set of files in tabs.-owill open in a split buffer, and-Owill do the same, but vertically- When on the command line,
Ctrl+fwill allow you to edit the command line vi-style.Ctrl+Cwill exit this mode. Ctrl+[may be better thanESCas you don’t have the leave the home keys- add
set -o vito your bashrc for (default insert-mode) readline editing! Jwill join the next line on the end of the current linevi{to visual mode select in {} parenthesis. Thenzfto fold that section.gvto select the last selectiongqto justify the current paragraph
I recommend you customise vim; I tried getting used to the stock configuration on Ubuntu, but it was too minimal and there were far too many annoyances. Remove the irritating things, add features such as the solarized colour scheme; a well-engineered palette for anything you stare at. Pathogen is worth installing to make managing plugins easier.
I made a vimrc shared between my computers, and eventually got carried away and made a dotfiles git repository with configuration files for bash, tmux and git.
Thanks for reading! If you enjoyed this article or have comments, please consider sharing it on Hacker news, Twitter, Hackaday, Lobste.rs, Reddit and/or LinkedIn.
You can email me with any corrections or feedback.
Tags: