In the world of VIM, EMAC or Sublime I belong to VIM side. Its the classic editor which is very fluent if you believe in using all fingers. It has really long learning curve, more you use it more you like.
Sublime is gaining some popularity now a days, but with out vintage( VIM) mode its just one more editor.
Best thing about VIM is every command is under you finger tip and no mouse is needed. If you know basic commands you can combine them and create complex useful commands. Its already celebrated 2 decade of dominance as being programmers editor, and big community to support it.
I prefer VIM compared to may other IDEs like Eclipse or visual studio. Reason behind this is VIM is more fast while traversing through code (We read more code than we write). There are lot of plugins, using which you can customize vim to get IDE kind of benefit. I have listed few of them. If you want to explore more you can find more than 4500 plugins.
LINK: VIM top plugins:
There are many articles from hobbyist and professional, but below is my version. Its mainly about command and plugins which I use and explored. VIM is easy in coding, modifying and quick in traversing.
If you are beginner this is not the article for you. If you have already explored VIM and want to explore more. you will find some interesting information here.
All below command and plugins are tested with VIM 7.0 or above.
Lot many time we need this feature, while commenting code , changing variable type, handling coma separates file to extract data in colum way.
char * first_name; to String first_name;
char *_name; to String last_name;
char * address; to String address;
Start recording macro   : q
buffer to store macro   : some_name
commands for macro record : commands_which_we_want_to_store_in_macro
Stop recording macro  : q
use macro    : repeation@some_name
Ex:
Syntax highlighting enables Vim to show parts of the text in another font or color. Those parts can be specific keywords or text matching a pattern.
This command switches on syntax highlighting:---
:source $VIMRUNTIME/syntax/cpp.vim
VIM installation comes with syntax for all languages, If you have some specific requirement you can write your own syntax file. Please refer below link.
http://vim.wikia.com/wiki/Creating_your_own_syntax_files
My personal choice is sublime sublime default themes and iClipse iClipse truly dark and light themes.
To choose color theme from VIM default supplied run below command
If you want to create your own color scheme, good start point is present in README.txt present in $VIMHOME/colors/ path.
Lot of people shared their color scheme for vim, below is one of the good source.
http://www.vimninjas.com/categories/colors
As per I know most of all editors uses ctag for this purpose. Ctag is not part of VIM installation, we have to install and configure for usage.
If you are (L|U)inx user, installation comes with ctags. If you are windows user you can download Exbrent Ctags form this location. http://ctags.sourceforge.net Generate ctags for you file type.
Fist generate Ctag and in VIM you have to do following settings.
There is a autocomplete in VIM for programs. VIM on Ctrl+N guess what might follow the current text and opens popup menu with choices. We have to select the right match and hit enter. Using this feature we need not to remember lot of API stuff. Everything can be filled in my editor.
To enable this feature add below lines to your vimrc file.
filetype plugin on
For the C++ user below tip describes the settings. http://vim.wikia.com/wiki/VimTip1608
Command:
Its not possible for BATMAN to fight alone, ( He need plugins :D batpod, batplane, tumbler : ). Plugins are the best way to fill this need. There is a big open community who creates these gadgets for others.
You can find lot of plugins for vim by its vast community. VIM top plugins:
VIM has its own scripting layer to write plugins. It did’t impress me a lot, may be because its usage is only to VIM. Its not general purpose language. But there is always some one who try different things. For them Stevelosh is the man. Steve has written very good guide for VIM programmers.
http://learnvimscriptthehardway.stevelosh.com/
Download NerdTree from here
In normal mode call
:NERDTree command to open NERDTree File browser
Few commands: Tree navigation mappings
Nerd Tree window at leftside
This plugin supports all the programming languages supported by the exuberant ctags tool, which includes the following languages: Assembly, ASP, Awk, Beta, C, C++, C#, Cobol, Eiffel, Erlang, Fortran, HTML, Java, Javascript, Lisp, Lua, Make, Pascal, Perl, PHP, Python, Rexx, Ruby, Scheme, Shell, Slang, SML, Sql, TCL, Verilog, Vim and Yacc.
Web Page:
Link:http://vim-taglist.sourceforge.net/index.html
Download Taglist from here
Taglist window at right side
Best thing about VIM is every command is under you finger tip and no mouse is needed. If you know basic commands you can combine them and create complex useful commands. Its already celebrated 2 decade of dominance as being programmers editor, and big community to support it.
I prefer VIM compared to may other IDEs like Eclipse or visual studio. Reason behind this is VIM is more fast while traversing through code (We read more code than we write). There are lot of plugins, using which you can customize vim to get IDE kind of benefit. I have listed few of them. If you want to explore more you can find more than 4500 plugins.
LINK: VIM top plugins:
There are many articles from hobbyist and professional, but below is my version. Its mainly about command and plugins which I use and explored. VIM is easy in coding, modifying and quick in traversing.
If you are beginner this is not the article for you. If you have already explored VIM and want to explore more. you will find some interesting information here.
All below command and plugins are tested with VIM 7.0 or above.
Some of the usefull commands
Block selection
This is cool feature when we want to edit file in coloum way.Lot many time we need this feature, while commenting code , changing variable type, handling coma separates file to extract data in colum way.
char * first_name; to String first_name;
char *_name; to String last_name;
char * address; to String address;
v+Ctrl+q v to start visula mode Ctrl+q to move to block selection Then h,j,k,l to select the direction
Creating macros
We always do repeated set of operation, which take lot of keystrokes or mouse handling. Using VIM’s record and play feature we can store required commands in buffer and play when ever required. You can imagine it as writing function and calling it again and again.Start recording macro   : q
buffer to store macro   : some_name
commands for macro record : commands_which_we_want_to_store_in_macro
Stop recording macro  : q
use macro    : repeation@some_name
Ex:
Esc +q+a : Start recording and store in buffer "a" yyp : Command for which we want to create macro q : stop macro recording 2@a : command stored in buffer "a" repeat 2 time
VIM commands and Settings:
Syntax highlighting
Modern editors do lot of cool stuff make developers life more easy. Syntax highlighting is one of good feature which helps in doing visual patterns matching in mind, while reading and editing code.Syntax highlighting enables Vim to show parts of the text in another font or color. Those parts can be specific keywords or text matching a pattern.
This command switches on syntax highlighting:---
:syntax enableWhat this command actually does is to execute command
:source $VIMRUNTIME/syntax/syntax.vimEx: For CPP file extendion its execute
:source $VIMRUNTIME/syntax/cpp.vim
VIM installation comes with syntax for all languages, If you have some specific requirement you can write your own syntax file. Please refer below link.
http://vim.wikia.com/wiki/Creating_your_own_syntax_files
Window Split
Splitting existing window and analyzing the code is very useful feature. We can split same file or open new file in split window analysis. Below are the command to split window horizontally or vertically splitting current viewing file:vsplit or :vs :split or :spopen new file in split
:vsplitToggling between split windowsor :vs FILE_NAME :split or :sp FILE_NAME
Ctrl+ww : one window to another in left to right order window_Num+Ctrl+ww : Jump to window number in left to right order
Window Tabbing
Tabbing is another best way to organize files which we are working on. Its like another window which we can split, search and we can do lot of stuff:tabnew Command to open new tab :tabnew FILE_NAME Command to open file in new tab gt Command to traverse tab in left to right order gT Command to traverse tab in right to left order Tab_Nu+gt Command to jump to the tab
Color Scheme
I tried many color scheme’s and finally sticking myself to default one for past many days. But still finding best one to have good visual effect. I like light background and dark font on top of it. There are lot of debate and discussion what color is good for eyes and its still going on.My personal choice is sublime sublime default themes and iClipse iClipse truly dark and light themes.
To choose color theme from VIM default supplied run below command
:colorscheme SPACE TABIt will show you all available colorschemes for vim.
If you want to create your own color scheme, good start point is present in README.txt present in $VIMHOME/colors/ path.
Lot of people shared their color scheme for vim, below is one of the good source.
http://www.vimninjas.com/categories/colors
Ctags and VIM
When we are reading code file its handy feature to see the definition of the tag. Jump to definition to declaration, function calling to function declaration, choose the Appropriate definition in case of polymorphism and lot more.As per I know most of all editors uses ctag for this purpose. Ctag is not part of VIM installation, we have to install and configure for usage.
If you are (L|U)inx user, installation comes with ctags. If you are windows user you can download Exbrent Ctags form this location. http://ctags.sourceforge.net Generate ctags for you file type.
Fist generate Ctag and in VIM you have to do following settings.
:set tags = path_of_tagsCommands
C-] - go to definition C-T - Jump back from the definition. C-W C-] - Open the definition in a horizontal splitAdd these lines in vimrc
map:tab split :exec("tag ".expand(" ")) map :vsp :exec("tag ".expand(" ")) C-\ - Open the definition in a new tab A-] - Open the definition in a vertical split
Omni Completion
“ Lazy guys invent shortcuts “There is a autocomplete in VIM for programs. VIM on Ctrl+N guess what might follow the current text and opens popup menu with choices. We have to select the right match and hit enter. Using this feature we need not to remember lot of API stuff. Everything can be filled in my editor.
To enable this feature add below lines to your vimrc file.
filetype plugin on
:set omnifunc=syntaxcomplete#CompleteFor C,C++ user has to generates the ctags to use this feature. You can find Exberant Ctags here. http://ctags.sourceforge.net/
For the C++ user below tip describes the settings. http://vim.wikia.com/wiki/VimTip1608
Command:
Ctrl-N opens the pop-up menu Ctrl-P to navigate selecting the right match
Omni Completion showing possibility on Ctrl+N |
Plugins:
Its not possible for BATMAN to fight alone, ( He need plugins :D batpod, batplane, tumbler : ). Plugins are the best way to fill this need. There is a big open community who creates these gadgets for others.
You can find lot of plugins for vim by its vast community. VIM top plugins:
VIM has its own scripting layer to write plugins. It did’t impress me a lot, may be because its usage is only to VIM. Its not general purpose language. But there is always some one who try different things. For them Stevelosh is the man. Steve has written very good guide for VIM programmers.
http://learnvimscriptthehardway.stevelosh.com/
NerdTree
In my personal opinion this is the best plug-in I used in VIM. Its makes life more easy when we are handling with big project. This is the improved version of traditional file explorer in VIM(e) and currently the most popular one. It gives the IDE kind of project browser with in your finger tips. I feel it can have more fetures like directly creating file in some tree node, delete file or directory, copy paste, and much more. If some one has time please do it for me :DDownload NerdTree from here
In normal mode call
:NERDTree command to open NERDTree File browser
Few commands: Tree navigation mappings
P: go to root p: go to parent K: go to first child J: go to last child Ctrl-k: go to next siblingDirectory node mappings
o: open & close node O: recursively open node x: close parent of node X: close all child nodes of Ctrl-k: go to prev siblingFile node mappings
o : open in prev window go: preview t : open in new tab T : open in new tab silently i : open split gi: preview split s : open vsplit gs: preview vsplit
Nerd Tree window at leftside |
Nerd Tree window at leftside
Taglist
Taglist plugin enhances the feature provided by Ctag . It opens up browser window which displays Class , functions and variables. We can navigate to function prototype/ signature of function and variable easily. It make life more easy. To use this plugin we need to have ctags generated for files.This plugin supports all the programming languages supported by the exuberant ctags tool, which includes the following languages: Assembly, ASP, Awk, Beta, C, C++, C#, Cobol, Eiffel, Erlang, Fortran, HTML, Java, Javascript, Lisp, Lua, Make, Pascal, Perl, PHP, Python, Rexx, Ruby, Scheme, Shell, Slang, SML, Sql, TCL, Verilog, Vim and Yacc.
Web Page:
Link:http://vim-taglist.sourceforge.net/index.html
Download Taglist from here
Taglist window at right side
No comments:
Post a Comment