Some useful vi / vim short-cuts that I'm always forgetting:
Copy and paste a block of text
5Y Copy five lines of text
P Paste the copied text
See also here for how to copy and paste a block of text.
Show hidden characters in a file
:set list Show hidden characters
:set unlist Hide the hidden characters
Moving around in the file
0 Go to the start of a line
$ Go to the end of a line
1G Go to the start of the file
G Go to the end of the file
Insert 50 '-'s in a row
'.'
repeats the last text-changing command. You can type a number before a
command in vi for it to be done a certain number of times. For example,
if you want to make a line of 50 '-'s in a row, you can type '-', then press ESC, and type '50.' to get 50 '-'s.
Toggle auto-indenting for paste
If you want to paste in code from a python script, but don't want the intenting to be messed up, you can type:
:set paste
You can then turn this off later using:
:set nopaste
There is a nice VI cheat sheet here.
:q!
ReplyDeleteemacs foo