Setting up Vim

547 views
Skip to first unread message

Ethan

unread,
Sep 10, 2011, 3:33:24 AM9/10/11
to golang-nuts
Hi, I'm having problem setting up Vim to work with Golang. I did as
instruction in README and http://www.miek.nl/blog/archives/2011/08/12/vim_setup/index.html
but so far nothing works. No syntax coloring, no autoindent, no auto-
completion, nothing.
Is there any tutorial out there that show a complete set of steps to
do it?

Bonus: I'm new to Vim

Kyle Lemons

unread,
Sep 10, 2011, 4:10:28 AM9/10/11
to Ethan, golang-nuts
Your vim also needs to be set up to do the things you describe. At a
minimum, try adding the following to your vimrc:

set ai
syntax on

----
Kyle Lemons
Google Platforms - Servers and Storage
Georgia Tech - BS CmpE '10

Sent from my iPhone, so pardon any spelling or punctuation issues!

Dave Cheney

unread,
Sep 10, 2011, 4:16:16 AM9/10/11
to Kyle Lemons, Ethan, golang-nuts
Hi Ethan,

I found the instructions in the misc package to be the most reliable.

$GOROOT/misc/vim/readme.txt

It should be noted that depending on your distro, you may have to
install vim-enhanced to get the support for this. From memory, on
debian/ubuntu the package is called vim-nox (other variants like
vim-gtk, also etc exist)

Cheers

Dave

tux21b

unread,
Sep 10, 2011, 5:00:46 AM9/10/11
to golan...@googlegroups.com
I have recently stumbled upon Sublime Text, a nice and modern editor. It offers some really nice unique features, and has many similarities with emacs and vim (there is even a vintage mode). The dev version is pretty stable and new features are added daily. I am currently considering a switch from vim too.

One big advantage over vim is, that ST has a pretty good config by default - my .vimrc + custom .vim/ folder on the other hand are about 100k lines long... Also ST looks more modern and might be a bit easier to master, especially at the beginning. I think a recent tweet by Brian Ketelsen describes it well: "SublimeText 2 + GoSublime + GoCode + Gofmt on save == joy".

Unfortunately the editor is closed source and costs quite a lot. The freely downloadable unlicensed version does not expire however...

PS: sorry for the add, but i am still impressed by ST ;)

Brian Ketelsen

unread,
Sep 10, 2011, 7:32:51 AM9/10/11
to golan...@googlegroups.com
Allegedly Sublime Text has a hidden VIM mode that can be enabled to make it follow most VIM commands and modes.  I haven't tried it yet, but it's on my list of things to check out.


Brian

Miek Gieben

unread,
Sep 10, 2011, 7:46:58 AM9/10/11
to golang-nuts
[ Quoting Ethan at 00:33 on September 10 in "[go-nuts] Setting up Vim"... ]

> Hi, I'm having problem setting up Vim to work with Golang. I did as
> instruction in README and http://www.miek.nl/blog/archives/2011/08/12/vim_setup/index.html

that was more of a note-to-self, than a full blown vim setup for Go.

You will at least need this in your ~/.vimrc

filetype plugin on
filetype indent on
filetype on

go/misc/vim/readme.txt explains the next steps very well.

Regards,
Miek Gieben

signature.asc

Kyle Lemons

unread,
Sep 10, 2011, 1:24:42 PM9/10/11
to Trịnh Quang Anh, golang-nuts
Sounds like your version of vim is a really minimal one or your terminal settings make vim think it can't use colors.  What does vim --version say? echo $TERM?  I believe at least +syntax and +indent need to be compiled in, and your terminal should probably be xterm-color.
~K

2011/9/10 Trịnh Quang Anh <codem...@gmail.com>
I added the following lines to .vimrc:

set rtp+=/home/quanganht/go/misc/vim
filetype plugin on
filetype indent on
syntax on

the only change is some keywords get underlined. Everything else is not there.

2011/9/10 Kyle Lemons <kev...@google.com>

Kyle Lemons

unread,
Sep 11, 2011, 2:35:15 AM9/11/11
to Trịnh Quang Anh, golang-nuts
try the following command:
$ TERM=xterm-color vim -R $GOROOT/src/pkg/xml/marshal.go

any improvement?

2011/9/10 Trịnh Quang Anh <codem...@gmail.com>
My Vim version has +syntax but no +indent. It doesn't look like a minimal version anyway. And the terminal is xterm.

Vào 00:24 Ngày 11 tháng 9 năm 2011, Kyle Lemons <kev...@google.com> đã viết:

keystroke

unread,
Oct 31, 2011, 6:56:38 PM10/31/11
to golang-nuts
I had some how the same problem, but when I copied all the files to
~/.vim as the same structure in misc/vim, it works.
Just don't know why....

On 9月10日, 下午3时33分, Ethan <codemast...@gmail.com> wrote:
> Hi, I'm having problem setting upVimto work with Golang. I did as
> instruction in README andhttp://www.miek.nl/blog/archives/2011/08/12/vim_setup/index.html

Reinhard Wobst

unread,
Jul 2, 2012, 4:49:06 AM7/2/12
to golang-nuts
> This not work because you have duplicate "syntax on" in the $HOME/.vimrc
> and /etc/vim/vimrc (or /etc/vimrc)

No, $HOME/.vimrc overwrites /etc/vimrc. However, sometimes strange vim
versions are delivered with Linux distributions. It is really quite
easy to compile and install a new vim, even if you have no superuser
privileges, especially if you want to have special features enabled,
as was Python in my case:

#!/bin/bash
UNIX=yes
SHELL=bash
CFLAGS=-O2 LDFLAGS="-s -L/usr/lib/python/config -lpthread" \
configure --with-features=big --enable-pythoninterp \
--with-python-config-dir=/usr/lib64/python2.6/config/

Then type "make && make install" (or set --prefix=... if you are no
superuser in the config line above). This lasts less than 10
minutes ...

Greetings

Reinhard
Reply all
Reply to author
Forward
0 new messages