To be specified,what I want to do is:
- if I create
xxx.php,#!/usr/bin/env phpwill be the first line of the file - if I create
xxx.py,#!/usr/bin/env pythonwill be added first.
How can I approach this?Thanks!
|
To be specified,what I want to do is:
How can I approach this?Thanks! |
||||
|
|
|
After some searching work,I find a post in SO that can solve my problem using templates.Hope it's helpful for you guys. Creat templates
Add following setting to
|
|||||
|
|
Not sure you can set up vim to do this unassisted. You might create a helper script to do it for you though. Assuming a linux environment... This script will check the file extension, and if necessary create the file with the header before calling vim.
You could then alias this script to run in place of vim.
|
|||||||||||
|
|
There exist many plugins that offer this feature. Some even let you automatically deduce various things, or even parametrize your header depending the folder where you are creating your new file (mu-template). |
|||
|
|
I actually like the approach of defining a vim function to do the work, this way it becomes much easier to do more complicated things. For instance, if the inserted text depends on the name of the file as is commonly done with C/C++. My C/C++ one looks like this:
The get_get_name() function forms the gate name from the name of the file being edited, and actually varies depending on the project I'm working on because some of the projects want it to be formatted a certain way. |
|||||||||
|