0
我遇到了问题,我的.vimrc文件。我已经完成了所有python和sh文件的自动命令。我已经在下面列出了。autocmd bufnewfile在相对路径上导致“Trailing characters”错误
gvim test.py
如果我使用的路径相对于当前工作目录,但是,如:
gvim ../test.py
我收到以下错误:
使用的直接路径,即当所有的作品如预期Error detected while processing BufNewFile Auto commands for "*.{py,sh}"
E488: Trailing characters
有关如何解决此问题的任何想法?
autocmd bufnewfile *.{py,sh}
\ let path = expand("~/bin/Templates/")|
\ let extension = expand("%:e")|
\ let template = path . extension|
\ let name = "John Doe" |
\ if filereadable(template)|
\ execute "silent! 0r" . template|
\ execute "1," . 10 . "g/# File Name:.*/s//# File Name: " .expand("%")|
\ execute "1," . 10 . "g/# Creation Date:.*/s//# Creation Date: " .strftime("%b-%d-%Y")|
\ execute "1," . 10 . "g/Created By:.*/s//Created By: " . name|
\ execute "normal Gdd/CURSOR\<CR>dw"|
\ endif|
\ startinsert!
autocmd bufwritepre,filewritepre *.{py,sh}
\ execute "normal ma"|
\ execute "1," . 10 . "g/# Last Modified:.*/s/# Last Modified:.*/# Last Modified: "
\ .strftime("%b-%d-%Y")
autocmd bufwritepost,filewritepost *.{py,sh}
\ execute "normal 'a"
模板为Python文件如下:
所有的#!/usr/bin/python
# File Name: <filename>
# Creation Date: <date>
# Last Modified: <N/A>
# Created By: <Name>
# Description: CURSOR
完美。非常感谢你! – kennedyl