About

Swaroop C H is 27 years of age. He graduated in B.E. (Computer Science) from PESIT, Bangalore, India. He has previously worked at Yahoo! and Adobe.

More about

Page
Personal tools
COLLECTION
Collection

Vim en:More

From Notes

Jump to: navigation, search

Contents

[edit] Introduction

We've explored so many features of Vim, but we still haven't covered them all, so let's take a quick wild ride through various topics that are useful and fun.

[edit] Modeline

What if you wanted to specify that a certain file should always use pure tabs and no spaces while editing. Can we enforce that within the file itself?

Yes, just put vim: noexpandtab within the first two lines or last two lines of your file.

An example:

# Sample Makefile
.cpp:
    $(CXX) $(CXXFLAGS) $< -o $@
 
# vim: noexpandtab

This line that we are adding is called a "modeline."

[edit] Portable Vim

If you keep switching between different computers, isn't it a pain to maintain your Vim setup exactly the same on each machine? Wouldn't it be useful if you could just carry Vim around in your own USB disk? This is exactly what Portable GVim is.

Just unzip into a directory on the portable disk, then run GVimPortable.exe. You can even store your own vimrc and other related files on the disk and use it anywhere you have a Microsoft Windows computer.

[edit] Upgrade plugins

Any sufficiently advanced Vim user would be using a bunch of plugins and scripts added to their ~/.vim or ~/vimfiles directory. What if we wanted to update them all to the latest versions? You could visit the script page for each of them, download and install them, but there's a better way - just run :GLVS (which stands for 'G'et 'L'atest 'V'im 'S'cripts).

See :help getscript for details.

There are scripts to even twitter from Vim!

[edit] Dr. Chip's plugins

"Dr. Chip" has written some amazing Vim plugins over many years. My favorite ones are the drawit.vim which help you to draw actual text-based drawings such as all those fancy ASCII diagrams that you have seen before.

Another favorite is Align.vim which helps you to align consecutive lines together. For example, say you have the following piece of program code:

a = 1
bbbbb = 2
cccccccccc = 3

Just visually select these three lines and press \t=, and voila, it becomes like this:

a          = 1
bbbbb      = 2
cccccccccc = 3

This is much easier to read than before and makes your code look more professional.

Explore Dr. Chip's page to find out about many more interesting plugins.

[edit] Blog from Vim

Using the Vimpress plugin, you can blog to your Wordpress blog right within Vim.

[edit] Make Firefox work like Vim

Use the Vimperator add-on to make Firefox behave like Vim, complete with modal behavior, keyboard shortcuts to visit links, status line, tab completion and even marks support!

[edit] Bram's talk on the seven habits

Bram Moolenaar, the creator of Vim, had written an article long ago titled "Seven habits of effective text editing" that explained how you should use a good editor (such as Vim).

Bram recently gave a talk titled "Seven habits for effective text editing, 2.0" where he goes on to describe the newer features of Vim as well as how to effectively use Vim. This talk is a good listen for any regular Vim user.

[edit] Contribute to Vim

You can contribute to Vim in various ways such as working on development of Vim itself, writing plugins and color schemes, contributing tips and helping with the documentation.

If you want to help in the development of Vim itself, see :help development.

[edit] Community

Many Vim users hang out at the vim@vim.org mailing list where questions and doubts are asked and answered. The best way to learn more about Vim and to help other beginners learn Vim is to frequently read (and reply) to emails in this mailing list.

You can also ask questions at Stack Overflow by tagging the question as 'vim' and you'll find useful discussions there, such as the one on "What are your favorite vim tricks?"

You can also find articles and discussions at delicious and reddit.

[edit] Summary

We've seen some wide range of Vim-related stuff and how it can be beneficial to us. Feel free to explore these and many more Vim scripts to help you ease your editing and make it even more convenient.


Please add your comments by clicking on the 'Discussion' link in the left sidebar.