Created
November 28, 2017 01:25
-
-
Save ShawnRong/bbf9fc258317385874881cbcabe3e44b to your computer and use it in GitHub Desktop.
.vimrc(vim settings)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" so ~/.vim/plugins.vim | |
syntax enable | |
set backspace=indent,eol,start "Make backspace behave like every other editor. | |
let mapleader=',' "The default leader is \, but a comma is much better. | |
set number "Let's activate line numbers. | |
set linespace=10 "Maccim-specific line-height" | |
set noerrorbells visualbell t_vb= "No bell | |
set shiftwidth=4 " number of spaces to use for autoindenting | |
set shiftround " use multiple of shiftwidth when indenting with '<' and '>' | |
set autoindent " always set autoindenting on | |
set copyindent " copy the previous indentation on autoindenting | |
set autowriteall "Automatically write the file when switching buffers. | |
set complete=.,w,b,u "Set Autocomplete | |
set tabstop=8 | |
set expandtab | |
set softtabstop=4 | |
set shiftwidth=4 | |
set ignorecase "Ignore case when searching" | |
set smartcase "Ignore case if searching pattern is all lowercase" | |
"-----------Visuals--------------" | |
"Theme set | |
colorscheme onedark | |
set background=dark | |
let g:onedark_termcolors=256 | |
"----------Custom----------------" | |
" Swap files out of the project root | |
set backupdir=~/.vim/backup// | |
set directory=~/.vim/swap// | |
"Easy escaping to normal model | |
inoremap jj <esc> | |
set guioptions-=e "Delate gui tabs | |
set guioptions-=l | |
set guioptions-=L | |
set guioptions-=r | |
set guioptions-=R | |
"Fake a custom left padding for each window. | |
"hi LineNr guibg=bg | |
"set foldcolumn=2 | |
"hi foldcolum guibg=bg | |
"Get rid of ugly split borders. | |
hi vertsplit guifg=bg guibg=bg | |
" Create/edit file in the current directory | |
nmap :ed :edit %:p:h/ | |
" Open splits | |
nmap vs :vsplit<cr> | |
nmap sp :split<cr> | |
" Down is really the next line | |
nnoremap j gj | |
nnoremap k gk | |
"-----------Search---------------" | |
set hlsearch | |
set incsearch | |
"-----------Split Management-------" | |
set splitbelow | |
set splitright | |
"Moving between window | |
nmap <C-J> <C-W><C-J> | |
nmap <C-K> <C-W><C-K> | |
nmap <C-H> <C-W><C-H> | |
nmap <C-L> <C-W><C-L> | |
" Quickly go forward or backward to buffer | |
nmap :bp :BufSurfBack<cr> | |
nmap :bn :BufSurfForward<cr> | |
"-----------Mappings---------------" | |
"Make it easy to edit the Vimrc file. | |
nmap <Leader>ev :tabedit $MYVIMRC<cr> | |
"Remove the highlight search" | |
nmap <Leader><space> :nohlsearch<cr> | |
nmap <Leader>f :tag<space> | |
"Add code snippet setting" | |
nmap <Leader>es :e ~/.vim/snippets/ | |
"-----------Plugins----------------" | |
"-----------vim-polyglot-----------" | |
let g:polyglot_disabled = ['yaml'] | |
"----------NERDTree plugins--------" | |
"shortct to open NERDtred | |
nmap <Leader>n :NERDTreeToggle<cr> | |
let NERDTreeAutoDeleteBuffer=1 | |
"display git information | |
let g:NERDTreeIndicatorMapCustom = { | |
\ "Modified" : "✹", | |
\ "Staged" : "✚", | |
\ "Untracked" : "✭", | |
\ "Renamed" : "➜", | |
\ "Unmerged" : "═", | |
\ "Deleted" : "✖", | |
\ "Dirty" : "✗", | |
\ "Clean" : "✔︎", | |
\ "Unknown" : "?" | |
\ } | |
"--------CtrlP Plugins------------" | |
"open file | |
map <Leader>p :CtrlP<cr> | |
"open buffer file | |
noremap <Leader>o :CtrlPBuffer<cr> | |
"open recent file | |
noremap <Leader>e :CtrlPMRU<cr> | |
"open recent file | |
map <Leader>r :CtrlBufTag<cr> | |
"exclude file | |
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux | |
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$' | |
let g:ctrlp_mruf_max=500 | |
let g:ctrlp_match_window_bottom=1 | |
"--------Rainbow_parenthese-------" | |
let g:rbpt_colorpairs = [ | |
\ ['brown', 'RoyalBlue3'], | |
\ ['Darkblue', 'SeaGreen3'], | |
\ ['darkgray', 'DarkOrchid3'], | |
\ ['darkgreen', 'firebrick3'], | |
\ ['darkcyan', 'RoyalBlue3'], | |
\ ['darkred', 'SeaGreen3'], | |
\ ['darkmagenta', 'DarkOrchid3'], | |
\ ['brown', 'firebrick3'], | |
\ ['gray', 'RoyalBlue3'], | |
\ ['black', 'SeaGreen3'], | |
\ ['darkmagenta', 'DarkOrchid3'], | |
\ ['Darkblue', 'firebrick3'], | |
\ ['darkgreen', 'RoyalBlue3'], | |
\ ['darkcyan', 'SeaGreen3'], | |
\ ['darkred', 'DarkOrchid3'], | |
\ ['red', 'firebrick3'], | |
\ ] | |
"-----------Vim-airline------------" | |
if !exists('g:airline_symbols') | |
let g:airline_symbols = {} | |
endif | |
"let g:airline_left_sep = '▶' | |
"let g:airline_left_alt_sep = '❯' | |
"let g:airline_right_sep = '◀' | |
"let g:airline_right_alt_sep = '❮' | |
let g:airline_symbols.linenr = '¶' | |
let g:airline_symbols.branch = '⎇' | |
set noshowmode | |
let g:airline#extensions#tabline#enabled = 1 | |
let g:airline#extensions#tabline#buffer_nr_show = 1 | |
let g:airline_theme='onedark' | |
set laststatus=2 | |
let g:airline#extensions#branch#enabled = 1 | |
let g:airline#extensions#tabline#show_tab_nr = 0 | |
let g:airline#extensions#tabline#show_tab_type = 1 | |
let g:airline#extensions#tabline#buffers_label = 'b' | |
let g:airline#extensions#tabline#tabs_label = 't' | |
"------------Syntastic-------------" | |
nnoremap <Leader>w :Errors<cr> | |
let g:syntastic_html_checkers = ['eslint', 'eslint-plugin-vue'] | |
"-----------TagBar-----------------" | |
nmap <Leader>t :TagbarToggle<cr> | |
" 启动时自动focus | |
"let g:tagbar_autofocus = 1 | |
"-----------YouCompleteMe Plugin---" | |
"file type black list ycm | |
" 设置在下面几种格式的文件上屏蔽ycm | |
let g:ycm_filetype_blacklist = { | |
\ 'tagbar' : 1, | |
\ 'qf' : 1, | |
\ 'notes' : 1, | |
\ 'markdown' : 1, | |
\ 'unite' : 1, | |
\ 'text' : 1, | |
\ 'vimwiki' : 1, | |
\ 'pandoc' : 1, | |
\ 'infolog' : 1, | |
\ 'mail' : 1 | |
\} | |
"key word trigger | |
let g:ycm_semantic_triggers = { | |
\ 'c' : ['->', '.', ' ', '(', '[', '&'], | |
\ 'objc' : ['->', '.', 're!\[[_a-zA-Z]+\w*\s', 're!^\s*[^\W\d]\w*\s', | |
\ 're!\[.*\]\s'], | |
\ 'ocaml' : ['.', '#'], | |
\ 'cpp,objcpp' : ['->', '.', '::'], | |
\ 'perl' : ['->'], | |
\ 'php' : ['->', '::'], | |
\ 'cs,java,javascript,typescript,d,python,perl6,scala,vb,elixir,go' : ['.'], | |
\ 'ruby' : ['.', '::'], | |
\ 'lua' : ['.', ':'], | |
\ 'erlang' : [':'], | |
\ } | |
let g:ycm_cache_omnifunc = 1 | |
let g:ycm_python_binary_path = '/usr/bin/python3' | |
let g:ycm_key_list_select_completion = ['<TAB>', '<Down>'] | |
"-----------Auto-Commands----------" | |
"Automatically source the Vimrc file on save. | |
augroup autosourcing | |
autocmd! | |
autocmd BufWritePost .vimrc source % | |
augroup END | |
if exists('$ITERM_PROFILE') | |
if exists('$TMUX') | |
let &t_SI = "\<Esc>[3 q" | |
let &t_EI = "\<Esc>[0 q" | |
else | |
let &t_SI = "\<Esc>]50;CursorShape=1\x7" | |
let &t_EI = "\<Esc>]50;CursorShape=0\x7" | |
endif | |
end | |
"----------Iterm2 cursor issue-----" | |
" Change cursor shape between insert and normal mode in iTerm2.app | |
"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 | |
""---------Tmux cursor shape--------" | |
"if exists('$ITERM_PROFILE') | |
"if exists('$TMUX') | |
"let &t_SI = "\<Esc>[3 q" | |
"let &t_EI = "\<Esc>[0 q" | |
"else | |
"let &t_SI = "\<Esc>]50;CursorShape=1\x7" | |
"let &t_EI = "\<Esc>]50;CursorSgape=0\x7" | |
"endif | |
"end | |
""---------Tmux copy indentation at pasting--" | |
"function! WrapForTmux(s) | |
"if !exists('$TMUX') | |
"return a:s | |
"endif | |
"let tmux_start = "\<Esc>Ptmux;" | |
"let tmux_end = "\<Esc>\\" | |
"return tmux_start . substitute(a:s, "\<Esc>", "\<Esc>\<Esc>", 'g') . tmux_end | |
"endfunction | |
"let &t_SI .= WrapForTmux("\<Esc>[?2004h") | |
"let &t_EI .= WrapForTmux("\<Esc>[?2004l") | |
"function! XTermPasteBegin() | |
"set pastetoggle=<Esc>[201~ | |
"set paste | |
"return "" | |
"endfunction | |
"inoremap <special> <expr> <Esc>[200~ XTermPasteBegin() | |
"Notes and Tips | |
"- Press 'zz' to instntly center the line where the cursor is located. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment