https://github.com/scrooloose/vimfiles/blob/master/vimrc
set nocompatible "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 'jlanzarotta/bufexplorer' Plugin 'godlygeek/csapprox' Plugin 'ctrlpvim/ctrlp.vim' Plugin 'tpope/vim-endwise' Plugin 'tpope/vim-markdown' Plugin 'henrik/vim-indexed-search' Plugin 'scrooloose/nerdtree' Plugin 'Xuyuanp/nerdtree-git-plugin' Plugin 'scrooloose/nerdcommenter' Plugin 'scrooloose/syntastic' Plugin 'tpope/vim-rails' Plugin 'tpope/vim-surround' Plugin 'tpope/vim-fugitive' Plugin 'tpope/vim-ragtag' Plugin 'SirVer/ultisnips' Plugin 'honza/vim-snippets' Plugin 'mbbill/undotree' Plugin 'vim-scripts/YankRing.vim' Plugin 'majutsushi/tagbar' Plugin 'kien/rainbow_parentheses.vim' Plugin 'Valloric/MatchTagAlways' Plugin 'EinfachToll/DidYouMean' Plugin 'AndrewRadev/splitjoin.vim' Plugin 'michaeljsmith/vim-indent-object' Plugin 'vim-utils/vim-ruby-fold' Plugin 'christoomey/vim-tmux-navigator' Plugin 'chrisbra/csv.vim' Plugin 'ludovicchabant/vim-gutentags' Plugin 'airblade/vim-gitgutter' Plugin 'godlygeek/tabular' Plugin 'NLKNguyen/papercolor-theme' Plugin 'kana/vim-textobj-user' Plugin 'nelstrom/vim-textobj-rubyblock' Plugin 'dhruvasagar/vim-table-mode' Plugin 'mattn/webapi-vim' Plugin 'mattn/gist-vim' Plugin 'mzlogin/vim-markdown-toc' Plugin 'aklt/plantuml-syntax' Plugin 'flazz/vim-colorschemes' Plugin 'vim-airline/vim-airline' Plugin 'vim-airline/vim-airline-themes' call vundle#end() runtime macros/matchit.vim "allow backspacing over everything in insert mode set backspace=indent,eol,start "store lots of :cmdline history set history=1000 set showcmd "show incomplete cmds down the bottom set showmode "show current mode down the bottom set visualbell "beep 대신 visal bell 사용 set number "show line numbers set hlsearch "찾았던 키워드에 하일라이팅 해주기, 끄려면 :noh" set incsearch "한글자씩 입력할때마다 증가하면서 그에 매칭되는 word에 하일라이팅 set wrap "dont wrap lines set linebreak "wrap lines at convenient points set autoread "현재 열고 있는 파일이 아니라 다른 파일에서 수정이 발생한 경우, set synmaxcol=9999 "9999 line 이후에는 syntax highlight를 제대로 안 할 수 있음 "size가 큰 파일을 열때, 속도를 개선하는 효과있음 if v:version >= 703 "undo settings set undodir=~/.vim/undofiles set undofile set colorcolumn=+1 "mark the ideal max text width endif set directory=~/.vim/swapfiles/ "default indent settings set tabstop=4 softtabstop=4 shiftwidth=4 set expandtab smarttab "tab안에 space 채워줌, 이전 줄에서 끝난 그 indent에서 새로운 줄을 시작함" set autoindent set list listchars=tab:▸\ ,trail:·,precedes:←,extends:→ "tab과 space 구분하기 용이하게 세팅" "folding settings set foldmethod=indent "fold based on indent set foldnestmax=3 "deepest fold is 3 levels set nofoldenable "dont fold by default set foldlevelstart=99 "편집하려고 여는 모든 파일의 folding 없앰 set wildmode=list:longest "make cmdline tab completion similar to bash set wildmenu "자동완성 기능 향상" set wildignore=*.o,*.obj,*~ "stuff to ignore when tab completing set completeopt=menuone,preview "insert 모드에서 자동완성 추가 옵션 set formatoptions-=o "dont continue comments when pushing o/O "vertical/horizontal scroll off settings set scrolloff=3 set sidescrolloff=7 set sidescroll=1 "load ftplugins and indent files filetype plugin on filetype indent on "turn on syntax highlighting syntax on "some stuff to get the mouse going in term set mouse=a if !has("nvim") set ttymouse=xterm2 endif "tell the term has 256 colors "set t_Co=256 "colorscheme github "colorscheme jellybeans "hide buffers when not displayed set hidden iabbrev teh the set ignorecase set smartcase set laststatus=2 let g:airline_powerline_fonts = 1 let g:airline#extensions#tabline#enabled = 1 let g:airline#extensions#tabline#left_sep = ' ' let g:airline#extensions#tabline#left_alt_sep = '|' "recalculate the trailing whitespace warning when idle, and after saving autocmd cursorhold,bufwritepost * unlet! b:statusline_trailing_space_warning "return '[\s]' if trailing white space is detected "return '' otherwise function! StatuslineTrailingSpaceWarning() if !exists("b:statusline_trailing_space_warning") if !&modifiable let b:statusline_trailing_space_warning = '' return b:statusline_trailing_space_warning endif if search('\s\+$', 'nw') != 0 let b:statusline_trailing_space_warning = '[\s]' else let b:statusline_trailing_space_warning = '' endif endif return b:statusline_trailing_space_warning endfunction "return the syntax highlight group under the cursor '' function! StatuslineCurrentHighlight() let name = synIDattr(synID(line('.'),col('.'),1),'name') if name == '' return '' else return '[' . name . ']' endif endfunction "recalculate the tab warning flag when idle and after writing autocmd cursorhold,bufwritepost * unlet! b:statusline_tab_warning "return '[&et]' if &et is set wrong "return '[mixed-indenting]' if spaces and tabs are used to indent "return an empty string if everything is fine function! StatuslineTabWarning() if !exists("b:statusline_tab_warning") let b:statusline_tab_warning = '' if !&modifiable return b:statusline_tab_warning endif let tabs = search('^\t', 'nw') != 0 "find spaces that arent used as alignment in the first indent column let spaces = search('^ \{' . &ts . ',}[^\t]', 'nw') != 0 if tabs && spaces let b:statusline_tab_warning = '[mixed-indenting]' elseif (spaces && !&et) || (tabs && &et) let b:statusline_tab_warning = '[&et]' endif endif return b:statusline_tab_warning endfunction "recalculate the long line warning when idle and after saving autocmd cursorhold,bufwritepost * unlet! b:statusline_long_line_warning "return a warning for "long lines" where "long" is either &textwidth or 80 (if "no &textwidth is set) " "return '' if no long lines "return '[#x,my,$z] if long lines are found, were x is the number of long "lines, y is the median length of the long lines and z is the length of the "longest line function! StatuslineLongLineWarning() if !exists("b:statusline_long_line_warning") if !&modifiable let b:statusline_long_line_warning = '' return b:statusline_long_line_warning endif let long_line_lens = s:LongLines() if len(long_line_lens) > 0 let b:statusline_long_line_warning = "[" . \ '#' . len(long_line_lens) . "," . \ 'm' . s:Median(long_line_lens) . "," . \ '$' . max(long_line_lens) . "]" else let b:statusline_long_line_warning = "" endif endif return b:statusline_long_line_warning endfunction "return a list containing the lengths of the long lines in this buffer function! s:LongLines() let threshold = (&tw ? &tw : 80) let spaces = repeat(" ", &ts) let line_lens = map(getline(1,'$'), 'len(substitute(v:val, "\\t", spaces, "g"))') return filter(line_lens, 'v:val > threshold') endfunction "find the median of the given array of numbers function! s:Median(nums) let nums = sort(a:nums) let l = len(nums) if l % 2 == 1 let i = (l-1) / 2 return nums[i] else return (nums[l/2] + nums[(l/2)-1]) / 2 endif endfunction "plantuml conf let g:plantuml_executable_script = "$HOME/.vim/plantuml/uml.sh" "use space as leader in sensible modes nmapvmap "make wrapped lines more intuitive noremap k gk noremap j gj noremap 0 g0 noremap $ g$ "fix for yankring and neovim let g:yankring_clipboard_monitor=0 "vim-gist settings let g:gist_post_private = 1 let g:gist_browser_command = 'sensible-browser %URL%' "add new words (via zg) here setlocal spellfile+=~/.vim/spell/en.utf-8.add "make table-mode tables github-markdown compat let g:table_mode_corner="|" "syntastic settings let syntastic_stl_format = '[Syntax: %E{line:%fe }%W{#W:%w}%B{ }%E{#E:%e}]' "nerdtree settings let g:NERDTreeMouseMode = 2 let g:NERDTreeWinSize = 40 let g:NERDTreeMinimalUI=1 "tagbar settings let g:tagbar_sort = 0 "explorer mappings nnoremap bb :BufExplorer nnoremap bs :BufExplorerHorizontalSplit nnoremap bv :BufExplorerVerticalSplit nnoremap nt :NERDTreeToggle nnoremap nf :NERDTreeFind nmap :NERDTreeToggle set pastetoggle= "붙여넣기 할때 paste mode on/off 옵션" nnoremap nn :e . nnoremap nd :e %:h nnoremap ] :TagbarToggle nnoremap :CtrlP nnoremap :CtrlPBuffer "command abbrevs we can use `:E ` (and similar) to edit a file in the "same dir as current file cabbrev E ="e " . expand("%:h") . "/" = Eatchar(' ') cabbrev Sp ="sp " . expand("%:h") . "/" = Eatchar(' ') cabbrev SP ="sp " . expand("%:h") . "/" = Eatchar(' ') cabbrev Vs ="vs " . expand("%:h") . "/" = Eatchar(' ') cabbrev VS ="vs " . expand("%:h") . "/" = Eatchar(' ') function! s:Eatchar(pat) let c = nr2char(getchar(0)) return (c =~ a:pat) ? '' : c endfunc "ultisnips settings let g:UltiSnipsListSnippets = " " "source project specific config files runtime! projects/**/*.vim "dont load csapprox if we no gui support - silences an annoying warning if !has("gui") let g:CSApprox_loaded = 1 endif "ruby block textobj conf - remap from ar/ir to ab/ib let g:textobj_rubyblock_no_default_key_mappings = 1 xmap ab (textobj-rubyblock-a) omap ab (textobj-rubyblock-a) xmap ib (textobj-rubyblock-i) omap ib (textobj-rubyblock-i) "make clear the highlight as well as redraw nnoremap :nohls inoremap :nohls "map Q to something useful noremap Q gq "make Y consistent with C and D nnoremap Y y$ "visual search mappings function! s:VSetSearch() let temp = @@ norm! gvy let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g') let @@ = temp endfunction vnoremap * : call VSetSearch() // vnoremap # : call VSetSearch() ?? "gutentags settings "let g:gutentags_exclude = ['vendor/*', 'tmp/*', 'log/*', 'coverage/*', 'doc/*'] "tmux-vim-navigator setup let g:tmux_navigator_no_mappings = 1 nnoremap :TmuxNavigateLeft nnoremap :TmuxNavigateDown nnoremap :TmuxNavigateUp nnoremap :TmuxNavigateRight nnoremap :TmuxNavigatePrevious "jump to last cursor position when opening a file "dont do it when writing a commit log entry autocmd BufReadPost * call SetCursorPosition() function! SetCursorPosition() if &filetype !~ 'svn\|commit\c' if line("'\"") > 0 && line("'\"") <= line("$") exe "normal! g`\"" normal! zz endif else call cursor(1,1) endif endfunction "spell check when writing commit logs autocmd filetype svn,*commit* setlocal spell "http://vimcasts.org/episodes/fugitive-vim-browsing-the-git-object-database/ "hacks from above (the url, not jesus) to delete fugitive buffers when we "leave them - otherwise the buffer list gets poluted " "add a mapping on .. to view parent tree autocmd BufReadPost fugitive://* set bufhidden=delete autocmd BufReadPost fugitive://* \ if fugitive#buffer().type() =~# '^\%(tree\|blob\)$' | \ nnoremap .. :edit %:h | \ endif "ruby settings let g:ruby_indent_access_modifier_style = 'outdent' "add :Efactory and Eadmin etc for rails let g:rails_projections = { \ "spec/factories/*.rb": { \ "command": "factory", \ "template": \ ["FactoryGirl.define do", " factory :{} do", " end", "end"] \ }, \ "app/admin/*.rb": { \ "command": "admin", \ "template": \ ["ActiveAdmin.register {singular|capitalize} do", "end"], \ }} "activate rainbow parens for clojure autocmd syntax clojure call s:ActivateRainbowParens() function! s:ActivateRainbowParens() abort RainbowParenthesesToggle RainbowParenthesesLoadRound RainbowParenthesesLoadSquare RainbowParenthesesLoadBraces endfunction "when copying/pasting from the term into :e from a git diff or rspec or "similar we edit things like " "./app/models/foo.rb:10:in " "Save the time of stripping trailing shit and just make this edit and go to "line 10. autocmd bufenter * call s:checkForLnum() function! s:checkForLnum() abort let fname = expand("%:f") if fname =~ ':\d\+\(:.*\)\?$' let lnum = substitute(fname, '^.*:\(\d\+\)\(:.*\)\?$', '\1', '') let realFname = substitute(fname, '^\(.*\):\d\+\(:.*\)\?$', '\1', '') bwipeout exec "edit " . realFname doautocmd bufread doautocmd bufreadpre call cursor(lnum, 1) endif endfunction "toggle a markdown notes file in a fixed window on the right with f12 nnoremap :NotesToggle command! -nargs=0 NotesToggle call toggleNotes() function! s:toggleNotes() abort let winnr = bufwinnr("notes.md") if winnr > 0 exec winnr . "wincmd c" return endif botright 100vs notes.md setl wfw setl nonu "hack to make nerdtree et al not split the window setl previewwindow "for some reason this doesnt get run automatically and the cursor "position doesn't get set doautocmd bufreadpost % normal zMzO endfunction "command to filter :scriptnames output by a regex command! -nargs=1 Scriptnames call scriptnames( ) function! s:scriptnames(re) abort redir => scriptnames silent scriptnames redir END let filtered = filter(split(scriptnames, "\n"), "v:val =~ '" . a:re . "'") echo join(filtered, "\n") endfunction
:PluginInstall
반응형
'ide > vim' 카테고리의 다른 글
Vim unable to open swap file Error (0) | 2017.03.22 |
---|---|
vi/vim (0) | 2017.03.09 |
neovim (0) | 2017.02.13 |
neovim :help (0) | 2017.02.09 |
vim vundle plugin (0) | 2016.03.02 |