My .vimrc

8 minute read

My .vimrc

set nocompatible
let mapleader=" "
set loadplugins

filetype on
filetype plugin indent on
syntax on
au FileType * setlocal formatoptions-=cro

" 인코딩 설정
set encoding=utf-8
set fenc=utf-8
set fencs=utf-8,cp949,cp932,euc-jp,shift-jis,big5,ucs-2le,latin1

" configuration for vundle
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

Plugin 'gmarik/Vundle.vim'
" None

Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
let g:airline_powerline_fonts=1
let g:airline_theme='gruvbox'
let g:airline#extensions#tabline#enabled=1

"Plugin 'matchparenpp'
" None

Plugin 'The-NERD-tree'
let g:NERDChristmasTree=1
let g:NERDTreeAutoCenter=1
let g:NERDTreeChDirMode=1
let g:NERDTreeHighlightCursorline=1
let g:NERDTreeSortOrder=['\.py$', '\.m$', '\.pyc$', '*']
let g:NERDTreeBookmarksFile = $HOME.'/.vim/NERDTreeBookmarks'
let g:NERDTreeIgnore=['\.vim$', '\~$']
let g:NERDTreeWinSize=40
let g:NERDTreeMinimalUI=1
let g:NERDTreeShowHidden=1
let g:NERDTreeShowLineNumbers=1
let g:NERDTreeQuitOnOpen=1
let g:NERDTreeShowFiles=1
let g:NERDTreeWinPos="left"

Plugin 'Valloric/YouCompleteMe'
let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_filetype_whitelist = {
            \ "sh":1,
            \ "zsh":1,
            \ "python":1,
            \ }
map <leader>g  :YcmCompleter GoToDefinitionElseDeclaration<CR>

Plugin 'morhetz/gruvbox'
set background=dark         "[light, dark]

