Thursday, February 12, 2009

Final (not the last) attempt at VIM

Being an ardent Open source / Linux fan believer, you might be surprised to know that i am still a newbie with vim. Perhaps the only commands i know on vi till now are (i, q, wq and q!).

The editor of my choice happens to be Source Insight with its cool features like context window(a dedicated window which takes you to the definition of the symbol, as soon as you place your cursor onto the symbol on the main window - Since the entire project source code is indexed periodically, this works amazingly fast even for a massive project like the Linux kernel which may span across many 10,000s of files) and call graphs. Though i didn't intend to make this blog an advertisement to Source Insight, i cant help the way it is coming out.

Instead this should be taken as a challenge by the open Source community including me to come up with a stunning GUI development suite which can challenge the mighty SourceInsight. But i seriously doubt whether any work in this direction will materialize in Open Source leave alone start. This is because as far as i know, in Open Source/ Linux community, any developer worth his salt is already addicted to either of the two stalwarts vi or Emacs, mostly the former one(i respect both of them - well aware of their capabilities , but never had the patience or memory to master the long list of commands and neither do i believe that, even if i manage to learn all the commands, it still would improve my development efficiency to any significant level above SI ... who knows after i may find myself disproved). Thanks to my friend Xavier who introduced me to this editor.

Till my first date with SI, i was wasting my time with some cheap and crappy editors like edit plus (where the only way to find the definition of a symbol was to do a find in files - it was okay there as the projects there never exceeded more than 100 files) at SCM (my previous employer).
I am deliberately taking this instant to take a dig at a couple of people at this juncture. These were the reactions of a couple of ppl who were mostly used to VC 6 ide / edit plus when i explained them about SI.
One of the wizards at SCM commented , this editor may have lot of fancy features, but frankly i don't think you need anything more than edit plus to code ... (what to say, i can only sympathize with his narrow vision and obsession to absurdity).

Coming back to our topic vi. One anecdote on vi which still makes me laugh goes like this : There is this guy called Sinu (SKJ) one of my class mates / project group mate from ModelEnggColl .... quite a knowledgeable and technically competent person with a good sense of humor ... Once i was at his place , so in between our conversation after i told him that i mostly work on Linux kernel based embedded devices, he casually asked me whether i used Vi. I replied in negative. Then came his reply that i am luckily spared , and that his hands are itching to thrash any one and every one who used vi and crossed his path.
The story goes like this Mr SKJ and his colleague - a self proclaimed vi expert (newbie) one day before some release finds that certain changes needs to be done to a file while testing on the target. so our expert showed all his VI expertise on the file and later confessed that the only way to get back the original file was to retype it once again in some other normal editor. (Dont ask me whether he didn't have a back of the original point - you are missing the point).

Once again coming back to the point. After umpteen attempts, i have again decided to try my hands at championing vi. Couple of plus points of vi which no one else can claim goes like this :
You will find it on any embedded Linux device , be it your mobile, router or anything .. in fact that will be the only editor that you will ever find on these.

So here I am start again - like the spider who tries to climb all the way up for the umpteenth time by writing a new .vimrc file , which i am copy pasting below :

set nocompatible

set backspace=indent,eol,start

set ignorecase " Case insensitive matching.

set incsearch " Incremental search.

set tabstop=4 " Number of spaces counts for.

set shiftwidth=4 " use 4 spaces when text is indented auto or manual"

set background=dark " use bright colors"

set cindent

set autoindent " use the current line's indent level to set the indent level of new lines"

set smartindent " intelligently guess the indent level of any new line based on the previous line"

set showmatch " setting will cause the cursor to very briefly jump to a brace"

set ruler


"" Function keys.



"" F1: Toggle hlsearch (highlight search matches).

nmap :set hls!

nmap :set ignorecase!

map q :q

Apart from this i have learned a handful of commands ... which i have already forgotten

b,w - move fwd / bckwd one word with cursor at word beginning
e, ge - same as the previous , but the cusor will be at the end of the word .. see the power of vi
n/N - search the word back and forth
Ctrl-O - cursor to the previous pos
gg / GG - go to the beginning or end of file .. or the other way ...i can ven remember big endian / little endian - leave alone this ... any ways life has to move on
2>> / << -- shift two lines either way
Ctrl -R - redo
gd - go to the local definition of the variable
[[ / ]] - next function / previous function
H, M,L - top / middle / bottom of the screen

How to move cursor Up / down n lines - shit i forgot ? any way life has to go on

That's enough for Today (Ctsy A. O sir)


  • At 12:23 AM , Blogger charly said...

    Hi Jithu.......I agree to you to an extend that source insight is aiding the software development to a new dimension by visual interpretation....... There is one significant difference in the context we need to take into account while comparing the use of source insight and vi editors...........
    That is you can have vi in any terminal that is in any Linux machine including the black box hardware (embedded low resource environment)........Vi has all the features of source insight which is implemented in command line.....
    If we want to do some editing in no GUI environment the best editor is VI......

    But time has changed this is an era of multi core machines and extreme graphics........This time have to use advance editors like source insight..........This doesn't mean that Vi is still irrelevant in the current scenario.......... It has its own importance in terminal interfaces.............

    I agree to you in the importance of need for having source insight kind of editors in Linux GUI environments......... But its not fair to compare these two editors since they are having importance in totally different context

  • At 7:23 AM , Anonymous Anonymous said...

    This comment has been removed by a blog administrator.


Post a Comment

Subscribe to Post Comments [Atom]

<< Home