Thursday, November 4, 2010

Vi and the Vim

I taught Henry how to edit previous blog posts. The end.

So after that lesson I read more from the book. As you may already know (YOU should know :P) to edit or create a new file you would run the command vi /your/directory/and/file/here. Once inside vi you use the lowercase i to enter insert mode where you enter text. Apparently I does the same thing but takes you to the beginning of the line. There are also a few other insert methods. Also another cool feature when opening a file is adding +(your number here) and it will jump to said line in the file. To navigate when not in the insert mode you can either use the arrow keys or HJKL H being left, J down, K up, and L right. Personally I use arrow keys but nethack may force me to use HJKL.

Paragraph break for the eyes. So more editing commands. To undo you just simply press u but sometimes I use q! when I accidently edit something I probably shouldn't have. I know I can use u but... To save and exit a file the the wq writes and quits. Simple. There is also the x which saves and quits and apparently you have to know the two for the exam. More stuff. dd deletes an entire line and yy copies an entire line. When working with the hostname scheme for our lab yy was useful so I wouldn't have to exactly replicate a four line block of text with proper syntax. p pastes whatever is in the unnamed buffer as the book puts it (clipboard sounds cooler). Some more advanced copy-paste that I am unlikely to ever use is the fact that vi has 27 buffers (one is unnamed) and you can copy things to any of them if you specify it. If not it just overwrites the unnamed buffer. Example "ayy would yank the line to buffer a and "ap pastes it.

Lots of stuff to cover in vi unfortunately but I'm almost through with that chapter.

1 comment:

  1. Excellent! One suggestion for information like this to make it even better on the eyes: use bulleted lists instead of paragraphs when writing about what is essentially a list of things.

    ReplyDelete