美文网首页
mac vim 配置(生产力工具)

mac vim 配置(生产力工具)

作者: qishuai | 来源:发表于2018-02-25 13:10 被阅读0次

vim是我经常使用的工具,但他的功能太简陋了,连代码高亮都没有,实在影响效率;之前也配置过vim,但是失败了,这次实在忍不了了,周末花几个小时时间配置一下,配置完之后果然很爽。现在vim能做:代码高亮、自动补全c++/golang/js代码、文件快速定位、语法检测。

安装列表:

  • Vundle: vim 插件安装管理插件
  • YouCompleteMe: 代码补全插件
  • syntastic: 语法分析和错误提示插件,可实时提示语法错误
  • NERD_tree: 目录树插件
  • command-t: 快速导航定位文件插件
  • vim-gitgutter: vim git 插件,看文件修改情况
  • ctags 遍历源代码文件生成tags文件
  • taglist: 显示函数列表

安装步骤:

  1. 安装Vundle,插件管理软件

     git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
    
  2. 安装YouCompleteMe

     cd ~/.vim/bundle
     git clone https://github.com/Valloric/YouCompleteMe.git
     cd YouCompleteMe
             git submodule update --init --recursive
             brew install cmake
     ./install.py --clang-completer --go-completer --js-completer
    
  3. 安装syntastic

     mkdir -p ~/.vim/autoload && curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
    

    如果以上命令没有反应,可以使用以下方法补救:

     //浏览器打开以下链接
     https://raw.githubusercontent.com/tpope/vim-pathogen/master/autoload/pathogen.vim
     cd ~/.vim/autoload
     touch pathogen.vim
     vim pathogen.vim
     // 手动复制网页上的内容,到该文件中,保存退出即可
    
  4. 安装NERD_tree

     git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree
    
  5. 安装command-t

     git clone https://github.com/wincent/command-t.git ~/.vim/bundle/command-t
    
  6. 安装vim-gitgutter

     git clone git://github.com/airblade/vim-gitgutter.git ~/.vim/bundle/vim-gitgutter
    
  7. 安装ctags,mac默认已经安装了ctags,如果没有通过以下命令安装

     brew install ctags
    
  8. 安装taglist,去浏览器下载:https://sourceforge.net/projects/vim-taglist/files/

     unzip taglist_45.zip
     cd taglist_45
     cp -r ./doc ~/.vim/
     cp -r ./plugin  ~/.vim/
     cd ~/.vim/plugin
     vim taglist.vim
     //在if !exists('loaded_taglist')上一行输入:
     let Tlist_Ctags_Cmd="/usr/local/bin/ctags"
    

    运行 ctags -R

  9. 将文章末尾代码复制到~/.vimrc中

     vim
     :PluginInstall
    

我的配置文件:

set guifont=Darcula:h52
let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'

filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

Plugin 'VundleVim/Vundle.vim'
Plugin 'Scrooloose/nerdtree'
Plugin 'airblade/vim-gitgutter'
Plugin 'vim-syntastic/syntastic'
Plugin 'wincent/command-t'
Plugin 'Valloric/YouCompleteMe'
Plugin 'SirVer/ultisnips'

call vundle#end()
filetype plugin indent on

" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"

"NERDTree
"F2开启和关闭树"
"map <F2> :NERDTreeToggle<CR>
"let NERDTreeChDirMode=1
""显示书签"
"let NERDTreeShowBookmarks=1
"设置忽略文件类型"
"let NERDTreeIgnore=['\~$', '\.pyc$', '\.swp$']
""窗口大小"
"let NERDTreeWinSize=25

"indentLine
"缩进指示线"
let g:indentLine_char='|'
let g:indentLine_enabled=1

set number
set ruler
set history=1000
set showcmd
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}
set laststatus=2
syntax on
set fileencodings=utf-8,gb2312,gbk,cp936,latin-1
set fileencoding=utf-8
set termencoding=utf-8
set fileformat=unix
set encoding=utf-8
colorscheme desert
set t_Co=256

set wildmenu

set nocompatible
set backspace=indent,eol,start
set backspace=2

set autoindent

set smartindent

set nobackup
set nowritebackup
set noswapfile

set expandtab

set tabstop=4

set softtabstop=4

set shiftwidth=4

set helplang=cn

set showmatch

au FileType html,python,vim,javascript setl shiftwidth=4
au FileType html,python,vim,javascript setl tabstop=4
au FileType java,php setl shiftwidth=4
au FileType java,php setl tabstop=4
set hlsearch

filetype indent on

set cindent
set completeopt=longest,menu


set noeb
set autowrite
set cursorline
"if $TERM_PROGRAM =~ "iTerm"
let &t_SI = "\<Esc>]50;CursorShape=1\x7" " Vertical bar in insert mode
let &t_EI = "\<Esc>]50;CursorShape=0\x7" " Block in normal mode
"endif
set clipboard+=unnamed
set autoread
set scrolloff=3
  1. 小技巧

使用鼠标定位

 set mouse=a

使用鼠标复制

  set mouse=v

vim如果没有指定打开的文件,指定开启NERDTree

autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif

如果窗口只剩下NERDTree时,自动关闭vim

  autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif

相关文章

  • mac vim 配置(生产力工具)

    vim是我经常使用的工具,但他的功能太简陋了,连代码高亮都没有,实在影响效率;之前也配置过vim,但是失败了,这次...

  • 关于mac配置Vim环境

    以下分为三类的使用 基本的Vim的mac环境下的配置 使用包管理工具 其他补充 基本的Vim的mac环境下的配置 ...

  • vim配置python相关插件

    配置vim插件管理工具配置vim-pathogen配置vimogen 配置常用插件YouCompleteMeneo...

  • 我的vim个性配置

    mac下安装vim 我的一些vim配置信息 移除安装

  • Mac How to play with Vim (3)

    众所周知Mac一直被程序猿视为生产力工具,正好手上有一台上古时期Macbook,可以拿来玩玩Vim。 Macboo...

  • MAC下vim插件YouCompleteMe和HomeBrew

    今天配置了mac的vim,说到vim优化,肯定少不了大牛Valloric的YouCompleteMe插件,这个插件...

  • 前端开发 VS Code 上手使用

    如果想配置 sublime 开发工具 => sublime 配置及使用技巧 如果想配置 vim 开发工具 => 面...

  • mac 配置vim

    1.环境 OS X EI Capitan 2.拷贝默认的配置文件 ``` $ cp /usr/share/vim/...

  • Mac vim配置

    copy上面内容,放到 ~/.vimrc文件中即可,没有该文件就新建一个吧

  • 实用Vim 配置.md

    实用 Vim 配置 以下分两部分介绍了Vim 的配置,他们的配置内容大同小异,主要是由于用途的不同。 Mac 在M...

网友评论

      本文标题:mac vim 配置(生产力工具)

      本文链接:https://www.haomeiwen.com/subject/wmbcxftx.html