Friday, May 9, 2008

Vim Tip: Mutliple windows and vimdiff

Vim Tip: Mutliple windows and vimdiff

Using multiple windows in VIM is a great way to do side-by-side editing, comparison and cut-and-paste (yank-and-put). Unlike other editors, you can do all this with your hands on home row. Learning to use multiple windows will also help you make better use of the built in :help, and also makes it easy to learn a powerful file comparison tool: vimdiff.

To open a file in a new window, use either ":split filename" or ":vsplit filename". vsplit is nice when you can devote an extra-wide window to VIM. If you leave of the filename argument, the split will be performed on the file you are already editing.

Navigating between windows is simple. Every window command starts with a "ctrl-w". Then you can move between windows with h,j,k,l or the arrow keys as you would normally move between lines. Some other useful window commands are:
ctrl-w c - Close this window
ctrl-w o - close all Other windows (mnemonic - Only)
ctrl-w 5+ - increase this window size by 5 lines
ctrl-w 5- - decrease this window size by 5 lines

With these window commands, we're ready to use "vimdiff". Start vimdiff from the command line:
% vimdiff a.txt b.txt
Vim will open the two files in "vsplit" mode, and will highlight differences between the two. I have attached an example of this. There are just a few more commands that are needed to be proficient with vimdiff:
do - (diff-obtain) obtain differences from other window into this one
dp - (diff-put) push differences in current window to the other window
zo - open a block of folded text

Monday, April 28, 2008

ifconfig

In linux, check network hardware information:
/sbin/ifconfig

ifconfig

In linux, check network hardware information:
/sbin/ifconfig

Friday, March 21, 2008

How to change default gnome-term size?

I found this on internet. Just want to paste here for further reference. Hope this link to original post alway works so that people knows to where the credit should be granted.

gnome-terminal is an xterm emulator, and it follows a termcap file for this. I don't know anything about termcaps, but the file can be found in
/usr/share/vte/termcap/xterm
on Fedora (I think). Anyway, there's a lot of stuff in this file you probably don't want to touch, but you can change the line that describes the terminal geometry:

xterm-xfree86|xterm-new|xterm terminal emulator (XFree86):\
:am:km:mi:ms:xn:\
:co#80:it#8:li#24:\

:co#80 specifies 80 columns, and li#24 specifies 24 lines. Change this to 120 and 30 or whatever you want. Now all terminals should open for this default size.

Monday, March 17, 2008