-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
307 lines (242 loc) · 7.93 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
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
" Use Vim settings, rather then Vi settings. This setting must be as early as
" possible, as it has side effects.
set nocompatible
set background=dark "Use dark color scheme
let mapleader = "\<Space>"
" 行番号
set number
set relativenumber
nnoremap <F3> :<C-u>setlocal relativenumber!<CR>
"Start scrolling when we're 8 lines away from margins
set scrolloff=8
set sidescrolloff=15
set sidescroll=1
" 改行時にインデントを引き継いで改行する
set autoindent
" インデントにつかわれる空白の数
set shiftwidth=4
" <Tab>押下時の空白数
set softtabstop=4
" <Tab>押下時に<Tab>ではなく、ホワイトスペースを挿入する
set expandtab
" <Tab>が対応する空白の数
set tabstop=4
" Display extra whitespace
"set list listchars=tab:»·,trail:·,nbsp:·
set autoread " Reload files changed outside vim
" Trigger autoread when changing buffers or coming back to vim in terminal.
au FocusGained,BufEnter * :silent! !
set smartindent
set laststatus=2
set ruler
set cursorline
set cursorcolumn
set hlsearch
set nowrap
set incsearch
set ignorecase
set visualbell " stop that ANNOYING beeping
set wildmenu
set wildmode=list:longest,full
" tempファイルを作らない。編集中に電源落ちまくるし、とかいう人はコメントアウトで
set noswapfile
set nobackup
set nowritebackup
set history=50
set showmatch
" タブ文字の表示 ^I で表示されるよ
"set list
" Open new split panes to right and bottom, which feels more natural
set splitright
set splitbelow
" クリップボードを共有する(設定しないとvimとのコピペが面倒です)
set clipboard+=unnamed
set clipboard+=autoselect
vmap <C-c> :w !xsel -ib<CR><CR>
" インクリメント、デクリメントを16進数にする(0x0とかにしなければ10進数です。007をインクリメントすると010になるのはデフォルト設定が8進数のため)
set nf=hex
" " マウス使えます
set ttyfast
"set mouse=a
" delete bug fix
set backspace=indent,eol,start
set gcr=a:block-blinkon0
set guioptions-=m
set guioptions-=T
set guioptions-=l
set guioptions-=L
set guioptions-=r
set guioptions-=R
filetype on
filetype plugin on
syntax enable
syntax on
set tags=./tags,tags
" cscope
" find . -type f -print | grep -E '\.(c(pp)?|h)$' > cscope.files
if has("cscope")
" add any database in current directory
if filereadable("cscope.out")
cs add cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
set csverb
endif
call plug#begin('~/.vim/plugged')
"precision colorscheme for the vim text editor
Plug 'altercation/vim-colors-solarized'
" On-demand loading
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
" Source code browser
Plug 'vim-scripts/taglist.vim'
"Vim plugin that displays tags in a window
Plug 'majutsushi/tagbar'
" Fuzzy file, buffer, mru, tag, etc finder
Plug 'kien/ctrlp.vim'
"Vim plug for switching between companion source files
Plug 'derekwyatt/vim-fswitch'
"Vim-script library
Plug 'vim-scripts/L9'
"buffer/file/command/tag/etc explorer with fuzzy matching
Plug 'vim-scripts/FuzzyFinder'
" [3] Several plugins to help work with Tmux
Plug 'christoomey/vim-tmux-navigator'
" Code highlighting and linting
Plug 'scrooloose/syntastic' "Run linters and display errors etc]
" fugitive.vim: a Git wrapper so awesome, it should be illegal
Plug 'tpope/vim-fugitive'
" A light and configurable statusline/tabline for Vim
Plug 'itchyny/lightline.vim'
" Add plugins to &runtimepath
call plug#end()
" Ctag
let g:ctrlp_extensions = ['tag']
" :help g:ctrlp_match_window
let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:10,results:50'
" :help g:ctrlp_working_path_mode
let g:ctrlp_working_path_mode = 'rw'
" Color Set
set t_Co=256
set mouse=a
colorscheme solarized
" Tagbar
let tagbar_width=32
let g:tagbar_compact=1
let g:tagbar_usearrows = 1
let g:tagbar_autoclose = 1
let g:tagbar_autofocus = 1
let g:tagbar_width = 80
let g:lightline = {
\ 'colorscheme': 'solarized',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'fugitive', 'readonly', 'relativepath', 'modified' ] ]
\ },
\ 'component': {
\ 'fugitive': '%{exists("*fugitive#head")?fugitive#head():""}'
\ },
\ 'component_visible_condition': {
\ 'fugitive': '(exists("*fugitive#head") && ""!=fugitive#head())'
\ }
\ }
"Use enter to create new lines w/o entering insert mode
nnoremap <CR> o<Esc>
""Below is to fix issues with the ABOVE mappings in quickfix window
autocmd CmdwinEnter * nnoremap <CR> <CR>
autocmd BufReadPost quickfix nnoremap <CR> <CR>
"" Quicker window movement
"nnoremap <C-j> <C-w>j
"nnoremap <C-k> <C-w>k
"nnoremap <C-h> <C-w>h
"nnoremap <C-l> <C-w>l
nnoremap <Leader>w :w<CR>
nnoremap <Leader>q :q<CR>
nnoremap <Leader>x :x<CR>
nnoremap <Leader>X :q!<CR>
nnoremap <Leader>b :NERDTreeToggle<CR>
nnoremap <Leader>B :NERDTreeFind<CR>
autocmd vimenter * NERDTree
nnoremap <Leader>s :Gstatus<CR>
" zoom a vim pane, <C-w>= to re-balance
nnoremap <Leader>- :wincmd _<cr>:wincmd \|<cr>
nnoremap <Leader>= :wincmd =<cr>
" resize panes
nnoremap <silent> <Right> :vertical resize +5<cr>
nnoremap <silent> <Left> :vertical resize -5<cr>
nnoremap <silent> <Up> :resize +5<cr>
nnoremap <silent> <Down> :resize -5<cr>
nnoremap <silent> <C-]> g<C-]>
nnoremap <silent> <C-w>m <C-w>vg<C-]>
nmap <silent> <Leader>r :TagbarToggle<CR>
nmap <silent> <Leader>sw :FSHere<CR>
nmap <silent> <Leader>g :CtrlPTag<CR>
" Switch between the last two file
nnoremap <leader><leader> <c-^>
" [ って打ったら [] って入力されてしかも括弧の中にいる(以下同様)
imap [ []<left>
imap ( ()<left>
imap { {}<left>
"ハイライトをヤメる
nmap <Leader>, :noh<CR><Esc>
"Switching by number
nnoremap <F5> :buffers<CR>:buffer<Space>
"au FocusLost,WinLeave * :silent! wa
"autocmd VimResized * :wincmd =
"autocmd BufEnter * silent! cd %:p:h
vmap <Leader>y "+y
vmap <Leader>d "+d
nmap <Leader>p "+p
nmap <Leader>P "+P
vmap <Leader>p "+p
vmap <Leader>P "+P
vmap 0p "0p
vmap 0P "0P
nmap 0p "0p
nmap 0P "0P
" cscope key
nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-\>d :cs find d <C-R>=expand("<cword>")<cR><CR>
" split instead of a horizontal one
nmap <C-\>S :vert scs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>G :vert scs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>C :vert scs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>T :vert scs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>E :vert scs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>F :vert scs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-\>I :vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-\>D :vert scs find d <C-R>=expand("<cword>")<cR><CR>
" vs mode search with *
vnoremap * "zy:let @/ = @z<CR>n
" auto comment off
augroup auto_comment_off
autocmd!
autocmd BufEnter * setlocal formatoptions-=r
autocmd BufEnter * setlocal formatoptions-=o
augroup END
" 編集中のファイルパスをクリップボードにコピーする
function! g:CopyFilePath()
let @+ = expand("%:p")
echo @+
endfunction
" 編集中のファイル名をクリップボードにコピーする
function! g:CopyFileName()
let @+ = expand("%:t")
echo @+
endfunction
" 編集中のファイルの存在するフォルダのパスをクリップボードにコピーする
function! g:CopyFolderPath()
let @+ = expand("%:p:h")
echo @+
endfunction
" コマンドとして実行できるようにする
command! CopyFilePath :call g:CopyFilePath()
command! CopyFileName :call g:CopyFileName()
command! CopyFolderPath :call g:CopyFolderPath()