Home  >  Article  >  Backend Development  >  How to set up go language vim

How to set up go language vim

藏色散人
藏色散人Original
2021-03-16 11:19:303394browse

Go language vim setting method: 1. Download the vim plug-in management tool; 2. Copy the autoload folder under vim-pathogen to "~/.vim"; 3. In "~/.vim" Create a bundle folder; 4. Configure your own vimrc file.

How to set up go language vim

The operating environment of this article: Windows7 system, Go1.11.2, Dell G3 computer.

golang vim plug-in settings

In most cases, vim is used to write golang code, which requires syntax highlighting and automatic format. For this purpose, you need to add a plug-in that supports golang syntax to the vim editor. The plug-in configuration method is as follows:

1. Download the vim plug-in management tool. If you have git, you can directly use git clone

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

2. Create the folder ~/.vim

mkdir ~/.vim

3. Copy the autoload folder under vim-pathogen to ~/.vim:

4. Create it under ~/.vim The bundle folder is used to store vim plug-ins. The file directory structure is:

[root@bogon .vim]# tree -L 1 *
autoload
└── pathogen.vim
bundle
├── nerdtree
├── vim-go
└── Vundle.vim

5. cd ~/.vim/bundle Go to bundle

and execute git clone https://github.com/ fatih/vim-go Install the vim-go plug-in

6. Configure your own vimrc file, vim ~/.vimrc, add:

call pathogen#infect()
syntax on
filetype plugin indent on

Now browse the golang code and you will have syntax highlighting Automatically fmt when supporting and saving

7. Install guru and use the gd command to jump to the function definition:

First create the /golang.org/x folder under the GOPATH path, and then Go to this folder and execute:

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

After the download is complete, execute: go install golang.org/x/tools/cmd/guru

Now vim has the vim-go plug-in and guru With the support of function jumps, writing golang code is more convenient and development is faster.

Recommended tutorial: "go language"

The above is the detailed content of How to set up go language vim. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn