Skip to content

Instantly share code, notes, and snippets.

@zhchbin
Last active July 23, 2022 13:14
Show Gist options
  • Save zhchbin/2b0d0fcc3721e8e804ab617cde3accc3 to your computer and use it in GitHub Desktop.
Save zhchbin/2b0d0fcc3721e8e804ab617cde3accc3 to your computer and use it in GitHub Desktop.
vimrc
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 'VundleVim/Vundle.vim'
Plugin 'L9'
Plugin 'code_complete'
Plugin 'fholgado/minibufexpl.vim'
Plugin 'godlygeek/tabular'
Plugin 'plasticboy/vim-markdown'
Plugin 'scrooloose/nerdcommenter'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'vim-scripts/AutoComplPop'
Plugin 'vim-scripts/FuzzyFinder'
Plugin 'zxqfl/tabnine-vim'
call vundle#end() " required
filetype plugin indent on " required
"--------- Basic Options ---------
set nocompatible
set backupdir=~/.vim
set directory=~/.vim
set textwidth=80
set colorcolumn=+1
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set ignorecase " Do case insensitive matching
set smartcase " Do smart case matching
set incsearch " Incremental search
set autowrite " Automatically save before commands like :next and :make
set mouse=a " Enable mouse usage (all modes)
set number " Enable the line number
set autoindent
set smartindent
set tabstop=2
set softtabstop=2
set shiftwidth=2
set expandtab
set cindent
set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s
set ruler " Status bar of the cursor
set showmode
set encoding=utf-8
set fileencoding=utf-8
set hlsearch
set wrap
set t_Co=256
set so=10 " set the cursor stay in the middle of the screen
set autochdir
set completeopt=menu,menuone,longest
set ff=unix
set ffs=unix
set guioptions-=m
set guioptions-=T
set cul
set backspace=2
set backspace=indent,eol,start
set noerrorbells visualbell t_vb=
autocmd GUIEnter * set visualbell t_vb=
set history=1000 " remember more commands and search history
set undolevels=1000 " use many muchos levels of undo
let mapleader=","
syntax on
colorscheme molokai
"--------- Key Map ---------
map <c-a> ggVG
inoremap <C-s> <ESC>:w<CR>
map <F3> :TagbarToggle<CR>
map <C-o> <Esc>:FufFile<CR>
map <C-s> <ESC>:w<CR>
inoremap <C-s> <ESC>:w<CR>
map <D-> <C->
"--------- The last cursor postion --------
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
" --------- The AutoComplete of ([{ ----------
inoremap {<CR> {<CR>}<Esc>:call BC_AddChar("}")<CR><Esc>kA<CR>
inoremap [<CR> []<Esc>:call BC_AddChar("]")<CR>i
inoremap (<CR> ()<Esc>:call BC_AddChar(")")<CR>i
function! BC_AddChar(schar)
if exists("b:robstack")
let b:robstack = b:robstack . a:schar
else
let b:robstack = a:schar
endif
endfunction
function! SetupForMD()
set textwidth=0
set wrapmargin=0
endfunction
function! SetupForPython()
setlocal shiftwidth=4
setlocal tabstop=4
setlocal softtabstop=4
setlocal expandtab
endfunction
function! SetupForLua()
setlocal shiftwidth=4
setlocal tabstop=4
setlocal softtabstop=4
setlocal expandtab
endfunction
function! SetupForGolang()
setlocal shiftwidth=8
setlocal tabstop=8
setlocal softtabstop=8
setlocal expandtab
endfunction
au BufNewFile,BufRead *.md call SetupForMD()
au BufNewFile,BufRead *.py call SetupForPython()
au BufNewFile,BufRead *.lua call SetupForLua()
au BufNewFile,BufRead *.go call SetupForGolang()
function! StripTrailing()
let previous_search=@/
let previous_cursor_line=line('.')
let previous_cursor_column=col('.')
%s/\s\+$//e
let @/=previous_search
call cursor(previous_cursor_line, previous_cursor_column)
endfunction
nmap <leader><space> :call StripTrailing()<CR>
" MiniBufExpl Colors
hi MBENormal guifg=#808080 guibg=fg
hi MBEChanged guifg=#CD5907 guibg=fg
hi MBEVisibleNormal guifg=#5DC2D6 guibg=fg
hi MBEVisibleChanged guifg=#F1266F guibg=fg
hi MBEVisibleActiveNormal guifg=#A6DB29 guibg=fg
hi MBEVisibleActiveChanged guifg=#F1266F guibg=fg
@zhchbin
Copy link
Author

zhchbin commented Oct 25, 2019

$ mkdir -p ~/.vim/colors && curl https://raw.githubusercontent.com/tomasr/molokai/master/colors/molokai.vim > ~/.vim/colors/molokai.vim

$ git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
$ vim +PluginInstall +qall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment