14.06.2014 Views

vim 101 hacks

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

Transaction ID: 85W16630AD8515549<br />

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

www.thegeekstuff.com<br />

SwapExists<br />

Detected an existing swap file<br />

Many developers want some default header for their programs. For example,<br />

when opening a “.c” file, you typically need a file header with a number of<br />

items. The following template is loaded automatically whenever I open a new<br />

“.c” file. You can achieve this in three steps as mentioned below.<br />

/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.<br />

* File Name : 1.c<br />

* Purpose :<br />

* Creation Date : 22-12-2008<br />

* Last Modified : Mon 22 Dec 2008 10:36:49 PM PST<br />

* Created By :<br />

_._._._._._._._._._._._._._._._._._._._._.*/<br />

Step 1: Create a template file<br />

Save the above template in a text file with “:insert” in the first line, followed<br />

by the template and a “.”(dot) in the last line as shown below.<br />

$ cat c_header.txt<br />

:insert<br />

/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.<br />

* File Name :<br />

* Purpose :<br />

* Creation Date :<br />

77

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

Saved successfully!

Ooh no, something went wrong!