-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.ideavimrc
executable file
·227 lines (187 loc) · 6.64 KB
/
.ideavimrc
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
""---------------------------------------------------------------------------
" bundle settings {{{
" webstorm のファイラーを起動
Plug 'preservim/nerdtree'
Plug 'tpope/vim-surround'
" }}}
"---------------------------------------------------------------------------
" basic settings {{{
set nocompatible " 必ず最初に書く(vi互換コードを解除)
set viminfo='20,<50,s10,h,! " YankRing用に!を追加
set shellslash " Windowsでディレクトリパスの区切り文字に / を使えるようにする
set lazyredraw " マクロなどを実行中は描画を中断
set number " 行番号を非表示
set ruler " ルーラーを表示 (noruler:非表示)
set cmdheight=2 " コマンドラインの高さ (Windows用gvim使用時はgvimrcを編集すること)
set laststatus=2 " 常にステータス行を表示 (詳細は:he laststatus)
" via http://kadoppe.com/archives/2013/09/vimrc-2.html
set lazyredraw
set ttyfast
" 折りたたみ関連
set nofoldenable
set foldmethod=indent
set foldopen=all " fold内に移動すれば自動で開く
" set foldclose=all " fold外に移動しfoldlevelより深ければ閉じる
set foldlevel=1 " 折りたたみの具合
set foldnestmax=2 " 最大折りたたみ深度$
set foldcolumn=2 " 左側に折りたたみガイド表示$
" via http://superuser.com/questions/622898/how-to-turn-off-the-bell-sound-in-intellij
" WebStormのビープ音を消す方法
set visualbell
set noerrorbells
" }}}
"---------------------------------------------------------------------------
" search settings {{{
set ignorecase " 大文字小文字無視
set smartcase " 大文字ではじめたら大文字小文字無視しない
set wrapscan " 最後まで検索したら先頭へ戻る
"set nowrapscan " 検索をファイルの先頭へループしない
set hlsearch " 検索文字をハイライト
set incsearch " インクリメンタルサーチ
" }}}
"---------------------------------------------------------------------------
" tab settings {{{
set autoindent
set cindent " C言語的なインデント
set expandtab " タブを空白文字に展開
set tabstop=2 " タブ文字の幅を設定できます。デフォルトは8です。
set softtabstop=2 " タブ文字を入力した際にタブ文字の代わりに挿入されるホワイトスペースの量を設定します。
set shiftwidth=2 " >> 等のコマンドや自動インデントの際に使う1レベル分のインデント量を設定します。
set shiftround
set smarttab
set nowrap
" 保存時にtabをスペースに変換する
autocmd BufWritePre * :%s/\t/ /ge
" }}}
"---------------------------------------------------------------------------
" move settings {{{
" deleteボタンが遠いんだ!
nmap <C-H> <BS>
" 0, 9で行頭、行末へ
nmap 1 ^
nmap 9 $
noremap <Space>h ^
noremap <Space>l $
" }}}
"---------------------------------------------------------------------------
" Windows {{{
" Split window
nmap ss :split<Return><C-w>w
nmap sv :vsplit<Return><C-w>w
" Move window
nmap <Space> <C-w>w
map s<left> <C-w>h
map s<up> <C-w>k
map s<down> <C-w>j
map s<right> <C-w>l
" }}}
"---------------------------------------------------------------------------
" insert mode settings {{{
" 挿入モードからコマンドモードに戻るキーバインド
imap <C-j> <esc>
" insert mode でjjでesc
inoremap jj <Esc>
" }}}
"---------------------------------------------------------------------------
" edit settings {{{
set showmatch " 括弧の対応をハイライト
set backspace=indent,eol,start
set clipboard=unnamed
set pastetoggle=<F12>
set guioptions+=a
" insertモードを抜けるとIMEオフ
set noimdisable
set iminsert=0 imsearch=0
set noimcmdline
inoremap <silent> <ESC> <ESC>:set iminsert=0<CR>
" コンマの後に自動的にスペースを挿入
inoremap , ,<Space>
" XMLの閉タグを自動挿入
augroup MyXML
autocmd!
autocmd Filetype xml inoremap <buffer> </ </<C-x><C-o>
augroup END
" 保存時に行末の空白を除去する
autocmd BufWritePre * :%s/\s\+$//ge
" }}}
"---------------------------------------------------------------------------
" other settings {{{
" ;でコマンド入力( ;と:を入れ替)
noremap ; :
" 行末までのヤンクにする
nnoremap Y y$
" 括弧入力後に←に移動
imap {} {}<Left>
imap [] []<Left>
" imap () ()<Left>
imap "" ""<Left>
imap '' ''<Left>
imap <> <><Left>
" カーソル行をハイライト
set cursorline
" カレントウィンドウにのみ罫線を引く
augroup cch
autocmd! cch
autocmd WinLeave * set nocursorline
autocmd WinEnter,BufRead * set cursorline
augroup END
hi clear CursorLine
hi CursorLine gui=underline
highlight CursorLine ctermbg=black guibg=black
" 全角スペースの表示
highlight ZenkakuSpace cterm=underline ctermfg=lightblue guibg=darkgray
match ZenkakuSpace / /
" 挿入モード時、ステータスラインの色を変更a
" via https://sites.google.com/site/fudist/Home/vim-nihongo-ban/vim-color
let g:hi_insert = 'highlight StatusLine guifg=darkblue guibg=darkyellow gui=none ctermfg=blue ctermbg=yellow cterm=none'
if has('syntax')
augroup InsertHook
autocmd!
autocmd InsertEnter * call s:StatusLine('Enter')
autocmd InsertLeave * call s:StatusLine('Leave')
augroup END
endif
"<space>j, <space>kで画面送り
noremap <Space>j <C-f>
noremap <Space>k <C-b>
" カーソル位置の単語をyankする
nnoremap vy vawy
"ビジュアルモード時vで行末まで選択
vnoremap v $h
" 最後に編集された位置に移動
nnoremap gb '[
"move tab
nnoremap gh gT
nnoremap gl gt
" <,>による連続インデント
vnoremap < <gv
vnoremap > >gv
autocmd FileType html setlocal includeexpr=substitute(v:fname,'^\\/','','') | setlocal path+=;/
" <Space>q で強制終了
nnoremap <Space>q :<C-u>q!<Return>
" ESC*2 でハイライトやめる
nnoremap <Esc><Esc> :<C-u>set nohlsearch<Return>
" 0番レジスタを使いやすくした
" via http://qiita.com/items/bd97a9b963dae40b63f5
vnoremap <silent> <C-p> "0p
" 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
" Shift + 矢印でウィンドウサイズを変更
nnoremap <S-Left> <C-w><<CR>
nnoremap <S-Right> <C-w>><CR>
nnoremap <S-Up> <C-w>-<CR>
nnoremap <S-Down> <C-w>+<CR>
" }}}
"---------------------------------------------------------------------------
" plugin settings {{{
"---------------------------------------------------------------------------
"
" for preservim/nerdtree {{{
" commands https://github.com/JetBrains/ideavim/wiki/NERDTree-support
nnoremap sf :NERDTree<CR>
nnoremap sk :NERDTreeToggle<CR>
" }}}
" }}}