Choose Your VIM Color Scheme With Color Sampler Pack

March 31, 2010 at 11:00 pm | VIM | 2 comments

vimYou can easily change your vim color scheme by :colorscheme, but it can be hard to compare several schemes to decide what’s best for you. But the Vim Color Sampler Pack can help you to choose which color scheme is best for you. This package was put together simply to save others time in downloading the color schemes.

This package is simply to help people who want to try out a lot of color schemes. It is the top 100 rated color schemes on vim.sf.net as of Jan 20th, 2010 that are are not “evil” (binding keys, changing fonts, etc) — zipped up in a single package. Every single theme was updated to its newest revision, and converted to unix formatted line endings.

Check out these screenshots before installing the color sampler pack.

Installing Vim Color Sampler Pack

Download the Color Sampler Pack From here. Simply unzip, and place the files in ~/.vim/plugin and ~/.vim/colors — it will unzip with correct dir structure, so you can just unzip to ~/.vim

The pack comes with an organized GUI menu, but no tool for console users. Console users can download the ScrollColor.vim plugin to walk through installed color schemes. Drop ScrollColors.vim into your plugin directory. Type :SCROLL and use arrow keys to walk through color schemes.

You can map two keys of your choice to NextColor and PrevColor actions. Choose pair of shortcut keys (for example and , or \n and \p) and map them as follows:

map <silent><F3> :NEXTCOLOR<cr>
map <silent><F2> :PREVCOLOR<cr>

Put the above maps in your ~/.vimrc

Happy coloring :-)

Vim Plugin: NERD Commenter

January 21, 2010 at 7:58 am | HOW-TOS, VIM | 3 comments

vimHi all, this is the second post about ‘Vim Plugins’. This time I am going to introduce you a new plugin called ‘NERD_commenter.vim’.

NERD commenter is a plugin for Vim that allows for easy commenting for many filetypes. The NERD commenter provides many different commenting operations and styles which are invoked via key mappings and a menu. NERD_commenter can handle single line, multi line, partial line commenting. This is a must have plugin if you’re programming in VIM.

How to use NERD_commenter.vim

This is the default block of code we will be working with:

$queue  = '/queue/foo';
$msg    = 'bar';
 
/* connection */
try {
     $stomp = new Stomp('tcp://localhost:61613');
} catch(StompException $e) {
     die('Connection failed: ' . $e->getMessage());
}
 
/* send a message to the queue 'foo' */
$stomp->send($queue, $msg);

,cc |NERDComComment|

Comments out the current line or text selected in visual mode.

//$queue  = '/queue/foo';
//$msg    = 'bar';
 
// connection
try {
    $stomp = new Stomp('tcp://localhost:61613');
} catch(StompException $e) {
    die('Connection failed: ' . $e->getMessage());
}
 
/* send a message to the queue 'foo' */
$stomp->send($queue, $msg);

,cn |NERDComNestedComment|

Same as |NERDComComment| but forces nesting.

//$queue  = '/queue/foo';
//$msg    = 'bar';
 
//// connection
try {
    $stomp = new Stomp('tcp://localhost:61613');
} catch(StompException $e) {
    die('Connection failed: ' . $e->getMessage());
}
 
/* send a message to the queue 'foo' */
$stomp->send($queue, $msg);

,c<space>|NERDComToggleComment|

Toggles the comment state of the selected line(s). If the topmost selected
line is commented, all selected lines are uncommented and vice versa.

create connection
try {
    $stomp = new Stomp('tcp://localhost:61613');
} catch(StompException $e) {
    die('Connection failed: ' . $e->getMessage());
}

,cm |NERDComMinimalComment|

Comments the given lines using only one set of multipart delimiters if
possible.

// create connection
/*try {
    $stomp = new Stomp('tcp://localhost:61613');
} catch(StompException $e) {
    die('Connection failed: ' . $e->getMessage());
}*/

,ci |NERDComInvertComment|

Toggles the comment state of the selected line(s) individually. Each selected
line that is commented is uncommented and vice versa.

create connection
//try {
    //$stomp = new Stomp('tcp://localhost:61613');
//} catch(StompException $e) {
    //die('Connection failed: ' . $e->getMessage());
//}

,cs |NERDComSexyComment|

Comments out the selected lines “sexily”

// create connection
/*
*try {
*    $stomp = new Stomp('tcp://localhost:61613');
*} catch(StompException $e) {
*    die('Connection failed: ' . $e->getMessage());
*}
*/

,cy |NERDComYankComment|

Same as |NERDComComment| except that the commented line(s) are yanked
before commenting.

// create connection
//try {
    //$stomp = new Stomp('tcp://localhost:61613');
