Right now, I am Learning Python the Hard Way, after lesson 10, I decided screw gedit
I am going to learn vi. Vi is known to have a steep learning curve, but these basic commands are enough to help you to get through Learning Python the Hard Way.
The good thing about this course is you start with rather small code, not much then 10 lines in the first couple of lessons. This makes it perfect to get a more then decent grip on vi, knowledge of the basic workings of the Terminal is assumed though!
If you want to see some vids about vi first, then I would suggest watching the Lullabot vids called Command Line Basics, at vid 9 she discusses vi. The whole series is worth watching though
This cheat sheet is based on this vi command summary, I added one help full Python command
Starting vi
Command | Description |
---|---|
vi file | start at line 1 of file |
vi +n file | start at line n of file |
vi + file | start at last line of file |
vi -r file | recover file after a system crash |
Saving files and quitting vi
Command | Description |
---|---|
:q | quit vi |
:”x” | save the file if it has changed and quit vi (don’t use the quotation marks around the x!) |
:”q”! | quit vi without saving changes(don’t use the quotation marks around the q!) |
Setting line numbers
Keys pressed | Effect |
---|---|
:set number | displays line numbers |
:set no number | remove line numbers |
Moving the cursor
Keys pressed | Effect |
---|---|
h | left one character |
l | right one character |
k | up one line |
j | down one line |
b | left one word |
w | right one word |
( | start of sentence |
) | end of sentence |
{ | start of paragraph |
} | end of paragraph |
1G | top of file |
nG | line n |
G | end of file |
Inserting text
Keys pressed | Text inserted |
---|---|
a | after the cursor |
i | before the cursor |
Deleting text
Keys pressed | Text deleted |
---|---|
x | character under cursor |
dd | current line |
CTR + z stops a Python script
Want a pdf file of this cheat sheet? Cliccie on the pinkbutton!