More useful vim tips

Go to place in file

:G    End of file

1G  Start of file

<n>G    (or) :n Go the nth line of file

Find and Replace

This is of the form %s/<text to find>/<text to replace>/<options>

%s/foo/bar/g : Replaces all occurrences of  foo with bar

%s/\<foo\>/bar/g : Replaces all EXACT matches of the word foo  with bar

%s/foo/bar/gc : The c option, asks for a confirmation before replacing


Editing multiple files in Vim

Splits and multi-file editing

Perhaps one of the most limiting features of the original vi is its inability to edit more than one file at once. vim removes this limitation; it can edit many files at the same time. In typical vim fashion, it provides many ways to do this. I’ll focus on the easiest way to visualize, which uses “splits,” which are like independent windows that can each contain a text file.

Opening a file in a split

Assuming you are already editing a file in a vim session and want to split the screen and edit a second file, you can use either of these commands:

:sp filename
Splits the screen horizontally and opens filename in the new area.
:vsp filename
Splits the screen vertically and opens filename in the new area.

For most purposes, horizontal splits are easier to manage. Any split can be further split — you can edit as many files in a single instance of vim as you like.

Managing splits

Once you are editing multiple files, you will probably need to move back and forth through your files and manage the size of the splits so that you can see the relevant portions of the files you’re interested in.

The prefix for all the below commands is <C-W> — that is, hold down Ctrl and type w. Press <C-W> before typing any of the below commands.

Moves to the next split.
Moves to the split above the current split.
Moves to the split above the current split.
Moves to the split below the current split.
Moves to the split below the current split.
Increases the size of the current split by one line. (Try combining this with counts — e.g. 5<C-W>+ will make the split five lines bigger.)
(Minus sign) Decreases the size of the current split by one line.
(Underscore) Maximize the current split (that is, make it take up as much room as possible.)

Saving and quitting

Each split acts something like an individual instance of vim — so :w and :q work on the current split. If you want those commands to apply to all the splits instead of just the current one, add a to them — for instance, :wa saves all the open files, :qa quits all open files (and exits vim), and :wqa saves and then closes all open files.

Recommended mappings

I recommend adding the below files to your .vimrc file to make working with splits easier:

map <C-J> <C-W>j<C-W>_ map <C-K> <C-W>k<C-W>_ set wmh = 0

The first two lines allow you to switch between splits much more smoothly — just press <C-J> to open and maximize the split below the current one and <C-K> to open and maximize the split above the current one. I chose these mappings because they correspond to vi’s default up and down keys, you might want to use different key combinations if you’ve ever used an editor that had hotkeys for moving from one open file to another.

The last line allows splits to reduce their size to a single line (which includes the filename and position); this saves a lot of space when you have many splits open. By default, vim forces splits to include an additional line that contains the line of text the cursor was on in that file.

InCTF 2011: National Capture the flag Ethical Hacking Contest

Amrita University & TIFAC CORE

proudly present

InCTF ’11: National Level “Capture the Flag” Ethical Hacking contest

InCTF’11 is from February to March 2011 and is focused exclusively on the student community. You can participate from your own university and no travel is required. No prior exposure or experience in cyber security needed to participate.

What you need to do?
1. Form a team (max five members from your college)
2. Approach a faculty/mentor and request him/her to mentor your team

3. Register online at

Whats more? There is no registration fee this year!

Great Rewards

25K The winning team receives a cash prize of Rs. 25000/-
20K The first runner-up team receives a cash prize of Rs. 20000/-
15K The second runners-up team receives a cash prize of Rs. 15000/-

Special Prizes*

  • Teams are awarded cash prizes of up to 10K based on their performance
  • Deserving teams are well awarded. Exciting prizes to be won.

So, what are you waiting for? – It’s simple Register, Learn, Hack!

Keep up with us
Website | Email | Facebook | Twitter

*Cash prizes are subject to their performance and participation in the CTF round. Only teams who connect to the VPN server and successfully gain points in the CTF round are eligible for prizes

Change your MAC address in Linux (Ubuntu)

Relevant to your use, you can either choose to make it a permanent addition or a temporary addition. Lets take an example of changing the MAC address of interface eth0 to 11:22:33:44:44:66

Temporary Addition

$ sudo ifconfig eth0 down

$ sudo ifconfig eth0 hw ether 11:22:33:44:55:66

$ sudo ifconfig eth0 up

Permanent Addition

1. Open /etc/network/interfaces ,

$ sudo vim /etc/network/interfaces

2. Add an extra line to specify the new MAC

auto eth0

iface eth0 inet dhcp

hwaddress ether 01:02:03:04:05:06

