Monday, June 18, 2012

Effectively using gvim for multiple files

I have been doing a lot of work with multiple files. These files used to be very long and the usual j-k scrolling with vi used to sometimes prove inadequate for scrolling through large pages. This time, I decided to go for geany, which is usually very very comfortable for programming, provides a shell in the IDE and is absolutely fantastic when combined with a proper theme.

But, i missed the functionality of vim. So I decided why not use gvim for editing? Well, i could, but then, multiple files were always a problem, because i didn't know how to manage multiple files other than editing each file everytime using :e.

Now i know better :) I researched a little bit and I got the perfect setup:

:tabe

for opening a new tab.

:tabn
:tabp



for changing between tabs.
Note: the vim-gnome package in Ubuntu 12.04 (>=10.10 i guess) supports Ctrl+PgUp / Ctrl+PgDwn for switching tabs.

You could even map the :tabe, :tabp, :tabn to F8, F9, F10 or something to make a good byobu-clone setup :D

You can also always split screen by doing ^w-s and ^w-v. This will split the screen in two horizontally/vertically. ^w-w will switch between parts, :e in a new pane will open a new file for editing.

You can open simultaneously while splitting using the commands

:vsp newfile
:sp newfile
You can move the division between them around by using ^W-> and ^W-<. These move the division by small measures. To move, for eg, 20 units at once, combine it with the usual prefix notation:

20^W-<
Well, i guess gvim is the best thing that ever happened to editing. Consider using Wombat theme for gvim!

No comments:

Post a Comment