-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
134 lines (108 loc) · 3.13 KB
/
.vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
" vim-plug manages itself
if has('vim_starting')
set runtimepath+=~/.vim/plugged/vim-plug
if !isdirectory(expand('~/.vim/plugged/vim-plug'))
echo 'Installing vim-plug...'
call system('mkdir -p ~/.vim/plugged/vim-plug')
call system('git clone https://github.com/junegunn/vim-plug.git ~/.vim/plugged/vim-plug/autoload')
endif
endif
call plug#begin('~/.vim/plugged')
Plug 'junegunn/vim-plug', {'dir': '~/.vim/plugged/vim-plug/autoload'}
Plug 'scrooloose/nerdtree', {'on': 'NERDTreeToggle'}
Plug 'tpope/vim-surround'
Plug 'jiangmiao/auto-pairs'
Plug 'tomtom/tcomment_vim'
Plug 'nathanaelkane/vim-indent-guides'
let s:uname = substitute(system('uname -s'), '\n\+$', '', '')
if s:uname == 'Darwin'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
else
Plug '~/.fzf'
endif
Plug 'junegunn/fzf.vim', { 'do': { -> fzf#install() } }
call plug#end()
filetype off
filetype plugin indent off
augroup vimrc
autocmd!
augroup END
set background=dark
set encoding=utf-8
set fileencodings=utf-8,iso-2022-jp,euc-jp,sjis
set hidden
set splitbelow
set splitright
set ttimeoutlen=100
set ignorecase
set smartcase
set incsearch
set hlsearch
set shiftround
set tabstop=4
set shiftwidth=4
set cindent
set smarttab
set expandtab
set ambiwidth=double
set backspace=indent,eol,start
set list
set listchars=tab:>\ ,trail:-
set number
set showmatch
set matchpairs& matchpairs+=<:>
set grepformat=%f:%l:%m,%f,%l%m,%f\ \ %l%m
set grepprg=grep\ -snHIER
set ruler
" show bottom status line always
set laststatus=2
set wildmode=list:full
set visualbell t_vb=
set noerrorbells
nnoremap : ;
vnoremap : ;
nnoremap ; :
vnoremap ; :
nnoremap j gj
nnoremap k gk
nnoremap gj j
nnoremap gk k
nnoremap <silent><ESC><ESC> :nohlsearch<CR>
" expand '%%' to current directory in command line mode
cnoremap <expr> %% getcmdtype() == ':' ? expand('%:h').'/' : '%%'
" open QuickFix window automatically after use make or grep commands
autocmd vimrc QuickFixCmdPost make,*grep* :cwindow
" remove trailing space
function! s:remove_space()
if &filetype ==? 'markdown'
return
endif
let cursor = getpos(".")
%s/\s\+$//ge
call setpos(".", cursor)
unlet cursor
endfunction
autocmd vimrc BufWritePre * call <SID>remove_space()
" restore cursor position
autocmd vimrc BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
nnoremap <silent><Leader>e :NERDTreeToggle<CR>
autocmd vimrc bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
let g:fzf_command_prefix = 'Fzf'
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-s': 'split',
\ 'ctrl-v': 'vsplit'
\}
let g:fzf_layout = { 'down': '~30%' }
nnoremap <silent><C-p> :FzfFiles<CR>
nnoremap <silent><Leader>b :FzfBuffers<CR>
nnoremap <silent><Leader>t :FzfTags<CR>
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_exclude_filetypes = ['help', 'nerdtree']
let g:indent_guides_auto_colors = 0
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=NONE ctermbg=NONE
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=darkgrey ctermbg=8
filetype plugin indent on
runtime macros/matchit.vim
runtime ftplugin/man.vim
syntax on