snipMate文件类型设置不正确

huangapple go评论72阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2012年8月23日 10:31:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/12083959.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定