Linux-vim的配置

1. 效果

vim是个非常强大的编辑器(主要是云端不能用其他的编辑器/(ㄒoㄒ)/~~),以下是我的vim配置文件,没啥新意,方便实用就行了,最终效果如下图:
Linux-vim的配置_第1张图片

2. 使用方法

#首先下载个Vundle
$git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/vundle
#打开.vimrc文件
$gedit ~/.vimrc
#复制我的`.vimrc`的内容,然后替换你.vimrc内容
#运行
$vim
#输入以下命令
:PluginInstall
#等待下载完成即可,下载可能需要点时间,主要在ycm下载需要时间,如果不需要可以去掉这个插件

3. 我的.vimrc文件

autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
" Switch syntax highlighting on, when the terminal has colors
if (&t_Co > 2 || has("gui_running")) && !exists("syntax_on")
  syntax on
endif

" Javascript syntax hightlight
syntax enable

" Set syntax highlighting for specific file types
autocmd BufRead,BufNewFile Appraisals set filetype=ruby
autocmd BufRead,BufNewFile *.md set filetype=markdown
autocmd Syntax javascript set syntax=jquery

" Color scheme
set t_Co=256
let g:rehash256 = 1
highlight NonText guibg=#060606
highlight Folded  guibg=#0A0A0A guifg=#9090D0

set nocompatible              " be iMproved 
filetype off                  " required! 

set rtp+=~/.vim/bundle/vundle/  
call vundle#rc() 

" let Vundle manage Vundle 
" required! 
Bundle 'gmarik/vundle'  

" 可以通过以下四种方式指定插件的来源 
" a) 指定Github中vim-scripts仓库中的插件,直接指定插件名称即可,插件明中的空格使用“-”代替。 
Bundle 'L9'  

" b) 指定Github中其他用户仓库的插件,使用“用户名/插件名称”的方式指定 
Bundle 'tpope/vim-fugitive'  
Bundle 'Lokaltog/vim-easymotion'  
Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}  
Bundle 'tpope/vim-rails.git'
Bundle 'scrooloose/nerdtree.git'
Bundle 'majutsushi/tagbar'
Bundle 'ctrlp.vim'
Bundle 'tomasr/molokai'
Bundle 'Valloric/YouCompleteMe'
let g:ycm_global_ycm_extra_conf = 'your path to .ycm_extra_conf.py'
colorscheme molokai

" c) 指定非Github的Git仓库的插件,需要使用git地址 
Bundle 'git://git.wincent.com/command-t.git' 

" d) 指定本地Git仓库中的插件 
Bundle 'file:///Users/gmarik/path/to/plugin' 

filetype plugin indent on     " required!

" Backspace deletes like most programs in insert mode
set backspace=2
" Show the cursor position all the time
set ruler
" Display incomplete commands
set showcmd
" Set fileencodings
set fileencodings=utf-8,bg18030,gbk,big5

filetype plugin indent on

" Softtabs, 2 spaces
set tabstop=4
set shiftwidth=4
set shiftround
set expandtab

" Display extra whitespace
set list listchars=tab:»·,trail:·

" Make it obvious where 80 characters is
" set textwidth=80
" set colorcolumn=+1

" Numbers
set number
set numberwidth=5

set matchpairs+=<:>
set hlsearch

" NERD tree
let NERDChristmasTree=0
let NERDTreeWinSize=35
let NERDTreeChDirMode=2
let NERDTreeIgnore=['\~$', '\.pyc$', '\.swp$']
let NERDTreeShowBookmarks=1
let NERDTreeWinPos="left"
" Automatically open a NERDTree if no files where specified
autocmd vimenter * if !argc() | NERDTree | endif
" Close vim if the only window left open is a NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
" Open a NERDTree
nmap <F5> :NERDTreeToggle<cr>

" Tagbar
let g:tagbar_width=35
let g:tagbar_autofocus=1
nmap <F6> :TagbarToggle<CR>

" ctrap
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.png,*.jpg,*.jpeg,*.gif " MacOSX/Linux
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
if executable('ag')
    " Use Ag over Grep
      set grepprg=ag\ --nogroup\ --nocolor
    " Use ag in CtrlP for listing files.
    let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
    " Ag is fast enough that CtrlP doesn't need to cache
    let g:ctrlp_use_caching = 0
endif

set laststatus=2 " Always display the status line
set statusline+=%{fugitive#statusline()} " Git Hotness

你可能感兴趣的:(Linux-vim的配置)