Friday, March 1, 2013

Gvim Basics


  1. Introduction to gvim 

Gvim is very much efficient for developers. It is command base editor. The difference between vim and gvim is that gvim is gui version of unix editor vim. gvim has nice gui control with hi-lighting facility.

You can download gvim form url www.vim.org or you can simply search on google it is easily available.

Let's gets start with gvim. First of all we will start with the configuration of gvim.

2.1 Configuration gvim

Gvim is configured by .vimrc or .gvimrc file in linux system. While for windows system this file name is _vimrc file. For linux no need to do anything if you have created the file just copy it in home folder and restart your gvim again and you are opening file with new configuration.

set nocompatible " Use gVim defaults

" set tw=80   tw to specify a default text width
set fo=tcrq  " fo to specify default formatoptions
   " t auto-wraps text using textwidth
   " c auto-wraps comments using textwidth
   " r auto-inserts the current comment leader
   " q allows formatting of comments

   " allow backspacing over everything in insert mode
   set backspace=2

set tabstop=1           " Each Tab has 1_spaces equivalent width
set shiftwidth=2        " Indentation width when using >> and << re-indentation
set nobackup
set expandtab           " Tabs are expanded to spaces

 here example for .vimrc is givm. This I have checked in linux system only.

2.2   Gvim modes

Gvim is model editor it has two modes of operation for editing files 1) insert mode 2) qcommand mode
There might be other mode for using it but for beginners this two is enough
      **) Insert mode
  Once you have started gvim by default you are in command mode. To enter from command mode to insert mode press character "i" and you will be in insert mode. Edit files as per you want to edit it and than press Esc for getting into command mode
      **) Command mode
    Command mode is the most important part of gvim. Or I can say command mode is the only advantage of gvim. By pressing Esc you can get into command mode of gvim. Then write commands
":" and write your required command for process like cut,copy, highlight etc.

For beginners I have listed down some commands that will be very much useful.

3. Gvim basic commands

  •  a ,  i
    Both of these command is used for entering into insert mode. The difference between them is  when we use "i" cursor is placed before character while using "a" cursor is placed at the end of the charecter.
  • :w
    Once you have written or entered text in the file you are editing in gvim. You have to save it before you quit the file. You can do it by simply writing command :w and it is written inside hard drive.
  • :quit , :q
    Once you have edited file in gvim. :q command is used for quitting the file. This command will not work if you have not saved the changes. And to ignore the changes you can use the command ":q!" command this command will close the file with ignoring the changes made in the file.
  • :wq , wa, wqa , qa
    All these four commads are the combination of the w, q and a(here a for all) :wq command writes  and quit file you are editing in gvim. :wa command saves all files that are currently open in the window. Same way :qa command quits all files open in the window(again :qa will work only if you have saved all files being edited in gvim's current window). And in the last my favorite command   when I am leaving my office in hurry is :wqa. This command writes and quits all the files that is being edited currently in gvim.


    These are four basic commands that is needed when you are using gvim first time. Another commands for gvim editor I have given at following page as this page is getting too long according to my  view.
    http://gvimeditor.blogspot.in/2013/03/gvim-basics-2.html



                                                   GO BACK TO INDEX

No comments:

Post a Comment