Monday, 29 August 2011

VI Essentials

Sometimes you visit a client and you have got only access to the vi editor. While this editor can be frustrating to learn especially for Windows and Mac users I believe that learning or referring to the below commands might become handy to any IT professional.

Starting/Saving
vi [+n] <file_name>
Open filename positioning the cursor at line number n
:wq
Save the file to disk and quit
:q!
Quit without saving any changes


Moving Cursor
h (or Left arrow key)
Left
l  (or Right arrow key)
Right
k (or Up arrow key)
Up
j  (or Down arrow key)
Down
G
End of file
^
Beginning of current line
$
End of current line


Searching Text
/string
Search down for string
?string
Search up for string
n
Repeat last search
:%s/old-string/new-string/g
Search and replace old-string with new-string


Copying and Pasting Text
[n]yy
Copying n lines into buffer
p
Paste the buffer after the current line


Inserting and Deleting Text
i
Insert starting left of cursor
x
Delete single character
[n]dd
Delete n lines
u
Undo last change


Directives
:set nu / :set nonu
Turn on line numbering / Turn off line numbering
:set ic / :set noic
Ignore case when searching / Ignore case off

6 comments:

  1. Greetings. I know this is somewhat off-topic, but I was wondering if you knew where I could get a captcha plugin for my comment form? I’m using the same blog platform like yours, and I’m having difficulty finding one? Thanks a lot.
    AWS Training in Bangalore | Amazon Web Services Training in Bangalore

    Amazon Web Services Training in Pune | Best AWS Training in Pune

    ReplyDelete
  2. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.

    angularjs-Training in velachery

    angularjs Training in bangalore

    angularjs Training in bangalore

    angularjs Training in btm

    angularjs Training in electronic-city

    ReplyDelete
  3. Fantastic work! This is the type of information that should follow collective approximately the web. Embarrassment captivating position Google for not positioning this transmit higher! Enlarge taking place greater than and visit my web situate
    online Python certification course | python training in OMR | python training course in chennai

    ReplyDelete
  4. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
    Java interview questions and answers | Core Java interview questions and answers

    ReplyDelete
  5. Great post! I am actually getting ready to across this information, It’s very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well.
    Data Science training in Chennai | Data science training in bangalore

    Data science training in pune | Data science online training

    Data Science Interview questions and answers

    ReplyDelete