I want to add shebang when creating anew python file.
.vimrc:
autocmd BufNewFile *.py exec ":call SetTitle_py(0)"
func SetTitle_py(line_num)
let boilerplate = [
\"#!/usr/bin/env python3",
\"# -*- coding:utf-8 -*- "
\]
call append(a:line_num, boilerplate)
endfunc
It works fine, everytime I create a new python file, the following two lines are inserted as the first two lines:
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
I want to add more lines such as below:
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
"""
"""
Add some comments in the .vimrc
:
.vimrc:
autocmd BufNewFile *.py exec ":call SetTitle_py(0)"
func SetTitle_py(line_num)
let boilerplate = [
\"#!/usr/bin/env python3",
\"# -*- coding:utf-8 -*- "
\"""
\
\"""
\]
call append(a:line_num, boilerplate)
endfunc
I have the error info when to re-create new python file:
Error detected while processing BufNewFile Autocommands for "*.py"..function SetTitle_py:
line 1:
E696: Missing comma in List: """"""]
line 8:
E121: Undefined variable: boilerplate
E116: Invalid arguments for function append
How can fix it?