Make VIM Nice Looking

February 10th, 2009 Category: Linux

Linux users usually know the text editor called “vi”. For beginners it’s tough to use and the look and feel is not very nice. “vim” which means vi-improved brings many improvements. To make vim more nice looking I’ve put my settings for your .vimrc together. I personally like the following settings:

  • Syntax highlighting
  • Different color scheme
  • Disable indenting when copy and pasting a text from clip board
  • Replace tabs with blanks
  • Use 2 spaces as tabs instead of 4 spaces
  • Improve the search
  • Display cursor position

Open the .vimrc in your home directory and add the following settings:

" enable syntax highlightning
syntax enable

" set a different color scheme
colorscheme desert

" avoid identing when pasting a text
set paste

" enable auto indent
set autoindent

" expand tabs to spaces
set expandtab

" set the tab stop to 2 spaces and soft tab stop to 2 spaces
set tabstop=2 sts=2
set shiftwidth=2

" immediately search and display the typed search pattern
set incsearch

" highlighting of search matches
set hlsearch

" show cursor position
set ruler

Much better now! Try the search (e.g. ESC /high) and you will recognize that the search pattern will be immediately highlighted when you enter it.

Note: If you want to replace all tabs within an existing file you can now use the vi command “:retab” and all tabs will be removed according the settings done in your .vimrc.

And finally the result:

planlosorg-putty-10022009-192707.jpg

Search and Replace over Multiple Files

December 30th, 2008 Category: Linux

Sometimes you need to search and replace strings over multiple files. This can easily be done using perl. I found this tip from www.liamdelahunty.com/tips

perl -pi -w -e 's/search/replace/g;' *.php

-e means execute the following line of code.
-i means edit in-place
-w write warnings
-p loop