Go語言vim環境簡單搭建

來源:互聯網
上載者:User
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。

Vundle.vim的安裝步驟如下:

mkdir ~/.vim/bundle
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim                                                                     

建立~/.vimrc檔案(如果你沒有這個檔案的話),在檔案頂部添加有關Vundle.vim的配置:

set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'

" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required

此時Vim僅安裝了Vundle.vim這一個外掛程式。編輯hellogolang.go時與編輯普通文字檔無異,一切都還是Vim的預設屬性。


編輯~/.vimrc,在vundle#begin和vundle#end間增加一行:

Plugin 'fatih/vim-go'

在Vim內執行 PluginInstall,

Vundle.vim會在左側開啟一個Vundle Installer Preview子視窗,視窗下方會提示:“Processing 'fatih/vim-go'”,待安裝完畢後,提示資訊變 成“Done!”。

這時,我們可以看到.vim/bundle下多了一個vim-go檔案夾:

$ ls .vim/bundle/
vim-go/  Vundle.vim/

此時,再次編輯hellogolang.go,文法高亮有了, 儲存時自動format(利用$GOBIN/gofmt)也有了,但其他進階功能,比如自動import缺失的 package、自動補齊仍然沒有,我們還要繼續安裝一些東東。


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.