skeleton template
Learn about it with :help skeleton
To read a skeleton (template) file when opening
a new file: >
:autocmd BufNewFile *.c 0r ~/vim/skeleton.c
:autocmd BufNewFile *.h 0r ~/vim/skeleton.h
:autocmd BufNewFile *.java 0r ~/vim/skeleton.java
autocmd BufNewFile readme.md 0r ~/skeletons/readme.md
autocmd BufNewFile *.sh 0r ~/skeletons/bash.sh
- autocmd – run this automatically on some event
- BufNewFile – this is Vim’s new file event
- readme.md – this is the pattern you want the new file to match
- 0r – read into the buffer starting at line 0, the first line
- ~/skeletons/readme.md – the file to read in
The second example works the same way but uses a
file glob*.sh
to match any file ending in.sh