Is it possible to have VIM auto populate a file based on the extension?
For example, when I open a new .sh
file, I would like VIM to automatically type
#!/bin/bash
as the first line. (This example simplified down to the essentials)
Is it possible to have VIM auto populate a file based on the extension?
For example, when I open a new .sh
file, I would like VIM to automatically type
#!/bin/bash
as the first line. (This example simplified down to the essentials)
Check the section on "skeleton" in the vim help section:
:help skeleton
For your case, you should add a line like the following to your .vimrc:
autocmd BufNewFile *.sh 0r ~/vim/skeleton.sh
Vim can do this for sure, and more than what you expect.
Please refer to the popular "bash-support" plugin :
http://www.vim.org/scripts/script.php?script_id=365
for details.