Golang vim syntax highlighting, saving FMT and guru installation

Source: Internet
Author: User
Tags autoload
This is a creation in Article, where the information may have evolved or changed.

Original link: Golang Vim plugin settings

In most cases, using vim to write Golang code requires syntax highlighting and automatic format. To do this, add a plugin that supports the Golang syntax to the VIM editor, and the plug-in configuration method is as follows:

1, download vim plugin management tool, if you have git, you can use Git clone directly

Https://github.com/tpope/vim-pathogen

2, in the establishment of folder ~/.vim

mkdir ~/.vim

3, copy Vim-pathogen under the AutoLoad folder to ~/.vim under:

4, under the ~/.vim set up the bundle folder, used to store vim plug-ins, file directory structure:

[Root@bogon. vim]# tree-l 1 *
AutoLoad
└──pathogen.vim
Bundle
├──nerdtree
├──vim-go
└──vundle.vim

5, CD ~/.vim/bundle to bundle under

Execute git clone https://github.com/fatih/vim-go install vim-go plugin

6. Configure your own VIMRC file, Vim ~/.VIMRC, add:

Call Pathogen#infect ()
Syntax on
FileType plugin indent on

Now browse the Golang code, there is syntax highlighting support and save the time of automatic FMT

7, installs the guru, realizes uses the GD command to jump to the function definition:

First create the golang.org/x folder under the $GOPATH/src path and then execute it under this folder:

git clone https://github.com/golang/tools

After the download is complete, perform the following $GOPATH/src/golang.org/x:

Go Install Golang.org/x/tools/cmd/guru

Locate the Guru under $gopah/bin, move it to the/usr/bin directory, or join $gopah/bin directly. BASHRC:

Vim opens the ~/.BASHRC, adding at its last:

Export Gopath= "Here is Gopath settings" Export gobin= $GOPATH/binexport path= $PATH: $GOPATH/bin

Executes the source ~/.BASHRC to make it effective.

To this vim has the vim-go plug-in and guru function jump support, writing Golang code more convenient, development is faster.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.