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 />

Create a Map in Vim<br />

In the following example, anytime you type :write , it will compile the<br />

current open *.c program file and execute the ./a.out, if the compilation is<br />

successful.<br />

:map :write :!cc % && ./a.out<br />

Fig: Create a map<br />

• :map – Vim command to create the map<br />

• :write – Name of the map (map-name)<br />

• :!cc % & ./a.out – The command that should be executed when the<br />

map-name is called.<br />

Execute the map<br />

To execute the map, call the name of the map. In the example shown above,<br />

:write is the name of the map.<br />

119

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

Saved successfully!

Ooh no, something went wrong!