//} catch(StompException $e) {
    //die('Connection failed: ' . $e->getMessage());
//}

pasted the yanked lines you will get

try {
    $stomp = new Stomp('tcp://localhost:61613');
} catch(StompException $e) {
    die('Connection failed: ' . $e->getMessage());
}

,c$ |NERDComEOLComment|

Comments the current line from the cursor to the end of line.

try {
    $stomp = /*new Stomp('tcp://localhost:61613');*/
} catch(StompException $e) {

,cA |NERDComAppendComment|

Adds comment delimiters to the end of line and goes into insert mode between
them.

try {
    $stomp = new Stomp('tcp://localhost:61613'); // cursor here
} catch(StompException $e) {

,cI |NERDComPrependComment|

Adds comment delimiters to the start of line and goes into insert mode between
them.

try {
    // cursor here   $stomp = new Stomp('tcp://localhost:61613');
} catch(StompException $e) {

,ca |NERDComAltDelim|

Switches to the alternative set of delimiters.

switches between // and /* */ for example. Here’s ,cc after applying this

/*$queue  = '/queue/foo';*/
/*$msg    = 'bar';*/
 
// create connection
try {
    $stomp = new Stomp('tcp://localhost:61613');
} catch(StompException $e) {
die('Connection failed: ' . $e->getMessage());
}

,cl  |NERDComAlignedComment|

Same as |NERDComComment| except that the delimiters are aligned down the side.

// create connection
/*try {*/
/*    $stomp = new Stomp('tcp://localhost:61613');*/
/*} catch(StompException $e) {*/
/*    die('Connection failed: ' . $e->getMessage());*/
/*}*/

,cr |NERDComAlignedComment|

Same as |NERDComComment| except that the delimiters are aligned down the right side.

// create connection
// create connection
/*try {                                             */
    /*$stomp = new Stomp('tcp://localhost:61613');  */
/*} catch(StompException $e) {                      */
    /*die('Connection failed: ' . $e->getMessage());*/
/*}*/

,cb |NERDComAlignedComment|

Same as |NERDComComment| except that the delimiters are aligned down both sides.

// create connection
/*try {                                             */
/*    $stomp = new Stomp('tcp://localhost:61613');  */
/*} catch(StompException $e) {                      */
/*    die('Connection failed: ' . $e->getMessage());*/
/*}

,cu |NERDComUncommentLine|

Uncomments the selected line(s).

send a message to the queue 'foo'
$stomp->send($queue, $msg);

Installing NERD_commenter.vim

To get the latest version:

* 1. Download NERD_commenter.zip.
* 2. Extract NERD_commenter.zip to ~/.vim (on Unix/Linux) or ~\vimfiles (on Windows).
* 3. Run :helptags ~/.vim/doc (on Unix/Linux) or :helptags ~/vimfiles/doc (on Windows) to rebuild the tags file (so that you can read :help NERD_commenter.)
* 4. Restart Vim.

Vim Plugin: Taglist

December 15, 2009 at 6:44 pm | HOW-TOS, VIM | 2 comments

vimHi all. Inspired by catonmat, I am staring a series of article about useful Vim plugins.The first post in this series will be about a plugins called “taglist.vim“.

Here is what the home page of Taglist Plugin says:

The “Tag List” plugin is a source code browser for the Vim editor. It provides an overview of the structure of source code files and allows you to efficiently browse through source code files in different programming languages. It is the top-rated and most-downloaded plugin for the Vim editor.

The taglist plugin groups and displays the functions, classes, structures, enumerations, macro definitions and other parts of a source code file in a Vim window. The taglist plugin will automatically highlight the current tag. You can jump to the definition of a tag by selecting the tag name from the taglist window. For a list of features supported by the taglist plugin, visit the features page.

The taglist plugin requires Vim version 6.0 and above. The taglist plugin will work on all the platforms where the exuberant ctags utility and Vim are supported (this includes MS-Windows).

Install exuberant ctags in Debian based distributions using apt.

$ sudo apt-get install exuberant-ctags

Now download the latest Taglist plugin from here. Unzip the files to the $HOME/.vim or the $HOME/vimfiles or the $VIM/vimfiles directory. After this step, you should have the following two files (the directory structure should be preserved):

plugin/taglist.vim – main taglist plugin file
doc/taglist.txt    - documentation (help) file

Change to the directory containing taglist.txt. Start Vim and run the “:helptags .” command to process the taglist help file. Restart Vim. You can now use the “:TlistToggle” command to open/close the taglist  window. Use ‘Ctrl+w w’ to toggle between Taglist window and source code window. You can use the “:help taglist” command to get more information about using the taglist plugin.

Screenshot:

Taglist ScreenShot

For more information got to Taglist project page.