Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable go.vim by default (automatically)?

Tags:

vim

go

The instructions on the Vim site says to just put the file in the /syntax folder. This works all right and well. But, for me to use the syntax I must set the following

:set syntax=go

Every single time. So, I know I am doing something wrong. I just don't know what.

Here are some things from looking around,

My HTML5 syntax set is from Rodrigo's HTML5 omnicomplete function and syntax vimball file. Though this uses some installation script to get it going.

As far as I can tell this would be my first manual adding of syntax file.

Also, my VIMRUNTIME is not set, well because there is no syntax.vim file, so from reading the documentation I see it checks for files via synload.vim

I even read the "Making Your Own Syntax Files" section, which says that same as above with the syntax=go option. Am I supposed to be detecting the .go filetype as described in new filetype section?

How can I enable syntax highlighting for GO by default?

This is for Mac Snow Leopard.

I don't think it is this complicated but I decided to leave all the different documentation I skimmed. GO and Vim say to just add the file. But it is definitely not detecting it automatically

like image 627
phwd Avatar asked Oct 01 '11 21:10

phwd


People also ask

What is vim go?

VIM + Plugins = A Powerful IDE for Go Vim is widely used to quickly edit text files and make configuration changes. However, Vim is more than that: it's a modern, flexible, and powerful editor that, with some additional configuration, can replace integrated development environments (IDE) for software development.

How do I set default syntax in vim?

Just type :e ~/. vimrc to vim, type in the line and save (:w).

How do I enable syntax in vim?

After opening login.sh file in vim editor, press ESC key and type ':syntax on' to enable syntax highlighting. The file will look like the following image if syntax highlighting is on. Press ESC key and type, “syntax off” to disable syntax highlighting.

Is vim good for go?

vim-go offers most of the features you may need when developing in Go, like syntax highlighting and folding, autocompletion support via gopls, code linting, quick execution using :GoRun , and more.


Video Answer


1 Answers

If you are using filetype detection in your ~/.vimrc file with the following line:

filetype plugin indent on

then you can place the file in the following folder:

~/.vim/after/ftplugin/go.vim

or for windows

~/vimfiles/...

For the filetype detection to work, would would want the autocmd in a file in the ftdetect folder:

~/.vim/ftdetect/go.vim

and the contents would be:

autocmd BufNewFile,BufReadPost *.go set filetype=go
like image 69
McLeopold Avatar answered Oct 14 '22 14:10

McLeopold