Golang 语言--linux 下 go语言 vim设置

  1. 在linux下安装 vundle.vim,请参照https://github.com/VundleVim/Vundle.vim获取和配置
  2. 打开.vimrc,如果没有可以创建.vimrc,复制如下内容到.vimrc
" An example for a vimrc file.
"" Maintainer:   Bram Moolenaar <Bram@vim.org>
" Last change:  2014 Nov 05"
" To use it, copy it to"     for Unix and OS/2:  ~/.vimrc
"         for Amiga:  s:.vimrc"  for MS-DOS and Win32:  $VIM\_vimrc
"       for OpenVMS:  sys$login:.vimrcset 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
Plugin 'fatih/vim-go'
call vundle#end()            " required
filetype plugin indent on    " required

" When started as "evim", evim.vim will already have done these settings.if v:progname =~? "evim"
  finish
endif" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.set nocompatible" allow backspacing over everything in insert mode
set backspace=indent,eol,start

if has("vms")
  set nobackup      " do not keep a backup file, use versions insteadelse
  set backup        " keep a backup file (restore to previous version)
  set undofile      " keep an undo file (undo changes after closing)
endifset history=50      " keep 50 lines of command line history
set ruler       " show the cursor position all the timeset showcmd     " display incomplete commands
set incsearch       " do incremental searching" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")" Don't use Ex mode, use Q for formatting
map Q gq

" CTRL-U in insert mode deletes a lot.  Use CTRL-G u to first break undo," so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>

" In many terminal emulators the mouse works just fine, thus enable it.if has('mouse')  set mouse=a
endif" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.if &t_Co > 2 || has("gui_running")
  syntax on
  set hlsearch
endif" Only do this part when compiled with support for autocommands.
if has("autocmd")

  " Enable file type detection.  " Use the default filetype settings, so that mail gets 'tw' set to 72,
  " 'cindent' is on in C files, etc.  " Also load indent files, to automatically do language-dependent indenting.
  filetype plugin indent on

  " Put these in an autocmd group, so that we can delete them easily.
  augroup vimrcEx
  au!  " For all text files set 'textwidth' to 78 characters.
  autocmd FileType text setlocal textwidth=78

  " When editing a file, always jump to the last known cursor position.  " Don't do it when the position is invalid or when inside an event handler
  " (happens when dropping a file on gvim).  " Also don't do it when the mark is in the first line, that is the default
  " position when opening a file.
  autocmd BufReadPost *
    \ if line("'\"") > 1 && line("'\"") <= line("$") |
    \   exe "normal! g`\"" |
    \ endif

  augroup ENDelse

  set autoindent        " always set autoindenting on

endif " has("autocmd")" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made." Only define it when not defined already.
if !exists(":DiffOrig")
  command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
          \ | wincmd p | diffthis
endif

if has('langmap') && exists('+langnoremap')
  " Prevent that the langmap option applies to characters that result from a  " mapping.  If unset (default), this may break plugins (but it's backward
  " compatible).  set langnoremap
endifset nuset tabstop=4set softtabstop=4set shiftwidth=4set nobackup" 这里是ctags
set tags=/home/.../go/go/tags
set tags+=/home/.../go/dev/danmu/tags
  1. 使用vim打开.vimrc,使用命令:PluginInstall,就可以下载相应的plugin包了

这里就可以使用vim 编辑.go 文件了

如果还需要,可以使用最新的ctags,一定要最新的,否则不支持.go 的tags

原文发布于微信公众号 - Golang语言社区(Golangweb)

原文发表时间:2016-04-22

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏Python与爬虫

佛系编程[如何创建一个安全可靠的应用程序]

推荐最近在GitHub上很火的一个项目,按照介绍,你也可以创建一个安全可靠的应用程序 项目地址在>>> nocode https://github.com/k...

4459
来自专栏后端沉思录

springboot、redis整合

1411
来自专栏阿杜的世界

在Spring Boot项目中使用Spock框架

Spock框架是基于Groovy语言的测试框架,Groovy与Java具备良好的互操作性,因此可以在Spring Boot项目中使用该框架写优雅、高效以及DSL...

2961
来自专栏云计算与大数据

How to Monitor Zookeeper

As per previous articles, our general rule of thumb is “collect all possible/rea...

2884
来自专栏后台及大数据开发

kubernetes集群搭建(6):kubernetes基本使用演示

流程: 用户访问client应用,client应用中调用server应用,由于部署了多节点,client在访问server时应该配置server 暴露的虚拟IP...

1392
来自专栏杨建荣的学习笔记

PCIE的简单配置(r8笔记第82天)

最近测试了一下PCIE-SSD在数据库环境的迁移 和加压情况,IOPS无可置疑,比起机械硬盘确实是高了很多个量级,在数据环境中的IO方面确实有很稳定的提升,目...

3788
来自专栏石奈子的Java之路

原 荐 SpringBoot 2.0 系列0

2484
来自专栏Duncan's Blog

springmvc-mybatis

本文基于原文http://doc.okbase.net/fengshizty/archive/126397.html配置环境。 首先说说几个问题 1.关于Myb...

1463
来自专栏大数据学习笔记

ElasticSearch 6.x 学习笔记:1.下载安装与配置

1. 安装配置JDK 8 (1)下载并解压缩 [root@node1 ~]# tar -zxvf jdk-8u112-linux-x64.tar.gz -C /...

2.5K10
来自专栏大魏分享(微信公众号:david-share)

怎样一个金箍圈(Pipeline),让至尊宝(Openshift)完成了到孙悟空(DevOps)的蜕变

但说出这句话,和实现Devops全工具链落地之间的差距,与造出原子弹和E=MC2公式的差距,实不逞多让。

6354

扫码关注云+社区

领取腾讯云代金券