14.06.2014 Views

vim 101 hacks

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Buyer: xiujuan lu (luxiujuan@gmail.com)<br />

Transaction ID: 85W16630AD8515549<br />

Vim <strong>101</strong> Hacks<br />

www.thegeekstuff.com<br />

jump line col file/text<br />

3 484 19 /home/ramesh/scsi-list.txt<br />

2 5 0 /etc/passwd<br />

1 6 19 /etc.yp.conf<br />

> 0 16 51 John Smith<br />

1 10 7 /etc/sudoers<br />

2 4 3 /etc/group<br />

3 204 3 /home/ramesh/my-projects.txt<br />

• In this example :jump was executed when user was editing names.txt<br />

file<br />

• The current location will be marked with location#0 and > in front of<br />

it. There will be numbers above and below location#0.<br />

• In this example, Current location#0 is “> 0 16 51 John Smith” in the<br />

current file names.txt<br />

• To jump to /etc/password, which is location#2 above current<br />

location, press 2CTRL-O<br />

• To jump to /etc/group, which is location#2 below current location,<br />

press 2CTRL-I<br />

Hack 13. Navigate Within a Very Long Line<br />

When you have a very long line without any newline, Vim treats it as single<br />

line. So, when you execute j on that line, it will jump to next line. However<br />

you’ll get a feeling that it has skipped lot of lines. But in reality it is just only<br />

long line.<br />

Visual Line: Let us assume that a very long line is wrapped down into 5 visual<br />

lines. Let us call each and every individual line as visual lines for the<br />

discussion purpose.<br />

The following shortcuts can help in navigating a very long line effectively.<br />

33

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!