(A simple configuration, additional configurations will require additions/alterations. E.g. static IP/different interface)

3. Restart the network service

$ /etc/init.d/networking restart

Though the the latest version of Ubuntu may require you to use the service command to start/stop/restart services

Building Amarok from scratch on Ubuntu 9.10

I was getting prepared for my GSoC project, and had to build Amarok from source. I had to refer a few tutorials(some outdated, some incomplete) and after some IRC discussions managed to build it successfully(Ubuntu 9.10).  I am enlisting the details below, more for the sake of memory.( I have short term memory loss 😛 ). Before starting off make sure the kde development packages(kde-devel) and compiler ( build-essentials) are installed.

Setting up the Environment

It is better to build it in the $HOME folder to prevent unnecessary overwriting of system files. By default, the build is system-wide and requires root privileges.

1.Create folder kde in $HOME
$ mkdir $HOME/kde
Make Seperate source and build folders
$ mkdir $HOME/kde/src
$ mkdir $HOME/kde/build/amarok

2.Append the following to $HOME/.bashrc:
export PATH=$HOME/kde/bin:$PATH

Reload your edited .bashrc:
source $HOME/.bashrc
NOTE: if you are not using the bash shell, edit your proper shell config file (~/.zshrc or ~/.tcshrc or whatever it may be)

3. Make KDE aware of Amarok’s plugin location:
$ echo ‘export KDEDIR=$HOME/kde’ >> $HOME/.kde/env/
$ echo ‘export KDEDIRS=$KDEDIR’ >> $HOME/.kde/env/

Getting the source

1. Go the the source folder
$ cd $HOME/src
2. Clone the git repository on gitorious
$ git clone git://
If your proxy does not support it,
$ git clone



Resolving Dependencies

$ sudo apt-get build-dep amarok
Install the OpenSSL and qtscript libraries and
$ sudo apt-get install libssl-dev qtscript-tools
Build Google Mock
$ ./configure && make && sudo make install


$ cd $HOME/kde/build/amarok
$ cmake -DCMAKE_INSTALL_PREFIX=$HOME/kde  -DCMAKE_BUILD_TYPE=debugfull -DKDE4_BUILD_TESTS=ON $HOME/kde/src/amarok && make && make install

Updating KDE Config

$ kbuildsycoca4 –noincremental

Run Amarok

$ amarok



Beginning with LaTeX on GNU/Linux

Recently, due to some project work i had the need to learn to use LaTeX to create my documentation. But as i was googling around for it i found a plethora of stuff that utterly confused me. Hence, This document gives an overview of LaTeX and how get started with it on GNU/Linux

Introduction to TeX

TeX is a typesetting program created by Donald Knuth of Stanford University with the aim of composing quality content that contains a lot of mathematical and technical expressions. It is also suitable for producing all sorts of other documents, from simple letters to complete books. TeX provides Device Independent output(dvi) which contains details only regarding references to fonts and positions of characters on the screen. This output can be used by various printers to convert it to their desired format like pdf, postscript etc.

What is Typesetting?

A type is a way characters look usually called a font. Type-setting is the process of putting characters (of a certain type) in their correct place (layout) on paper or screen.

What is LaTeX then?

TeX by itself is a macro compiler i.e it maps a higher level instruction into a sequence of device independent instructions. LaTeX provides a set of useful macros, which uses TeX underneath to produce the device independent output. LaTeX was introduced by Leslie Lamport, a researcher i admire for his innovation. Similar distributions of TeX include ConTeXt, AMS-TeX etc.

Getting Started

There are 3 main things you ought to be aware of to get started with LaTeX

Writing TeX files

The TeX files is the ASCII specification i.e which is written in characters available on the keyboard. You can use any text editor of your choice to write it – vim, emacs etc..

Here are some good areas to get started on learning to write tex files.

An Example LaTeX specification

The (Not So) Short Introduction to LaTeX2e
This document by Tobias Oetiker is good for beginners

The LaTeX Cheat Sheet

Setting up LaTeX

Usually most distros of GNU/Linux come with latex pre-installed. If not please check your software sources for a TeX package or install TeX Live directly.
For Ubuntu you can install it by
$ sudo apt-get install texlive

Once done you have a plethora of options available to you

Converting TeX files

Convert the tex to dvi
$ latex program_to_convert.tex
Convert dvi to postscript
$ dvips -Pcmz your_dvi_file.dvi -o
Convert tex to pdf directly
$ pdflatex program_to_convert.tex
Convert postscript to pdf
$ pdf2ps your_file.pdf
Convert pdf to postscript
$ pdf2ps your_file.pdf
Note: This article is only to get you *familiar* with LaTeX only. For advanced use, you may refer the following


