vim tip

Posted by curson on November 21, 2005 @ 13:33:15

I’ve been playing around with vim quite a lot lately, and the more I learn to use it, the more I like his power and flexibility.
Anyway, I’m enjoying the way it manages folders and file-listing and I found on some on-line pages how to create a sort of hyperlinking between files.

Let’s say you’re editing a memo to yourself that looks something like:

…remember to check /home/curson/web_design/test.html for errors

Vim could come in help of your webmastering mind allowing you to directly open the file test.html, of course taking it from the right directory in your $HOME.
All you have to do is to add a little piece of code to your vim configuration file (usually ~/.vimrc):

map gf :new <cfile><cr>

Thus, pressing “gf” in command mode while the cursor is over the “path” of the file you want to edit, will make vim opening that file (creating one if new…) in a splitted horizontal window.
If you add (still to .vimrc, see here for infos):

map <c-J> <c-W>j<c-W>_
map <c-K> <c-W>k<c-W>_

to your .vimrc file too, you will also be able to switch between those splitted windows by pressing ctrl+k/ctrl-j.

Easy and fun!
Isn’t it? ;)

Trackbacks

Use this link to trackback from your own site.

Comments

Leave a response

Comments

Powered by WP Hashcash