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

How to set up go language vim

藏色散人
Release: 2023-02-14 14:24:49
Original
3490 people have browsed it

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
Copy after login

2. Create the folder ~/.vim

mkdir ~/.vim
Copy after login

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
Copy after login

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
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template