Repository navigation
Expand file tree
/
Copy pathdot_vimrc
More file actions
202 lines (169 loc) · 4.6 KB
/
Copy pathdot_vimrc
File metadata and controls
202 lines (169 loc) · 4.6 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
" ======================
" vim configuration file
" @author suzuken (https://github.com/suzuken)
"
" suzuken/dotfiles - GitHub
" https://github.com/suzuken/dotfiles
" ======================
" use https://github.com/junegunn/vim-plug
call plug#begin()
Plug 'vim-scripts/The-NERD-Commenter'
Plug 'tpope/vim-fugitive'
Plug 'thinca/vim-quickrun'
Plug 'justinmk/vim-dirvish'
Plug 'preservim/vim-markdown'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'fatih/vim-go', {'for': 'go'}
call plug#end()
" bundled with Vim 9.0.1799+
packadd! editorconfig
filetype plugin indent on
syntax on
let mapleader = ","
"==========================
"Basic
"==========================
set encoding=utf-8
set fileencodings=ucs-bom,utf-8,iso-2022-jp,euc-jp,cp932,latin1
set fileformats=unix,dos,mac
set tabstop=4
set expandtab
set softtabstop=0
set shiftwidth=4
set smarttab
set autoindent
set smartindent
set backspace=indent,eol,start
set formatoptions+=mM
set number
set title
set scrolloff=5
set ambiwidth=double
set visualbell
set cmdheight=2
set showcmd
set laststatus=2
set splitright
set splitbelow
set helplang=en
set list
set listchars=tab:>-,trail:-,extends:<,precedes:<
highlight SpecialKey ctermfg=darkgray
set wildmenu
set wildmode=full:list
set clipboard=unnamed
set grepprg=internal
set autowrite
set hidden
set backup
set backupdir=$HOME/.vimback
set directory=$HOME/.vimtmp
set history=10000
set updatetime=500
"==========================
"Searching and Moving
"==========================
set ignorecase
set smartcase
set incsearch
set showmatch
set hlsearch
nnoremap / /\v
vnoremap / /\v
" always escape / and ? in search character.
cnoremap <expr> / getcmdtype() == '/' ? '\/' : '/'
cnoremap <expr> ? getcmdtype() == '?' ? '\?' : '?'
" when move to search results, move to center.
noremap n nzz
noremap N Nzz
noremap * *zz
noremap # #zz
noremap g* g*zz
noremap g# g#zz
"==========================
"Key Bind
"==========================
nnoremap ; :
" edit / reload vimrc
noremap <C-c><C-c> <C-c>
noremap <C-c><C-e>e :edit $MYVIMRC<CR>
noremap <C-c><C-e>s :source $MYVIMRC<CR>
" In visual mode, tab means indent highlighted block.
vnoremap <Tab> >gv
vnoremap <S-Tab> <gv
" move between splits with ctrl + hjkl
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" <Enter> always means inserting line.
nnoremap <S-Enter> O<ESC>
nnoremap <Enter> o<ESC>
" Creating underline/overline headings for markup languages
" Inspired by http://sphinx.pocoo.org/rest.html#sections
nnoremap <leader>1 yyPVr=jyypVr=
nnoremap <leader>2 yyPVr*jyypVr*
nnoremap <leader>3 yyPVr-jyypVr-
nnoremap <leader>4 yypVr=
nnoremap <leader>5 yypVr-
nnoremap <leader>6 yypVr^
nnoremap <leader>7 yypVr"
" open URI under the current line
function! HandleURI()
let s:uri = matchstr(getline("."), '[a-z]*:\/\/[^>,;:]*')
echo s:uri
if s:uri != ""
exec "!open \"" . s:uri . "\""
else
echo "No URI found in line."
endif
endfunction
nnoremap <Leader>w :call HandleURI()<CR>
" set full path of current buffer to unnamed register
" http://stackoverflow.com/questions/916875/yank-file-name-path-of-current-buffer-in-vim
nnoremap cp :let @" = expand("%")
"==========================
"File Type
"==========================
" python / ruby / yaml indent comes from Vim's bundled ftplugins.
augroup my_filetypes
autocmd!
autocmd FileType html setlocal tabstop=2 shiftwidth=2 softtabstop=2 expandtab
autocmd FileType go setlocal noexpandtab tabstop=4 shiftwidth=4
autocmd BufWinEnter,BufNewFile *_test.go set filetype=go.test
augroup END
"==========================
"Plugins
"==========================
" vim-go
let g:go_def_reuse_buffer = 1
augroup my_vim_go
autocmd!
autocmd FileType go nnoremap <buffer> <leader>is :GoImports<CR>
autocmd FileType go nmap <buffer> <leader>b <Plug>(go-build)
" override default gd option of vim-go, use split
autocmd FileType go nmap <buffer> gs <Plug>(go-def-split)
augroup END
" vim-quickrun
let g:quickrun_config = {}
let g:quickrun_config['go.test'] = {'command': 'go', 'cmdopt': 'test -v'}
nnoremap <Leader>r :QuickRun<CR>
" vim-markdown
let g:vim_markdown_fenced_languages = ['js=javascript', 'json=javascript']
" vim-dirvish
let g:dirvish_relative_paths = 1
augroup my_dirvish_events
autocmd!
autocmd User DirvishEnter let b:dirvish.showhidden = 1
augroup END
" ctrlp.vim
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard']
" NERD Commenter
let g:NERDSpaceDelims = 1
"----------------------------------------------------
"" host specific
"----------------------------------------------------
if filereadable(expand("~/.vimrc.local"))
source ~/.vimrc.local
endif