VIM Editor-Part II

This topic was published by and viewed 888 times since "". The last page revision was "".

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #1608
    Saptarshi Nag
    Saptarshi Nag
    Participant
    • Topics - 6
    • @saptarshi

    In command mode one can move the cursor using keyboard but not using the 'arrow keys'.In fact we can perform so many jobs in command mode.
    Movement Basics:
    h ->moves cursor left
    j ->moves cursor down one line
    k ->move cursor up one line
    l ->moves cursor to the right
    0 ->moves cursor to the beginning of a line
    $ ->moves cursor to the end of the line
    w ->moves cursor forward one line
    b ->moves cursor backward one line
    G ->moves to the end of the file(i.e.,shift+g)
    gg ->moves to the beginning of the file

    Adding a digit will multiply the movement,i.e.,5w will move the cursor forward 5 words but of course use it effectively.

    Saving and Quitting:-
    To save a piece of text or code one has to go to the last line mode,i.e, press : in command mode.You'll see a ':' in the last line of the screen
    To write
    w <filename> //filename is not necessary if it is given previously
    To write and quit Vim press wq
    To quit without saving press q!

    To write over another file w! <filename>
    To quit if nothing has been changed press q

    Searching:-

    One can easily search a character through keyboard in command mode

    /<text> -> searches forward from the cursor position
    ?<text> ->searches backward from the cursor position

    eg. ?hello

    searches the text 'hello' forward from the cursor position.If there are other 'hello's ahead you can find them pressing 'n' and if there are other 'hello's before you can find them pressing 'N'. Now apply these commands to your text written in vim to get the perfect effect.

    Check out DCJTech's official Facebook page - http://dcjtech.info/members/saptarshi/

Viewing 1 post (of 1 total)