英文:
snipMate filetype isn't set correctly
问题
我下载了vim并在python文件中使用它,代码片段完美运行。但是当我尝试在.go文件(golang)中使用snipMate时,它不起作用。我阅读了文档,没有找到答案,但是当我手动使用命令":set ft=go"时,代码片段起作用了。为什么snipMate自动适用于python而不适用于go?两种语言的代码片段文件都已提供。如何使go的代码片段自动起作用?
英文:
I downloaded vim and used it in a python file and the snippets worked perfectly. But when I tried to use snipMate in a .go file (golang) it didn't work. I read the documentation and couldn't find an answer but when I manually used the command ":set ft=go"
the snippets worked. Why does snipMate automatically work for python and not go. Snippet files for both languages are supplied. How do I get snippets for go to automatically work?
答案1
得分: 6
听起来你的.go文件没有设置为适当的文件类型。你可以在你的~/.vimrc文件中使用以下命令来解决这个问题:
au BufRead,BufNewFile *.go setl ft=go
适当的位置是将这样的文件放在你的~/.vim/ftdetect
目录中。例如,你可以创建一个名为~/.vim/ftdetect/go.vim
的文件,并将命令放在其中。
英文:
It sounds like your .go files aren't getting set to the appropriate filetype. You can use
au BufRead,BufNewFile *.go setl ft=go
in your ~/.vimrc to remedy this.
The appropriate place for files like this is in your ~/.vim/ftdetect
directory. For instance, you could create a file called ~/.vim/ftdetect/go.vim
and put the command in there.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论