Tuesday 18 March 2014

The Vim Editor.

VIM EDITOR


    Vim is one of the greatest editor. It is really cool editor to work with. Vim editor is also a editor it is very easy to use. At the start it may seems to be a big thing to start with, But once you learned to use it you will not get out of this editor and you will really love it. It will slightly encourage you to use terminal commands.

Start to work with vim editor


    Here to use vim editor we want to know some basic usage of terminal. From the terminal we are calling vim editor program.

Installation


    If you not installed vim editor then install it using your package manager.
    for debian based system.
          $ sudo apt-get install vim
    for red-hat based system
          $ sudo yum install vim

Start vim


         To start vim editor in your command prompt enter the command give bellow.
         $ vim

Some basic command to start using vim


     Here not to worry to muck up commands just use it will reside with you.

Modes in vim are


     

1) Command mode


                  In command mode we can do move around the file and delete etc,. When we open a file the vim will goes to command mode default.

Moving cursor.


       j    - To move down.
       k   -  To move up.
       l    - To move right.
       h   - To move left.
       0   - To move beginning of line.
       $   - To move end of the line.

Some useful basic command of vim.

     vim command are generally start with colon ':' and command string.

To save file.
     :w    - write buffer to file.
     :q     - quite without saving file.
     :wq  - quite after saving file.
     :w!   - forcefully write to file.
     :q!    - forcefully quite.
     :x     - saving changes to file.

Copy and Cut:
     y       -  To copy a character,
     yy     -  To select entire line,
     dd     -   To cut the entire line,

Past:
     p            - To past after the cursor,
     shift + p - To past before the cursor.


Text selection


   To select some text on the vim, We want to use the character 'v'.
     v              -   To select range of text after pressing 'v' you can use 'h', 'j', 'k', 'l', to select you range.
     Shift + v  -   To select entire line  after pressing 'shift+v' you can use 'h', 'j', 'k', 'l', to select you range.
     ctrl + v     -   To select columns  after pressing 'ctrl+v' you can use 'h', 'j', 'k', 'l', to select you range.
     g + v        -    To re-select.

  After the selection you can do tasks such as cut,delete, copy, past and sort.
    x, d        - To cut the selected content.
    y            -  To copy the selected content.
    p            -   To past the content after the cursor.
    shift + p - To past the content before the cursor.
 

2) Insert mode


     Once we make sure insert mode then only we can insert text to the vim editor, To make insert mode you can press five characters among following.
     a            - Insert after the cursor position now.
     shift + a - Insert after the end of the line.
     o            - Insert to the next line.
     shift + o - Insert to the previous line.
     i             - Insert at the cursor position now.
     shift + i  - Insert at the beginning of the line.

Reference


www.cs.swarthmore.edu