Vim : Things you thought you could never do Part I

When i first started out programming using Vim, my first reaction was “What a boring editor, ancient piece of crap” . So i started using gedit regularly. It was only recently that i was enlightened about the Awesome features of Vim!! So i thought i need to enlighten some of the vim critics out there.

Vim Modes

There are 2 main modes in Vim
a. Normal mode: The one when you open it initially in Vim
b. Editing Mode: When you press one of the following keys when in normal mode
i   –  insert at current position
a  –  insert AFTER current position
o  – open (create) a new line below current line
I  – insert AT START of current line
A – insert AFTER end of current line
O – open (create) a new line ABOVE current line
Here, as you can see they key ‘o‘ would turn out to be pretty useful.
Note: The following tips are useful in normal mode. The quotes are given only for understanding that they are strings. You dont need them while entering them in normal mode.



To make navigation easier i.e to make use of the main keys on the keypad h , j , k , l are used. To remember better
a. h is on far left -> so stands for left
b. l is on far right -> so stands for right
c. Since j looks like it is somewhat pointing down -> stands for down
d. Obv -> k stands for up


Use of combos to achieve magic !

d- delete
c- change
w- word
b- word before
a. So type “wwwwww” (and) “bbbbbbbbbb” and see what happens. Cool right!
b. Similarly place the cursor before a word and type “dw” -> a word is deleted!
c. So now, you can make combo’s of the above letters to make super things happen
i. d6w – delete 6 words after cursor posn
ii. d6j – delete 6 lines down
iii. d4b – delete 4 words before cursor posn
iv.  cw – change current word
etc. etc…. All this just in a few keystrokes !!


Auto-complete Feature

Lets say i am typing a document/program and i repeat the use of many words/keywords. The auto-complete feature shows me a list of complete options allowing me to fill in the word of my choice
Ctrl – P – Search previous
Ctrl – N – Search Next
Once the a drop-down of possible options(for multiple fills) is shown, go down to the appropriate one and press <enter >
Try it out!


Visual Mode

Now, we are always faced with the stigma as to
“How do i select multiple lines without a mouse? How do i copy/paste/delete multiple lines”.
Vim has the solution in the form of the “Visual Mode”
1. Type “v” – allows you to select multiple characters
2. Type “V”(Shift-v) : allows you to select multiple lines
Once youve selected the lines, you can  use
a. “d” – to delete
b. “y” – copy (short for yank)
c. “p” – paste (once you have copied)
d. Use “<“ and “>” to indent left and right
e.  “o” moves to start and of select
Other useful shortcuts
“dd”-delete current line
“d2d” – delete 2 lines
“yy” – yank current line
LOOK OUT FOR PART 2 !! Coming up soon!

Search your history of commands

I just recently discovered that one can search a history of commands(in BASH) in  a few keystrokes , rather than the ancient way of pressing the up arrow till you see it or eventually doze off 🙂

Press Ctrl + R

Start typing the command u want to search for( it starts autocompleting)

Once you reach the right command -> Type Enter

Happy Searching 🙂

SUNWcsl .101 build version conflict

Recently, i went about the task of porting Audacity to OpenSolaris.When i build Audacity, one of the dependencies unsatisfied was libsndfile.When i went to the package manager, to my pleasure i found the package SUNWlibsndfile available.

The Problem lies wherein when i try to install SUNWlibsndfile it reports the following error:

pkg: the following package(s) violated constraints:
Package pkg:/SUNWcsl@0.5.11,5.11-0.111 conflicts with constraint in installed pkg:/entire:
Pkg SUNWcsl: Optional min_version: 0.5.11,5.11-0.101 max version: 0.5.11,5.11-0.101 defined by: pkg:/entire

The library is available only for build 111 and not for build 101 which OpenSolaris 2008.11. When i inquired about this at, they told me it was for standardization that this was done.Does this mean that packages cannot be built for Old versions of opensolaris? According to me this is plain nonsense.

Hack to share files in Vbox : OpenSolaris

Usually files can be easily shared between the host system and the guest system in VirtualBox by using the easy and simple to configure ” Guest Additions” feature. The problem lies wherein the “Guest Additions” feature is not compatible in Solaris making it a headache to share files.I currently host Ubuntu with OpenSolaris as the guest OS.

So a simple but roundabout hack is to

1. Create an iso image in the host OS with the files you want to share


2. Mount the iso image in VBOX through the Devices -> Mount CD/DVD ROM-> Stuff2Share.iso


3.  Run/Open the Guest OS [OpenSolaris] and go to Places -> Stuff2Share.iso {auto mounted }


4. Happy Sharing !!