Wikia

Vim Tips Wiki

Changes: Shebang line automatically generated

Edit

Back to page

(Move categories to tip template)
(Remove html character entities)
 
Line 16: Line 16:
 
<pre>
 
<pre>
 
augroup Shebang
 
augroup Shebang
autocmd BufNewFile *.py 0put =\"#!/usr/bin/env python\&lt;nl&gt;# -*- coding: iso-8859-15 -*-\&lt;nl&gt;\"|$
+
autocmd BufNewFile *.py 0put =\"#!/usr/bin/env python\<nl># -*- coding: iso-8859-15 -*-\<nl>\"|$
autocmd BufNewFile *.rb 0put =\"#!/usr/bin/env ruby\&lt;nl&gt;# -*- coding: None -*-\&lt;nl&gt;\"|$
+
autocmd BufNewFile *.rb 0put =\"#!/usr/bin/env ruby\<nl># -*- coding: None -*-\<nl>\"|$
autocmd BufNewFile *.tex 0put =\"%&amp;plain\&lt;nl&gt;\"|$
+
autocmd BufNewFile *.tex 0put =\"%&plain\<nl>\"|$
autocmd BufNewFile *.\(cc\|hh\) 0put =\"//\&lt;nl&gt;// \".expand(\"&lt;afile&gt;:t\").\" -- \&lt;nl&gt;//\&lt;nl&gt;\"|2|start!
+
autocmd BufNewFile *.\(cc\|hh\) 0put =\"//\<nl>// \".expand(\"<afile>:t\").\" -- \<nl>//\<nl>\"|2|start!
 
augroup END
 
augroup END
 
</pre>
 
</pre>

Latest revision as of 09:35, September 29, 2008

Tip 880 Printable Monobook Previous Next

created February 20, 2005 · complexity basic · author Bertram Scharpf · version 6.0


In my Python or Ruby scripts, the first line is always a shebang line. I create it automatically using:

augroup Shebang
  autocmd BufNewFile *.py 0put =\"#!/usr/bin/env python\<nl># -*- coding: iso-8859-15 -*-\<nl>\"|$
  autocmd BufNewFile *.rb 0put =\"#!/usr/bin/env ruby\<nl># -*- coding: None -*-\<nl>\"|$
  autocmd BufNewFile *.tex 0put =\"%&plain\<nl>\"|$
  autocmd BufNewFile *.\(cc\|hh\) 0put =\"//\<nl>// \".expand(\"<afile>:t\").\" -- \<nl>//\<nl>\"|2|start!
augroup END

CommentsEdit

You can also create a skeleton-file for each filetype and read it - see :help template.


Around Wikia's network

Random Wiki