Next Previous Contents

2. Setup gvim init files

To enable the syntax color highlighting you MUST copy the gvimrc file to your home directory. This will also put the "Syntax" Menu with gvim command. You can click on Syntax Menu and select appropriate languages like C++, Perl, Java, SQL, ESQL etc..


cd $HOME
cp /usr/doc/vim-common-5.3/gvimrc_example  ~/.gvimrc

Comment lines in .gvimrc begin with double-quotes ("). You can customize gvim by editing the file $HOME/.gvimrc and put the following lines -
" This line is a comment .... one which begins with double-quotes
" The best is the bold font, try all of these and pick one....
set guifont=8x13bold
"set guifont=9x15bold
"set guifont=7x14bold
"set guifont=7x13bold
"
" Highly recommended to set tab keys to 4 spaces
set tabstop=4
set shiftwidth=4
"
" The opposite is 'set wrapscan' while searching for strings....
set nowrapscan
"
" The opposite is set noignorecase
set ignorecase

It is very strongly recommended that you set the tabstop to 4 and shiftwidth to 4. The tabstop is number spaces TAB key will put while editing with gvim. The shiftwidth is the number spaces the lines will be shifted with ">>" or "<<" vi commands (Press twice "greater than" and "less than" keys on keyboard). Refer to Vi tutorials Vim Tutorial for more details.

2.1 Sample gvimrc file

You can change the settings like color, bold/normal fonts in your $HOME/.gvimrc file. It is very strongly recommended that you set the background color to lightyellow or white with black foreground. Ergonomics says that best background color is lightyellow or white with black foreground. Hence change the variable 'guibg' in your $HOME/.gvimrc file as follows:


        highlight Normal guibg=lightyellow

The sample gvimrc from /usr/doc/vim-common-5.3/gvimrc_example is as follows:


" Vim
" An example for a gvimrc file.
" The commands in this are executed when the GUI is started.
"
" To use it, copy it to
"     for Unix and OS/2:  ~/.gvimrc
"             for Amiga:  s:.gvimrc
"  for MS-DOS and Win32:  $VIM\_gvimrc

" Make external commands work through a pipe instead of a pseudo-tty
"set noguipty

" set the X11 font to use
" set guifont=-misc-fixed-medium-r-normal--14-130-75-75-c-70-iso8859-1

" Make command line two lines high
set ch=2

" Make shift-insert work like in Xterm
map <S-Insert> <MiddleMouse>
map! <S-Insert> <MiddleMouse>

" Only do this for Vim version 5.0 and later.
if version >= 500

  " I like highlighting strings inside C comments
  let c_comment_strings=1

  " Switch on syntax highlighting.
  syntax on

  " Switch on search pattern highlighting.
  set hlsearch

  " For Win32 version, have "K" lookup the keyword in a help file
  "if has("win32")
  "  let winhelpfile='windows.hlp'
  "  map K :execute "!start winhlp32 -k <cword> " . winhelpfile <CR>
  "endif

  " Hide the mouse pointer while typing
  set mousehide

  " Set nice colors
  " background for normal text is light grey
  " Text below the last line is darker grey
  " Cursor is green
  " Constants are not underlined but have a slightly lighter background
  highlight Normal guibg=grey90
  highlight Cursor guibg=Green guifg=NONE
  highlight NonText guibg=grey80
  highlight Constant gui=NONE guibg=grey95
  highlight Special gui=NONE guibg=grey95

endif

See also sample vimrc used for console mode vim command from /usr/doc/vim-common-5.3/vimrc_example.

2.2 Xdefaults parameters

You can set some of the Vim properties in Xdefaults file.

WARNING!! WARNING: Do NOT put Vim*geometry it will break the gvim menu, use Vim.geometry instead

Edit the $HOME/.Xdefaults and put the following lines:


! GVim great Colors.
Vim*useSchemes:         all
Vim*sgiMode:            true
Vim*useEnhancedFSB:     true
Vim.foreground:         Black
!Vim.background:        lightyellow2
Vim*background:         white
! Do NOT use Vim*geometry , this will break the menus instead 
! use Vim.geometry. Asterik between Vim and geometry is not allowed.
! Vim.geometry: widthxheight
Vim.geometry:           88x40
!Vim*font:              -misc-fixed-medium-r-normal--20-200-75-75-c-100-iso8859-15-*5
Vim*menuBackground: yellow
Vim*menuForeground: black

In order for this change to take effect, type -
        xrdb -merge $HOME/.Xdefaults
        man xrdb

You can also edit the ~/.gvimrc file to change the background colors


        gvim $HOME/.gvimrc
The best background color is lightyellow or white, with black foreground.
        highlight Normal guibg=lightyellow


Next Previous Contents