Plugin 'ctrlpvim/ctrlp.vim'
set wildignore+=*/tmp/*,*.so,*.swp,*.zip     " MacOSX/Linux
set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe  " Windows

let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
let g:ctrlp_custom_ignore = {
  \ 'dir':  '\v[\/]\.(git|hg|svn|pyc)$',
  \ 'file': '\v\.(exe|so|dll)$',
  \ }

Plugin 'vim-scripts/indentpython.vim'
"Plugin 'vim-syntastic/syntastic'
"set statusline+=%#warningmsg#
"set statusline+=%{SyntasticStatuslineFlag()}
"set statusline+=%*
"let g:syntastic_always_populate_loc_list = 1
"let g:syntastic_loc_list_height = 5
"let g:syntastic_auto_loc_list = 0
"let g:syntastic_check_on_open = 1
"let g:syntastic_check_on_wq = 1
"let g:syntastic_error_symbol = '❌'
"let g:syntastic_style_error_symbol = '⚠️'
"let g:syntastic_warning_symbol = '⁉️'
"let g:syntastic_style_warning_symbol = '💩'
"highlight link SyntasticErrorSign SignColumn
"highlight link SyntasticWarningSign SignColumn
"highlight link SyntasticStyleErrorSign SignColumn
"highlight link SyntasticStyleWarningSign SignColumn
"Plugin 'nvie/vim-flake8'
"let g:flake8_show_in_gutter=1
"let g:flake8_show_in_file=1  
"let g:flake8_quickfix_height=3

call vundle#end()
filetype plugin indent on

" Appearance
set t_Co=256
"colorscheme wombat256mod
colorscheme gruvbox

" UI
set cursorcolumn                           " highlight the current column
set cursorline                             " highlight current line
set incsearch                              " BUT do highlight as you type you search phrase
set laststatus=2                           " always show the status line
set lazyredraw                             " do not redraw while running macros
set linespace=0                            " don't insert any extra pixel line betweens rows
"set list                                  " we do what to show tabs, to ensure we get them out of my files
"set listchars=tab:>-,trail:.,extends:>    " show tabs and trailing
set matchtime=5                            " how many tenths of a second to blink matching brackets for
set hlsearch                               " do not highlight searched for phrases
set nostartofline                          " leave my cursor where it was
set novisualbell                           " don't blink
set noerrorbells                           " don't beep
set number                                 " turn on line numbers
set numberwidth=5                          " We are good up to 99999 lines
set report=0                               " tell us when anything is changed via :...
set ruler                                  " Always show current positions along the bottom
set scrolloff=10                           " Keep 10 lines (top/bottom) for scope
set shortmess=aOstT                        " shortens messages to avoid 'press a key' prompt
set showcmd                                " show the command being typed
set showmatch                              " show matching brackets
set sidescrolloff=10
set statusline+=%#warningmsg#
set statusline+=%*

" Smart Setting
set backspace=2
set smartindent
set autoindent
set copyindent
set cindent
set nobackup
set mouse=a
set noto ttimeout
set autoread
"set completeopt=                          " don't use a pop up menu for completions
set expandtab                              " no real tabs please!
set formatoptions-=cro                     " Automatically insert comment leader on return, and let gq format comments
"set ignorecase                            " case insensitive by default
set infercase                              " case inferred by default
set nowrap                                 " do not wrap line
set shiftround                             " when at 3 spaces, and I hit > ... go to 4, not 5
set smartcase                              " if there are caps, go case-sensitive
set shiftwidth=4                           " auto-indent amount when using cindent, >>, << and stuff like that
set shiftround                             " use multiple of shiftwidth when indenting with '<' and '>'
set softtabstop=4                          " when hitting tab or backspace, how many spaces should a tab be (see expandtab)
set tabstop=4                              " real tabs should be 8, and they will show with set list on
set ww=h,l,b                               " move the cursor left/right to move to the previous/next line when the cursor is on the first/last character in the line
set sol                                    " when moving cursor(ex:<C-d>), move the cursor to the start of line
set wmh=0                                  " minium hegith of window
set title                                  " change name of terminal
set pastetoggle=<leader>p                  " toggle vim into past mode
set ttyfast                                " fast keyboard
set timeout timeoutlen=1000 ttimeoutlen=0 " fast keyboard
set clipboard=unnamedplus

" Python Specific Setting
let python_highlight_all=1

" Buffer setting
set hidden                                  
" prev buffer
nnoremap <silent><C-j> :bp<cr>              
" next buffer
nnoremap <silent><C-k> :bn<cr>
" quit buffer and move to prev buffer
nnoremap <silent><leader>D :bp<BAR>bd #<cr>
" list buffer
nnoremap <silent><C-l> :ls<cr>

inoremap jj <Esc>
nnoremap <leader>r :so ~/.vimrc<CR>

" Toggle NERDTree
nmap <leader>n :NERDTreeToggle<CR> 
nnoremap <silent><leader>/ :nohlsearch<Bar>:echo<CR>

" Use one of the following to define the camel characters.
let g:camelchar = "A-Z0-_9.,;:{([`'\""

nnoremap <silent><C-h> :<C-u>call search('\C\<\<Bar>\%(^\<Bar>[^'.g:camelchar.']\@<=\)['.g:camelchar.']\<Bar>['.g:camelchar.']\ze\%([^'.g:camelchar.']\&\>\@!\)\<Bar>\%^','bW')<CR>
nnoremap <silent><C-l> :<C-u>call search('\C\<\<Bar>\%(^\<Bar>[^'.g:camelchar.']\@<=\)['.g:camelchar.']\<Bar>['.g:camelchar.']\ze\%([^'.g:camelchar.']\&\>\@!\)\<Bar>\%$','W')<CR>
inoremap <silent><C-h> <C-o>:call search('\C\<\<Bar>\%(^\<Bar>[^'.g:camelchar.']\@<=\)['.g:camelchar.']\<Bar>['.g:camelchar.']\ze\%([^'.g:camelchar.']\&\>\@!\)\<Bar>\%^','bW')<CR>
inoremap <silent><C-l> <C-o>:call search('\C\<\<Bar>\%(^\<Bar>[^'.g:camelchar.']\@<=\)['.g:camelchar.']\<Bar>['.g:camelchar.']\ze\%([^'.g:camelchar.']\&\>\@!\)\<Bar>\%$','W')<CR>
vnoremap <silent><C-h> :<C-U>call search('\C\<\<Bar>\%(^\<Bar>[^'.g:camelchar.']\@<=\)['.g:camelchar.']\<Bar>['.g:camelchar.']\ze\%([^'.g:camelchar.']\&\>\@!\)\<Bar>\%^','bW')<CR>v`>o
vnoremap <silent><C-r> <Esc>`>:<C-U>call search('\C\<\<Bar>\%(^\<Bar>[^'.g:camelchar.']\@<=\)['.g:camelchar.']\<Bar>['.g:camelchar.']\ze\%([^'.g:camelchar.']\&\>\@!\)\<Bar>\%$','W')<CR>v`<o

" remove trailing white space
nnoremap <F5> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar><CR>

" prevent search jump
nnoremap * *``