hello,
I'm trying to add skeleton to new files having a filetype (eg python)
here's what I've tried :
autocmd BufNewFile if &filetype == "python" 0r ~/.vim/python.skel | normal G | let IndentStyle = "python" | endif
with no luck when I open a new file like this :
: bel new | set filetype=python
I know skeleton works , because I have this line that adds it
when open a named new file
au BufNewFile *.py 0r ~/.vim/python.skel | normal G | let IndentStyle = "python"
PS: i noticed, when I open a new file with the command above, that adding startinsert at the end causes loading to be much longer and may corrupt dipslay.
this doesn't work very well:
: bel new | set filetype=python | startinsert
this works well:
: bel new | startinsert | set filetype=python
no file name argument has been given to that :new command, so the BufNewFile autocommand is not triggered.
this is the most important part of the reason why it doesn't work. :)
thank you for correcting autocommand.
do you have any (simple) idea about how to add skeleton to
unnamed file having filetype as python ?
if line("$") == 1 && empty(getline(1))
that's nice
if last line is the first one, and first line is empty
thank you.