vim
vim is a text editor that is a
clone of the vi editor,
which was created around 1976. Despite its age, vim is one of the most
popular editors in the world, and it is available on virtually every
computing platform (or vi is available).
vim has a bit of a learning curve, meaning that you may get somewhat
frustrated with it until you have used it a few times. In particular,
there are two modes: COMMAND mode and INSERT mode. In COMMAND mode,
you execute commands (like undo, redo, find and replace, quit, etc.). In
INSERT mode, you type text. To go into INSERT mode from COMMAND mode, you
type i. To go back to COMMAND mode, you type the esc key.
To open a file (or create one):
$ vim filename
vim starts out in COMMAND mode. Seasoned vim users spend most of
their time in COMMAND mode, unless they are actively typing text. Although
the arrow keys work in INSERT mode, vim was designed so that users don't
need to move their fingers off of the home row to move around the screen.
In COMMAND mode, the following keys move you around:
j : down
k : up
h : left
l : right
w : move forward one word
b : move backward one word
ctrl-f : page down
ctrl-b : page up
(number)G - go to a line number (e.g., 25G goes to line 25.)
:number - same as above (go to line. e.g., :25 goes to line 25)
gg - go to the first line in the file G - go to the last line in the file
Other keys that are important:
i - go into INSERT mode before the current character
a - go into INSERT mode after the current character
A - go into INSERT mode at the end of the current line
<esc> character - go back into COMMAND mode
/searchTerm : search for a term, e.g., /current<enter> will search
for the word "current".
n - go to the next match from a search
N - go to the previous match for a search
:w - saves the file
:wq - saves the file and exits (abbreviation is :x)
:q - quit
:q! - quit without saving
For more, check out The CS 107 Guide to Vim
The builtin vim tutorial on myth, by running the "vimtutor" program:
$ vimtutor
Seriously, take a moment to do this!! Much of what gives you comfort in an editor is just muscle memory, so you should plan on spending time this week just typing something, anything!
There is also a fun online vim tutorial, called Vim Adventures