kana / config

My configuration files feat. hardcore Vim scripts

This URL has Read+Write access

config / vim / dot.vimrc
661b53ea » kana 2008-02-15 vim/dot.vimrc: 1 " My .vimrc
8fdfe5f1 » kana 2007-10-10 Notes: New section. 2 " Notes "{{{1
3 "
4 " * This file consists of "sections".
5 "
ee2fb8d1 » kana 2008-05-04 vim: vimrc: Update some ite... 6 " - The name of each section should be single word.
60783901 » kana 2007-10-10 Revise UTILITY FUNCTIONS & ... 7 "
8fdfe5f1 » kana 2007-10-10 Notes: New section. 8 " * Each section consists of zero or more "subsections".
9 "
60783901 » kana 2007-10-10 Revise UTILITY FUNCTIONS & ... 10 " - There is no rule for the name of each subsection.
11 "
b6850cdf » kana 2007-10-10 Divide MISC. section into P... 12 " * The last subsection in a section should be named as "Misc.".
8fdfe5f1 » kana 2007-10-10 Notes: New section. 13 "
14 " * Whenever new subsection is inserted,
ee2fb8d1 » kana 2008-05-04 vim: vimrc: Update some ite... 15 " it should be inserted just before "Misc." subsection.
8fdfe5f1 » kana 2007-10-10 Notes: New section. 16 "
17 " * If a setting can be categorized into two or more sections,
18 " it should be put into the most bottom section in this file.
19 "
20 " For example, key mappings for a specific plugin should be put into the
ee2fb8d1 » kana 2008-05-04 vim: vimrc: Update some ite... 21 " "Plugins" section.
8fdfe5f1 » kana 2007-10-10 Notes: New section. 22 "
23 "
24 " Coding Rule
25 "
26 " * Separate sections with 8 blank lines.
27 "
28 " * Separate subsections with 4 blank lines.
29 "
ee2fb8d1 » kana 2008-05-04 vim: vimrc: Update some ite... 30 " * Indentation: See the modelines at the bottom of this file.
31 "
32 " * Character Encoding: Use UTF-8 for this file and other files such as
33 " plugins, but this file must contain only unibyte (i.e. 7-bit ASCII)
34 " characters.
35 "
36 " Because changing 'encoding' does not affect the character encoding of
37 " existing buffers, so that each multibyte character will be treated as
38 " multiple single byte characters at the first time of loading this file.
39 " For example, if this file contains a character U+3042 (Japanese Hiragana
40 " "A"), it will be converted into 3 independent bytes -- E3, 81 and 82.
8fdfe5f1 » kana 2007-10-10 Notes: New section. 41 "
42 " * Limit all lines to a maximum of 79 characters.
43 "
44 " * Separate {lhs} and {rhs} of key mappings with 2 spaces.
45 "
46 " * Separate {cmd} and {rep} of :command definitions with 2 spaces.
47 "
e63e08e5 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 48 " * Write the full name for each command -- don't abbreviate it.
49 " For example, write "nnoremap", not "nn".
60783901 » kana 2007-10-10 Revise UTILITY FUNCTIONS & ... 50 "
8fdfe5f1 » kana 2007-10-10 Notes: New section. 51 " * Key Notation:
52 "
53 " - Control-keys: Write as <C-x>, neither <C-X> nor <c-x>.
54 "
55 " - Carriage return: Write as <Return>, neither <Enter> nor <CR>.
56 "
57 " - Other characters: Write as same as :help key-notation
bc03e7c8 » kana 2008-01-12 vim/dot.vimrc: 58 "
59 " * Line continuation:
60 "
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 61 " - At the middle of key mappings, abbreviations and other proler places:
62 " Write "\" at the previous column of the start of the {rhs}.
bc03e7c8 » kana 2008-01-12 vim/dot.vimrc: 63 "
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 64 " - Others: Write "\" at the same column of the beggining of the command.
bc03e7c8 » kana 2008-01-12 vim/dot.vimrc: 65 "
66 " - Examples:
67 "
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 68 " execute "echo"
69 " \ "foo"
70 " \ "baz"
bc03e7c8 » kana 2008-01-12 vim/dot.vimrc: 71 "
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 72 " map <silent> xyzzy :<C-u>if has('cryptv')
73 " \| X
74 " \|endif<Return>
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 75 "
76 " * Don't align columns. So don't write like the following code:
77 "
78 " map <expr> foo bar
79 " noremap <silent> bar baz
80 "
81 " instead, write like the following code:
82 "
83 " map <expr> foo bar
84 " noremap <silent> bar baz
8fdfe5f1 » kana 2007-10-10 Notes: New section. 85
86
87
88
89
90
91
92
88559863 » kana 2007-10-10 Rearrange SETTINGS WHICH AR... 93 " Basic "{{{1
94 " Absolute "{{{2
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 95
88559863 » kana 2007-10-10 Rearrange SETTINGS WHICH AR... 96 set nocompatible " to use many extensions of Vim.
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 97
98
f6426230 » kana 2008-02-24 Vim: vimrc: Improve the pla... 99 function! s:SID_PREFIX()
100 return matchstr(expand('<sfile>'), '<SNR>\d\+_')
101 endfunction
102
103
88559863 » kana 2007-10-10 Rearrange SETTINGS WHICH AR... 104
105
106 " Encoding "{{{2
107
195a83f9 » kana 2007-02-16 Fix the layout. 108 " To deal with Japanese language.
faa79ee5 » kana 2008-04-07 Add some fixes to work on M... 109 if $ENV_WORKING ==# 'colinux' || $ENV_WORKING ==# 'mac'
eafef300 » kana 2007-09-10 dot.vimrc: 110 set encoding=utf-8
111 else
112 set encoding=japan
113 endif
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 114 if !exists('did_encoding_settings') && has('iconv')
115 let s:enc_euc = 'euc-jp'
116 let s:enc_jis = 'iso-2022-jp'
117
118 " Does iconv support JIS X 0213 ?
692abb34 » kana 2008-01-12 vim/dot.vimrc: 119 if iconv("\x87\x64\x87\x6a", 'cp932', 'euc-jisx0213') ==# "\xad\xc5\xad\xcb"
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 120 let s:enc_euc = 'euc-jisx0213,euc-jp'
121 let s:enc_jis = 'iso-2022-jp-3'
122 endif
123
124 " Make fileencodings
eafef300 » kana 2007-09-10 dot.vimrc: 125 let &fileencodings = 'ucs-bom'
e2da61a6 » kana 2007-09-10 Fix character encoding sett... 126 if &encoding !=# 'utf-8'
127 let &fileencodings = &fileencodings . ',' . 'ucs-2le'
128 let &fileencodings = &fileencodings . ',' . 'ucs-2'
129 endif
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 130 let &fileencodings = &fileencodings . ',' . s:enc_jis
131
eafef300 » kana 2007-09-10 dot.vimrc: 132 if &encoding ==# 'utf-8'
133 let &fileencodings = &fileencodings . ',' . s:enc_euc
134 let &fileencodings = &fileencodings . ',' . 'cp932'
135 elseif &encoding =~# '^euc-\%(jp\|jisx0213\)$'
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 136 let &encoding = s:enc_euc
eafef300 » kana 2007-09-10 dot.vimrc: 137 let &fileencodings = &fileencodings . ',' . 'utf-8'
138 let &fileencodings = &fileencodings . ',' . 'cp932'
139 else " cp932
140 let &fileencodings = &fileencodings . ',' . 'utf-8'
141 let &fileencodings = &fileencodings . ',' . s:enc_euc
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 142 endif
eafef300 » kana 2007-09-10 dot.vimrc: 143 let &fileencodings = &fileencodings . ',' . &encoding
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 144
145 unlet s:enc_euc
146 unlet s:enc_jis
147
148 let did_encoding_settings = 1
149 endif
150
151
eafef300 » kana 2007-09-10 dot.vimrc: 152 if $ENV_ACCESS ==# 'cygwin'
b765a4dc » kana 2007-05-05 Set proper 'termencoding' o... 153 set termencoding=cp932
eafef300 » kana 2007-09-10 dot.vimrc: 154 elseif $ENV_ACCESS ==# 'linux'
b765a4dc » kana 2007-05-05 Set proper 'termencoding' o... 155 set termencoding=euc-jp
1e8f2dd7 » kana 2007-11-17 Basic / Encoding: 156 elseif $ENV_ACCESS ==# 'colinux'
eafef300 » kana 2007-09-10 dot.vimrc: 157 set termencoding=utf-8
1e8f2dd7 » kana 2007-11-17 Basic / Encoding: 158 else " fallback
159 set termencoding= " same as 'encoding'
b765a4dc » kana 2007-05-05 Set proper 'termencoding' o... 160 endif
161
162
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 163
164
88559863 » kana 2007-10-10 Rearrange SETTINGS WHICH AR... 165 " Options "{{{2
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 166
167 if 1 < &t_Co && has('syntax')
d8fe4914 » kana 2007-04-05 BASIC SETTINGS: 168 if &term ==# 'rxvt-cygwin-native'
169 set t_Co=256
170 endif
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 171 syntax enable
172 colorscheme default
173 set background=dark
174 endif
175
176 filetype plugin indent on
177
178
1d8429d4 » kana 2007-10-04 Vim: .vimrc: BASIC SETTINGS: 179 set ambiwidth=double
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 180 set autoindent
181 set backspace=indent,eol,start
182 set backup
183 set backupcopy&
184 set backupdir=.,~/tmp
ec95550e » kana 2007-07-05 BASIC SETTINGS: 185 set backupskip&
2149f670 » kana 2007-07-09 BASIC SETTINGS ('backupskip'): 186 set backupskip+=svn-commit.tmp,svn-commit.[0-9]*.tmp
5e26906f » kana 2007-02-15 Set cinoptions. 187 set cinoptions=:0,t0,(0,W1s
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 188 set directory=.,~/tmp
189 set noequalalways
086e70b4 » kana 2007-09-21 BASIC SETTINGS: 190 set formatoptions=tcroqnlM1
e50ead64 » kana 2007-11-22 Basic / Options: 191 set formatlistpat&
7612ae3c » kana 2007-12-25 vim/dot.vimrc: 192 let &formatlistpat .= '\|^\s*[*+-]\s*'
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 193 set history=100
194 set hlsearch
ade507da » kana 2008-01-21 vim/dot.vimrc: 195 nohlsearch " To avoid (re)highlighting the last search pattern
196 " whenever $MYVIMRC is (re)loaded.
387b4985 » kana 2007-02-14 Basic settings: set grepprg... 197 set grepprg=internal
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 198 set incsearch
780ddd3f » kana 2007-10-25 Basic / Options: 199 set laststatus=2 " always show status lines.
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 200 set mouse=
201 set ruler
202 set showcmd
203 set showmode
204 set smartindent
205 set updatetime=60000
206 set title
eafef300 » kana 2007-09-10 dot.vimrc: 207 set titlestring=Vim:\ %f\ %h%r%m
4099e419 » kana 2007-09-23 r726@colinux: kana | 2007... 208 set wildmenu
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 209 set viminfo=<50,'10,h,r/a,n~/.viminfo
210
929617dd » kana 2007-10-21 Basic / Options: 211 " default 'statusline' with 'fileencoding'.
212 let &statusline = ''
a251119f » kana 2008-01-14 vim/dot.vimrc: 213 let &statusline .= '%<%f %h%m%r%w'
929617dd » kana 2007-10-21 Basic / Options: 214 let &statusline .= '%='
c3b76d8a » kana 2008-02-21 bash: New alias g=git 215 "" temporary disabled.
741790d7 » kana 2008-02-24 Vim: vimrc: Improve perform... 216 "let &statusline .= '(%{' . s:SID_PREFIX() . 'vcs_branch_name(getcwd())}) '
929617dd » kana 2007-10-21 Basic / Options: 217 let &statusline .= '[%{&fileencoding == "" ? &encoding : &fileencoding}]'
218 let &statusline .= ' %-14.(%l,%c%V%) %P'
219
d87dedaf » kana 2007-11-22 Basic / Options: 220 function! s:MyTabLine() "{{{
221 let s = ''
222
223 for i in range(1, tabpagenr('$'))
08e68c23 » kana 2008-01-23 vim/dot.vimrc: 224 let bufnrs = tabpagebuflist(i)
225 let curbufnr = bufnrs[tabpagewinnr(i) - 1] " first window, first appears
226
55bd4e49 » kana 2008-02-11 vim/dot.vimrc: 227 let no = (i <= 10 ? i-1 : '#') " display 0-origin tabpagenr.
08e68c23 » kana 2008-01-23 vim/dot.vimrc: 228 let mod = len(filter(bufnrs, 'getbufvar(v:val, "&modified")')) ? '+' : ' '
73ac2940 » kana 2008-01-22 vim/dot.vimrc: 229 let title = s:GetTabVar(i, 'title')
230 let title = len(title) ? title : fnamemodify(s:GetTabVar(i, 'cwd'), ':t')
08e68c23 » kana 2008-01-23 vim/dot.vimrc: 231 let title = len(title) ? title : fnamemodify(bufname(curbufnr),':t')
232 let title = len(title) ? title : '[No Name]'
d87dedaf » kana 2007-11-22 Basic / Options: 233
234 let s .= '%'.i.'T'
235 let s .= '%#' . (i == tabpagenr() ? 'TabLineSel' : 'TabLine') . '#'
73ac2940 » kana 2008-01-22 vim/dot.vimrc: 236 let s .= no
237 let s .= mod
238 let s .= title
d87dedaf » kana 2007-11-22 Basic / Options: 239 let s .= '%#TabLineFill#'
240 let s .= ' '
241 endfor
242
243 let s .= '%#TabLineFill#%T'
b28b2a8f » kana 2008-02-24 Vim: vimrc: Leave memo to s... 244 let s .= '%=%#TabLine#'
c365129d » kana 2008-02-25 Vim: vimrc: Revise 'tabline... 245 let s .= '| '
246 let s .= '%999X'
a6745698 » kana 2008-02-24 Vim: vimrc: Show VCS branch... 247 let branch_name = s:vcs_branch_name(getcwd())
c365129d » kana 2008-02-25 Vim: vimrc: Revise 'tabline... 248 let s .= (branch_name != '' ? branch_name : '?')
249 let s .= '%X'
d87dedaf » kana 2007-11-22 Basic / Options: 250 return s
251 endfunction "}}}
54122cc5 » kana 2007-11-22 Basic / Options: 252 let &tabline = '%!' . s:SID_PREFIX() . 'MyTabLine()'
d87dedaf » kana 2007-11-22 Basic / Options: 253
48be31de » kana 2007-07-26 Revise some comments and co... 254 " To automatically detect the width and the height of the terminal,
195a83f9 » kana 2007-02-16 Fix the layout. 255 " the followings must not be set.
256 "
0b630120 » kana 2007-02-16 Add text object for C funct... 257 " set columns=80
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 258 " set lines=25
259
260
261 let mapleader=','
b7f425a5 » kana 2007-04-19 Change <LocalLeader>: 262 let maplocalleader='.'
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 263
264
0d470d94 » kana 2007-10-10 Basic / Options: 265 " Use this group for any autocmd defined in this file.
266 augroup MyAutoCmd
267 autocmd!
268 augroup END
269
270
82a12043 » kana 2008-04-26 vim: idwintab: New 271 call idwintab#load()
272
273
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 274
275
195a83f9 » kana 2007-02-16 Fix the layout. 276
277
278
279
60783901 » kana 2007-10-10 Revise UTILITY FUNCTIONS & ... 280 " Utilities "{{{1
46d31b9f » kana 2008-02-15 vim/dot.vimrc: 281 " For per-'filetype' settings "{{{2
282 "
661b53ea » kana 2008-02-15 vim/dot.vimrc: 283 " To write a bit of customization per 'filetype', an easy way is to write some
3cb0ddfc » kana 2008-03-07 vim: vimrc: OnFileType: Upd... 284 " ":autocmd"s like "autocmd FileType c". But it doesn't match to compound
661b53ea » kana 2008-02-15 vim/dot.vimrc: 285 " 'filetype' such as "c.doxygen". So the pattern should be
3cb0ddfc » kana 2008-03-07 vim: vimrc: OnFileType: Upd... 286 " "{c,*.c,c.*,*.c.*}", but it's hard to read and to write. :OnFileType is
287 " a wrapper for ":autocmd FileType" to support to write such customization.
661b53ea » kana 2008-02-15 vim/dot.vimrc: 288 "
289 " Note: If a:filetype contains one of the following characters:
290 " * ? { } [ ]
291 " a:filetype will be treated as-is to write customization for compound
292 " 'filetype' with :OnFileType.
3cb0ddfc » kana 2008-03-07 vim: vimrc: OnFileType: Upd... 293 "
661b53ea » kana 2008-02-15 vim/dot.vimrc: 294 " Note: If a:filetype contains one or more ",", :OnFileType will be called for
295 " each ","-separated filetype in a:filetype.
46d31b9f » kana 2008-02-15 vim/dot.vimrc: 296 "
297 " FIXME: syntax highlighting and completion.
3cb0ddfc » kana 2008-03-07 vim: vimrc: OnFileType: Upd... 298 "
299 " BUGS: This doesn't work for most cases because of the limit of the maximum
300 " number of arguments to a function.
46d31b9f » kana 2008-02-15 vim/dot.vimrc: 301
302 command! -nargs=+ OnFileType call <SID>OnFileType(<f-args>)
303 function! s:OnFileType(group, filetype, ...)
304 let group = (a:group == '-' ? '' : a:group)
661b53ea » kana 2008-02-15 vim/dot.vimrc: 305 let commands = join(a:000)
306
307 let SPECIAL_CHARS = '[*?{}[\]]'
308 if a:filetype !~ SPECIAL_CHARS && a:filetype =~ ','
309 for ft in split(a:filetype, ',')
310 call s:OnFileType(group, ft, commands)
311 endfor
312 return
313 endif
314 let filetype = (a:filetype =~ SPECIAL_CHARS
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 315 \ ? a:filetype
316 \ : substitute('{x,x.*,*.x,*.x.*}', 'x', a:filetype, 'g'))
46d31b9f » kana 2008-02-15 vim/dot.vimrc: 317
318 execute 'autocmd' group 'FileType' filetype commands
319 endfunction
320
321
322
323
2fc52491 » kana 2007-12-08 Utilities / MAP: 324 " MAP: wrapper for :map variants. "{{{2
325 "
326 " :MAP {option}* {modes} {lhs} {rhs}
327 "
328 " {option}
329 " One of the following string:
330 " <echo> The mapping will be echoed on the command line.
331 " Default: not echoed.
332 " <re> The mapping will be remapped.
333 " Default: not remapped.
334 "
335 " {modes}
336 " String which consists of the following characters:
337 " c i l n o s v x
338 "
339 " {lhs}, {rhs}
340 " Same as :map.
341
342 command! -bar -complete=mapping -nargs=+ MAP call s:MAP(<f-args>)
343
344 function! s:MAP(...)
345 if !(3 <= a:0)
346 throw 'Insufficient arguments: '.string(a:000)
347 endif
348
349 let silentp = 1
350 let noremap = 1
351 let i = 0
352 while i < a:0
353 if a:000[i] ==# '<echo>'
354 let silentp = 0
355 elseif a:000[i] ==# '<re>'
356 let noremap = 0
357 else
358 break
359 endif
360 let i += 1
361 endwhile
362
41df7154 » kana 2007-12-09 Utilities / MAP: 363 let mapcommand = (noremap ? 'noremap' : 'map')
2fc52491 » kana 2007-12-08 Utilities / MAP: 364 let silentoption = (silentp ? '<silent>' : '')
365 let j = 0
41df7154 » kana 2007-12-09 Utilities / MAP: 366 let modes = a:000[i]
2fc52491 » kana 2007-12-08 Utilities / MAP: 367 while j < len(modes)
41df7154 » kana 2007-12-09 Utilities / MAP: 368 execute (modes[j] . mapcommand) silentoption join(a:000[i+1:])
2fc52491 » kana 2007-12-08 Utilities / MAP: 369 let j += 1
370 endwhile
371 endfunction
372
373
0bdec718 » kana 2008-01-13 vim/dot.vimrc: 374 autocmd MyAutoCmd FileType vim
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 375 \ syntax keyword my_vim_MAP MAP
376 \ skipwhite
377 \ nextgroup=my_vim_MAP_option,my_vim_MAP_modes,vimMapMod,vimMapLhs
378 \ | syntax match my_vim_MAP_option '<\(echo\|re\)>'
379 \ skipwhite
380 \ nextgroup=my_vim_MAP_option,my_vim_MAP_modes,vimMapMod,vimMapLhs
381 \ | syntax match my_vim_MAP_modes '\<[cilnosvx]\+\>'
382 \ skipwhite
383 \ nextgroup=vimMapMod,vimMapLhs
384 \ | highlight default link my_vim_MAP vimMap
385 \ | highlight default link my_vim_MAP_option vimUserAttrbCmplt
386 \ | highlight default link my_vim_MAP_modes vimUserAttrbKey
0bdec718 » kana 2008-01-13 vim/dot.vimrc: 387
388
2fc52491 » kana 2007-12-08 Utilities / MAP: 389
390
391 " CMapABC: support input for Alternate Built-in Commands "{{{2
59a73603 » kana 2008-02-02 vim/dot.vimrc: 392 " Memo: It's possible to implement this feature by using :cabbrev with <expr>.
393 " But it seems to be hard to reset the current definitions.
60783901 » kana 2007-10-10 Revise UTILITY FUNCTIONS & ... 394
395 let s:CMapABC_Entries = []
396 function! s:CMapABC_Add(original_pattern, alternate_name)
397 call add(s:CMapABC_Entries, [a:original_pattern, a:alternate_name])
398 endfunction
399
400
401 cnoremap <expr> <Space> <SID>CMapABC()
402 function! s:CMapABC()
403 let cmdline = getcmdline()
404 for [original_pattern, alternate_name] in s:CMapABC_Entries
405 if cmdline =~# original_pattern
406 return "\<C-u>" . alternate_name . ' '
407 endif
408 endfor
409 return ' '
410 endfunction
411
412
413
414
415 " Alternate :cd which uses 'cdpath' for completion "{{{2
416
16c5f100 » kana 2007-11-21 Commands / Per-tab current ... 417 command! -complete=customlist,<SID>CommandComplete_cdpath -nargs=1 CD
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 418 \ TabCD <args>
60783901 » kana 2007-10-10 Revise UTILITY FUNCTIONS & ... 419
420 function! s:CommandComplete_cdpath(arglead, cmdline, cursorpos)
421 return split(globpath(&cdpath, a:arglead . '*/'), "\n")
422 endfunction
423
424 call s:CMapABC_Add('^cd', 'CD')
425
426
427
428
429 " Help-related stuffs "{{{2
430
431 function! s:HelpBufWinNR()
432 let wn = 1
433 while wn <= winnr('$')
434 let bn = winbufnr(wn)
435 if getbufvar(bn, '&buftype') == 'help'
436 return [bn, wn]
437 endif
438 let wn = wn + 1
439 endwhile
440 return [-1, 0]
441 endfunction
442
443 function! s:HelpWindowClose()
444 let [help_bufnr, help_winnr] = s:HelpBufWinNR()
445 if help_bufnr == -1
446 return
447 endif
448
449 let current_winnr = winnr()
450 execute help_winnr 'wincmd w'
451 execute 'wincmd c'
452 if current_winnr < help_winnr
453 execute current_winnr 'wincmd w'
454 elseif help_winnr < current_winnr
455 execute (current_winnr-1) 'wincmd w'
456 else
457 " NOP
458 endif
459 endfunction
460
461
462
463
464 " High-level key sequences "{{{2
465
466 function! s:KeysToComplete()
06ae6e4d » kana 2008-01-13 vim/dot.vimrc: 467 if &l:filetype ==# 'vim'
60783901 » kana 2007-10-10 Revise UTILITY FUNCTIONS & ... 468 return "\<C-x>\<C-v>"
06ae6e4d » kana 2008-01-13 vim/dot.vimrc: 469 elseif strlen(&l:omnifunc)
470 return "\<C-x>\<C-o>"
60783901 » kana 2007-10-10 Revise UTILITY FUNCTIONS & ... 471 else
472 return "\<C-n>"
473 endif
474 endfunction
475
476 function! s:KeysToStopInsertModeCompletion()
477 if pumvisible()
478 return "\<C-y>"
479 else
480 return "\<Space>\<BS>"
481 endif
482 endfunction
483
484
485 function! s:KeysToEscapeCommandlineModeIfEmpty(key)
486 if getcmdline() == ''
487 return "\<Esc>"
488 else
489 return a:key
490 end
491 endfunction
492
493
8d4d8c22 » kana 2007-10-17 Key Mappings / The <Space>: 494 function! s:KeysToInsertOneCharacter()
bd03351b » kana 2007-12-29 vim/dot.vimrc: 495 Echo ModeMsg '-- INSERT (one char) --'
8d4d8c22 » kana 2007-10-17 Key Mappings / The <Space>: 496 return nr2char(getchar()) . "\<Esc>"
497 endfunction
498
499
60783901 » kana 2007-10-10 Revise UTILITY FUNCTIONS & ... 500
501
502 " :edit with specified 'fileencoding'. "{{{2
503
e63e08e5 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 504 command! -nargs=? -complete=file -bang -bar Cp932
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 505 \ edit<bang> ++enc=cp932 <args>
e63e08e5 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 506 command! -nargs=? -complete=file -bang -bar Eucjp
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 507 \ edit<bang> ++enc=euc-jp <args>
e63e08e5 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 508 command! -nargs=? -complete=file -bang -bar Iso2022jp
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 509 \ edit<bang> ++enc=iso-2022-jp <args>
e63e08e5 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 510 command! -nargs=? -complete=file -bang -bar Utf8
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 511 \ edit<bang> ++enc=utf-8 <args>
e63e08e5 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 512
513 command! -nargs=? -complete=file -bang -bar Jis Iso2022jp<bang> <args>
514 command! -nargs=? -complete=file -bang -bar Sjis Cp932<bang> <args>
60783901 » kana 2007-10-10 Revise UTILITY FUNCTIONS & ... 515
516
517
518
519 " Jump sections "{{{2
520
521 " for normal mode. a:pattern is '/regexp' or '?regexp'.
522 function! s:JumpSectionN(pattern)
523 let pattern = strpart(a:pattern, '1')
524 if strpart(a:pattern, 0, 1) == '/'
525 let flags = 'W'
526 else
527 let flags = 'Wb'
528 endif
529
530 mark '
531 let i = 0
532 while i < v:count1
533 if search(pattern, flags) == 0
534 if stridx(flags, 'b') != -1
535 normal! gg
536 else
537 normal! G
538 endif
539 break
540 endif
541 let i = i + 1
542 endwhile
543 endfunction
544
545
546 " for visual mode. a:motion is '[[', '[]', ']]' or ']['.
547 function! s:JumpSectionV(motion)
548 execute 'normal!' "gv\<Esc>"
549 execute 'normal' v:count1 . a:motion
550 let line = line('.')
551 let col = col('.')
552
553 normal! gv
554 call cursor(line, col)
555 endfunction
556
557
558 " for operator-pending mode. a:motion is '[[', '[]', ']]' or ']['.
559 function! s:JumpSectionO(motion)
560 execute 'normal' v:count1 . a:motion
561 endfunction
562
563
564
565
16c5f100 » kana 2007-11-21 Commands / Per-tab current ... 566 " Per-tab current directory "{{{2
567
568 command! -nargs=1 TabCD
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 569 \ execute 'cd' <q-args>
570 \ | let t:cwd = getcwd()
16c5f100 » kana 2007-11-21 Commands / Per-tab current ... 571
572 autocmd MyAutoCmd TabEnter *
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 573 \ if !exists('t:cwd')
574 \ | let t:cwd = getcwd()
575 \ | endif
576 \ | execute 'cd' t:cwd
16c5f100 » kana 2007-11-21 Commands / Per-tab current ... 577
578
579
580
1b973ca0 » kana 2008-01-12 vim/dot.vimrc: 581 " Window-related stuffs "{{{2
582
583 " Are the windows :split'ed and :vsplit'ed?
584 function! s:WindowsJumbledP()
585 " Calculate the terminal height by some values other than 'lines'.
586 " Don't consider about :vsplit.
587 let calculated_height = &cmdheight
588 let winid = winnr('$')
589 while 0 < winid
590 let calculated_height += 1 " statusline
591 let calculated_height += winheight(winid)
592 let winid = winid - 1
593 endwhile
594 if &laststatus == 0
595 let calculated_height -= 1
596 elseif &laststatus == 1 && winnr('$') == 1
597 let calculated_height -= 1
598 else " &laststatus == 2
599 " nothing to do
600 endif
601
602 " Calculate the terminal width by some values other than 'columns'.
603 " Don't consider about :split.
604 let calculated_width = 0
605 let winid = winnr('$')
606 while 0 < winid
607 let calculated_width += 1 " VertSplit
608 let calculated_width += winwidth(winid)
609 let winid = winid - 1
610 endwhile
611 let calculated_width -= 1
612
613 " If the windows are only :split'ed, &lines == calculated_height.
614 " If the windows are only :vsplit'ed, &columns == calculated_width.
615 " If there is only one window, both pairs are same.
616 " If the windows are :split'ed and :vsplit'ed, both pairs are different.
617 return (&lines != calculated_height) && (&columns != calculated_width)
618 endfunction
619
620
621 function! s:MoveWindowThenEqualizeIfNecessary(direction)
622 let jumbled_beforep = s:WindowsJumbledP()
623 execute 'wincmd' a:direction
624 let jumbled_afterp = s:WindowsJumbledP()
625
626 if jumbled_beforep || jumbled_afterp
627 wincmd =
628 endif
629 endfunction
630
631
55d71fe9 » kana 2008-01-12 vim/dot.vimrc: 632 function! s:MoveWindowIntoTabPage(target_tabpagenr)
633 " Move the current window into a:target_tabpagenr.
634 " If a:target_tabpagenr is 0, move into new tab page.
55bd4e49 » kana 2008-02-11 vim/dot.vimrc: 635 if a:target_tabpagenr < 0 " ignore invalid number.
636 return
637 endif
1b973ca0 » kana 2008-01-12 vim/dot.vimrc: 638 let original_tabnr = tabpagenr()
639 let target_bufnr = bufnr('')
55d71fe9 » kana 2008-01-12 vim/dot.vimrc: 640 let window_view = winsaveview()
1b973ca0 » kana 2008-01-12 vim/dot.vimrc: 641
55d71fe9 » kana 2008-01-12 vim/dot.vimrc: 642 if a:target_tabpagenr == 0
643 tabnew
f4ac71ac » kana 2008-02-12 vim/dot.vimrc: 644 tabmove " Move new tabpage at the last.
55d71fe9 » kana 2008-01-12 vim/dot.vimrc: 645 execute target_bufnr 'buffer'
646 let target_tabpagenr = tabpagenr()
647 else
648 execute a:target_tabpagenr 'tabnext'
649 let target_tabpagenr = a:target_tabpagenr
650 topleft new " FIXME: be customizable?
651 execute target_bufnr 'buffer'
652 endif
653 call winrestview(window_view)
1b973ca0 » kana 2008-01-12 vim/dot.vimrc: 654
655 execute original_tabnr 'tabnext'
656 if 1 < winnr('$')
657 close
658 else
659 enew
660 endif
661
55d71fe9 » kana 2008-01-12 vim/dot.vimrc: 662 execute target_tabpagenr 'tabnext'
1b973ca0 » kana 2008-01-12 vim/dot.vimrc: 663 endfunction
664
665
666 function! s:ScrollOtherWindow(scroll_command)
667 if winnr('$') == 1 || winnr('#') == 0
668 " Do nothing when there is only one window or no previous window.
669 Echo ErrorMsg 'There is no window to scroll.'
670 else
671 execute 'normal!' "\<C-w>p"
672 execute 'normal!' (s:Count() . a:scroll_command)
673 execute 'normal!' "\<C-w>p"
674 endif
675 endfunction
676
677
678
679
b6638a87 » kana 2008-02-24 Vim: vimrc: Improve the pla... 680 " VCS branch name "{{{2
681 " Returns the name of the current branch of the given directory.
682 " BUGS: git is only supported.
741790d7 » kana 2008-02-24 Vim: vimrc: Improve perform... 683 let s:_vcs_branch_name_cache = {} " dir_path = [branch_name, key_file_mtime]
684
685
686 function! s:vcs_branch_name(dir)
687 let cache_entry = get(s:_vcs_branch_name_cache, a:dir, 0)
688 if cache_entry is 0
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 689 \ || cache_entry[1] < getftime(s:_vcs_branch_name_key_file(a:dir))
741790d7 » kana 2008-02-24 Vim: vimrc: Improve perform... 690 unlet cache_entry
691 let cache_entry = s:_vcs_branch_name(a:dir)
692 let s:_vcs_branch_name_cache[a:dir] = cache_entry
693 endif
694
695 return cache_entry[0]
696 endfunction
697
698
699 function! s:_vcs_branch_name_key_file(dir)
700 return a:dir . '/.git/HEAD'
701 endfunction
702
703
704 function! s:_vcs_branch_name(dir)
705 let head_file = s:_vcs_branch_name_key_file(a:dir)
706 let branch_name = ''
b6638a87 » kana 2008-02-24 Vim: vimrc: Improve the pla... 707
708 if filereadable(head_file)
709 let ref_info = s:first_line(head_file)
710 if ref_info =~ '^\x\{40}$'
e1fbc681 » kana 2008-02-25 Vim: vimrc: Fix the style o... 711 let remote_refs_dir = a:dir . '/.git/refs/remotes/'
712 let remote_branches = split(glob(remote_refs_dir . '**'), "\n")
b6638a87 » kana 2008-02-24 Vim: vimrc: Improve the pla... 713 call filter(remote_branches, 's:first_line(v:val) ==# ref_info')
714 if 1 <= len(remote_branches)
e1fbc681 » kana 2008-02-25 Vim: vimrc: Fix the style o... 715 let branch_name = 'remote: '. remote_branches[0][len(remote_refs_dir):]
b6638a87 » kana 2008-02-24 Vim: vimrc: Improve the pla... 716 endif
717 else
718 let branch_name = matchlist(ref_info, '^ref: refs/heads/\(\S\+\)$')[1]
719 if branch_name == ''
720 let branch_name = ref_info
721 endif
722 endif
723 endif
724
741790d7 » kana 2008-02-24 Vim: vimrc: Improve perform... 725 return [branch_name, getftime(head_file)]
b6638a87 » kana 2008-02-24 Vim: vimrc: Improve the pla... 726 endfunction
727
728
729
730
195a83f9 » kana 2007-02-16 Fix the layout. 731 " Misc. "{{{2
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 732
e9972de3 » kana 2007-06-03 KEY MAPPINGS / Misc.: 733 function! s:ToggleBell()
734 if &visualbell
735 set novisualbell t_vb&
736 echo 'bell on'
737 else
738 set visualbell t_vb=
739 echo 'bell off'
740 endif
741 endfunction
742
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 743 function! s:ToggleOption(option_name)
744 execute 'setlocal' a:option_name.'!'
745 execute 'setlocal' a:option_name.'?'
746 endfunction
747
748
49f2d127 » kana 2007-01-21 Add utility function s:Exte... 749 function! s:ExtendHighlight(target_group, original_group, new_settings)
750 redir => resp
751 silent execute 'highlight' a:original_group
752 redir END
753 if resp =~# 'xxx cleared'
754 let original_settings = ''
755 elseif resp =~# 'xxx links to'
b244da18 » kana 2007-01-23 s:ExtendHighlight: Fix some... 756 return s:ExtendHighlight(
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 757 \ a:target_group,
758 \ substitute(resp, '\_.*xxx links to\s\+\(\S\+\)', '\1', ''),
759 \ a:new_settings
760 \ )
49f2d127 » kana 2007-01-21 Add utility function s:Exte... 761 else " xxx {key}={arg} ...
b244da18 » kana 2007-01-23 s:ExtendHighlight: Fix some... 762 let t = substitute(resp,'\_.*xxx\(\(\_s\+[^= \t]\+=[^= \t]\+\)*\)','\1','')
763 let original_settings = substitute(t, '\_s\+', ' ', 'g')
49f2d127 » kana 2007-01-21 Add utility function s:Exte... 764 endif
765
b244da18 » kana 2007-01-23 s:ExtendHighlight: Fix some... 766 silent execute 'highlight' a:target_group 'NONE'
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 767 \ '|' 'highlight' a:target_group original_settings
768 \ '|' 'highlight' a:target_group a:new_settings
49f2d127 » kana 2007-01-21 Add utility function s:Exte... 769 endfunction
770
771
f43c5ec4 » kana 2007-05-22 UTILITY FUNCTIONS & COMMAND... 772 function! s:Count(...)
773 if v:count == v:count1 " count is specified.
774 return v:count
775 else " count is not specified. (the default '' is useful for special value)
776 return a:0 == 0 ? '' : a:1
777 endif
778 endfunction
779
780 command! -nargs=* -complete=expression -range -count=0 Execute
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 781 \ call s:Execute(<f-args>)
f43c5ec4 » kana 2007-05-22 UTILITY FUNCTIONS & COMMAND... 782 function! s:Execute(...)
783 let args = []
784 for a in a:000
785 if a ==# '[count]'
786 let a = s:Count()
787 endif
788 call add(args, a)
789 endfor
790 execute join(args)
791 endfunction
792
793
ebab41d2 » kana 2007-10-04 Vim: .vimrc: 794 " like join (J), but move the next line into the cursor position.
795 function! s:JoinHere(...)
796 let adjust_spacesp = a:0 ? a:1 : 1
88ff7005 » kana 2007-09-21 s:JoinHere: 797 let pos = getpos('.')
ebab41d2 » kana 2007-10-04 Vim: .vimrc: 798 let r = @"
88ff7005 » kana 2007-09-21 s:JoinHere: 799
6b7b0c04 » kana 2007-12-26 vim/dot.vimrc: 800 if line('.') == line('$')
bd03351b » kana 2007-12-29 vim/dot.vimrc: 801 Echo ErrorMsg 'Unable to join at the bottom line.'
6b7b0c04 » kana 2007-12-26 vim/dot.vimrc: 802 return
803 endif
804
ebab41d2 » kana 2007-10-04 Vim: .vimrc: 805 if adjust_spacesp " adjust spaces between texts being joined as same as J.
806 normal! D
807 let l = @"
88ff7005 » kana 2007-09-21 s:JoinHere: 808
ebab41d2 » kana 2007-10-04 Vim: .vimrc: 809 normal! J
810
811 call append(line('.'), '')
812 call setreg('"', l, 'c')
813 normal! jpkJ
814 else " don't adjust spaces like gJ.
815 call setreg('"', getline(line('.') + 1), 'c')
816 normal! ""Pjdd
817 endif
818
819 let @" = r
88ff7005 » kana 2007-09-21 s:JoinHere: 820 call setpos('.', pos)
821 endfunction
822
823
933b1512 » kana 2007-10-10 Filetypes: 824 function! s:SetShortIndent()
825 setlocal expandtab softtabstop=2 shiftwidth=2
826 endfunction
827
828
bd03351b » kana 2007-12-29 vim/dot.vimrc: 829 command! -bar -nargs=+ -range Echo call <SID>Echo(<f-args>)
830 function! s:Echo(hl_name, ...)
831 execute 'echohl' a:hl_name
832 execute 'echo' join(a:000)
833 echohl None
834 endfunction
835
836
73ac2940 » kana 2008-01-22 vim/dot.vimrc: 837 function! s:GetTabVar(tabnr, varname)
838 " Wrapper for non standard (my own) built-in function gettabvar().
839 return exists('*gettabvar') ? gettabvar(a:tabnr, a:varname) : ''
840 endfunction
841
842
ebaa9c68 » kana 2008-04-14 vim: vimrc: Modify :UsualDa... 843 command! -bar -nargs=? TabTitle
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 844 \ if <q-args> == ''
845 \ | let t:title = input("Set tabpage's title to: ",'')
846 \ | else
847 \ | let t:title = <q-args>
848 \ | endif
aab101ef » kana 2008-01-22 vim/dot.vimrc: 849
850
f93dcf39 » kana 2008-02-02 vim/dot.vimrc: 851 " Set up the layout of my usual days.
852 command! -bar -nargs=0 UsualDays call s:UsualDays()
853 function! s:UsualDays()
854 normal! 'T
855 execute 'CD' fnamemodify(expand('%'), ':p:h')
ebaa9c68 » kana 2008-04-14 vim: vimrc: Modify :UsualDa... 856 TabTitle meta
f93dcf39 » kana 2008-02-02 vim/dot.vimrc: 857
858 tabnew
859 normal! 'V
860 execute 'CD' fnamemodify(expand('%'), ':p:h:h')
ebaa9c68 » kana 2008-04-14 vim: vimrc: Modify :UsualDa... 861 TabTitle config
f93dcf39 » kana 2008-02-02 vim/dot.vimrc: 862 endfunction
863
864
4b7fc36c » kana 2008-02-11 vim/dot.vimrc: 865 " :source with echo.
866 command! -bar -nargs=1 Source echo 'Sourcing ...' <args> | source <args>
867
868
c3b76d8a » kana 2008-02-21 bash: New alias g=git 869 function! s:first_line(file)
870 let lines = readfile(a:file, '', 1)
871 return 1 <= len(lines) ? lines[0] : ''
872 endfunction
873
874
195a83f9 » kana 2007-02-16 Fix the layout. 875
876
877
878
879
880
ee2fb8d1 » kana 2008-05-04 vim: vimrc: Update some ite... 881 " Mappings "{{{1
792cc7d6 » kana 2007-10-10 Add some FIXMEs. 882 " FIXME: many {rhs}s use : without <C-u> (clearing count effect).
883 " FIXME: some mappings are not countable.
41fad213 » kana 2008-04-17 vim: vimrc: Fix the layout ... 884 " Physical/Logical keyboard layout declaration "{{{2
885 "
886 " :KeyLayout {physical-key} {logical-key}
887 " Declare that whenever Vim gets a character {logical-key}, the
888 " corresponding physical key is {physical-key}. This declaration will be
889 " used to map based on physical keyboard layout. To map {rhs} to a physical
890 " key {X}, use 'noremap <Plug>(physical-key-{X}) {rhs}'.
891
892 command! -nargs=+ KeyLayout call s:KeyLayout(<f-args>)
893 function! s:KeyLayout(physical_key, logical_key)
894 let indirect_key = '<Plug>(physical-key-' . a:physical_key . ')'
895 execute 'Allmap' a:logical_key indirect_key
896 execute 'Allnoremap' indirect_key a:logical_key
897 endfunction
898 command! -nargs=+ Allmap
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 899 \ execute 'map' <q-args>
900 \ | execute 'map!' <q-args>
41fad213 » kana 2008-04-17 vim: vimrc: Fix the layout ... 901 command! -nargs=+ Allnoremap
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 902 \ execute 'noremap' <q-args>
903 \ | execute 'noremap!' <q-args>
41fad213 » kana 2008-04-17 vim: vimrc: Fix the layout ... 904 command! -nargs=+ Allunmap
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 905 \ execute 'silent! unmap' <q-args>
906 \ | execute 'silent! unmap!' <q-args>
41fad213 » kana 2008-04-17 vim: vimrc: Fix the layout ... 907
908
909 if $ENV_WORKING ==# 'mac' || $USER ==# 'kecak'
910 " On my MacBook, Semicolon and Return are swapped by KeyRemap4MacBook.
911 " On u machines, these keys are swapped by Mayu.
912 KeyLayout ; <Return>
913 KeyLayout : <S-Return>
914 KeyLayout <Return> ;
915 KeyLayout <S-Return> :
916 else
917 KeyLayout ; ;
918 KeyLayout : :
919 KeyLayout <Return> <Return>
920 KeyLayout <S-Return> <S-Return>
921 endif
922
923
924
925
b44c6353 » kana 2007-10-10 Key Mappings / Tag-related ... 926 " Tag jumping "{{{2
f2552813 » kana 2007-10-10 Key Mappings / Tag jumping: 927 " FIXME: the target window of :split/:vsplit version.
7ae3d3dd » kana 2007-03-03 Key mappings (Tag-related h... 928 " Fallback "{{{3
929
930 " ``T'' is also disabled for consistency.
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 931 noremap t <Nop>
932 noremap T <Nop>
7ae3d3dd » kana 2007-03-03 Key mappings (Tag-related h... 933
934 " Alternatives for the original actions.
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 935 noremap [Space]t t
936 noremap [Space]T T
7ae3d3dd » kana 2007-03-03 Key mappings (Tag-related h... 937
938
b44c6353 » kana 2007-10-10 Key Mappings / Tag-related ... 939 " Basic "{{{3
940
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 941 nnoremap tt <C-]>
942 vnoremap tt <C-]>
943 nnoremap <silent> tj :<C-u>tag<Return>
944 nnoremap <silent> tk :<C-u>pop<Return>
945 nnoremap <silent> tl :<C-u>tags<Return>
946 nnoremap <silent> tn :<C-u>tnext<Return>
947 nnoremap <silent> tp :<C-u>tprevious<Return>
948 nnoremap <silent> tP :<C-u>tfirst<Return>
949 nnoremap <silent> tN :<C-u>tlast<Return>
7ae3d3dd » kana 2007-03-03 Key mappings (Tag-related h... 950
c8c91080 » kana 2008-01-12 vim/dot.vimrc: 951 " additions, like Web browsers
ba6366d1 » kana 2008-04-11 vim: vimrc: Fix all {lhs} t... 952 nmap <Plug>(physical-key-<Return>) tt
953 vmap <Plug>(physical-key-<Return>) tt
7ae3d3dd » kana 2007-03-03 Key mappings (Tag-related h... 954
c8c91080 » kana 2008-01-12 vim/dot.vimrc: 955 " addition, interactive use.
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 956 nnoremap t<Space> :<C-u>tag<Space>
c8c91080 » kana 2008-01-12 vim/dot.vimrc: 957
7ae3d3dd » kana 2007-03-03 Key mappings (Tag-related h... 958
b44c6353 » kana 2007-10-10 Key Mappings / Tag-related ... 959 " With the preview window "{{{3
960
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 961 nnoremap t't <C-w>}
962 vnoremap t't <C-w>}
963 nnoremap <silent> t'n :<C-u>ptnext<Return>
964 nnoremap <silent> t'p :<C-u>ptpevious<Return>
965 nnoremap <silent> t'P :<C-u>ptfirst<Return>
966 nnoremap <silent> t'N :<C-u>ptlast<Return>
7ae3d3dd » kana 2007-03-03 Key mappings (Tag-related h... 967
968 " although :pclose is not related to tag.
5c117084 » kana 2008-01-17 vim/dot.vimrc: 969 " BUGS: t'' is not related to the default meaning of ''.
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 970 nnoremap <silent> t'c :<C-u>pclose<Return>
971 nmap t'z t'c
972 nmap t'' t'c
7ae3d3dd » kana 2007-03-03 Key mappings (Tag-related h... 973
974
975 " With :split "{{{3
b44c6353 » kana 2007-10-10 Key Mappings / Tag-related ... 976
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 977 nnoremap tst <C-w>]
978 vnoremap tst <C-w>]
979 nnoremap <silent> tsn :<C-u>split \| tnext<Return>
980 nnoremap <silent> tsp :<C-u>split \| tpevious<Return>
981 nnoremap <silent> tsP :<C-u>split \| tfirst<Return>
982 nnoremap <silent> tsN :<C-u>split \| tlast<Return>
7ae3d3dd » kana 2007-03-03 Key mappings (Tag-related h... 983
984
985 " With :vertical split "{{{3
b44c6353 » kana 2007-10-10 Key Mappings / Tag-related ... 986
2006f11d » kana 2007-03-03 Key mappings (Tag-related h... 987 " |:vsplit|-then-|<C-]>| is simple
988 " but its modification to tag stacks is not same as |<C-w>]|.
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 989 nnoremap <silent> tvt <C-]>:<C-u>vsplit<Return><C-w>p<C-t><C-w>p
990 vnoremap <silent> tvt <C-]>:<C-u>vsplit<Return><C-w>p<C-t><C-w>p
991 nnoremap <silent> tvn :<C-u>vsplit \| tnext<Return>
992 nnoremap <silent> tvp :<C-u>vsplit \| tpevious<Return>
993 nnoremap <silent> tvP :<C-u>vsplit \| tfirst<Return>
994 nnoremap <silent> tvN :<C-u>vsplit \| tlast<Return>
7ae3d3dd » kana 2007-03-03 Key mappings (Tag-related h... 995
996
997
998
a8b99bc4 » kana 2007-10-10 Key Mappings / Quickfix hot... 999 " Quickfix "{{{2
1000 " Fallback "{{{3
1001
1002 " the prefix key.
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1003 nnoremap q <Nop>
ea54ec4d » kana 2007-02-26 Key mappings (Quickfix hotk... 1004
a8b99bc4 » kana 2007-10-10 Key Mappings / Quickfix hot... 1005 " alternative key for the original action.
1006 " -- Ex-mode will be never used and recordings are rarely used.
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1007 nnoremap Q q
a8b99bc4 » kana 2007-10-10 Key Mappings / Quickfix hot... 1008
1009
1010 " For quickfix list "{{{3
1011
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1012 nnoremap <silent> qj :Execute cnext [count]<Return>
1013 nnoremap <silent> qk :Execute cprevious [count]<Return>
1014 nnoremap <silent> qr :Execute crewind [count]<Return>
1015 nnoremap <silent> qK :Execute cfirst [count]<Return>
1016 nnoremap <silent> qJ :Execute clast [count]<Return>
1017 nnoremap <silent> qfj :Execute cnfile [count]<Return>
1018 nnoremap <silent> qfk :Execute cpfile [count]<Return>
1019 nnoremap <silent> ql :<C-u>clist<Return>
1020 nnoremap <silent> qq :Execute cc [count]<Return>
1021 nnoremap <silent> qo :Execute copen [count]<Return>
1022 nnoremap <silent> qc :<C-u>cclose<Return>
1023 nnoremap <silent> qp :Execute colder [count]<Return>
1024 nnoremap <silent> qn :Execute cnewer [count]<Return>
1025 nnoremap <silent> qm :<C-u>make<Return>
1026 nnoremap qM :<C-u>make<Space>
1027 nnoremap q<Space> :<C-u>make<Space>
1028 nnoremap qg :<C-u>grep<Space>
ea54ec4d » kana 2007-02-26 Key mappings (Quickfix hotk... 1029
a8b99bc4 » kana 2007-10-10 Key Mappings / Quickfix hot... 1030
1031 " For location list (mnemonic: Quickfix list for the current Window) "{{{3
1032
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1033 nnoremap <silent> qwj :Execute lnext [count]<Return>
1034 nnoremap <silent> qwk :Execute lprevious [count]<Return>
1035 nnoremap <silent> qwr :Execute lrewind [count]<Return>
1036 nnoremap <silent> qwK :Execute lfirst [count]<Return>
1037 nnoremap <silent> qwJ :Execute llast [count]<Return>
1038 nnoremap <silent> qwfj :Execute lnfile [count]<Return>
1039 nnoremap <silent> qwfk :Execute lpfile [count]<Return>
1040 nnoremap <silent> qwl :<C-u>llist<Return>
1041 nnoremap <silent> qwq :Execute ll [count]<Return>
1042 nnoremap <silent> qwo :Execute lopen [count]<Return>
1043 nnoremap <silent> qwc :<C-u>lclose<Return>
1044 nnoremap <silent> qwp :Execute lolder [count]<Return>
1045 nnoremap <silent> qwn :Execute lnewer [count]<Return>
1046 nnoremap <silent> qwm :<C-u>lmake<Return>
1047 nnoremap qwM :<C-u>lmake<Space>
1048 nnoremap qw<Space> :<C-u>lmake<Space>
1049 nnoremap qwg :<C-u>lgrep<Space>
dc1c4a00 » kana 2007-02-15 Add key mappings for quickf... 1050
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 1051
195a83f9 » kana 2007-02-16 Fix the layout. 1052
1053
51c76703 » kana 2007-10-10 Key Mappings / Tab-pages ho... 1054 " Tab pages "{{{2
1055 " The mappings defined here are similar to the ones for windows.
205b649f » kana 2007-05-22 KEY MAPPINGS / Tab-pages ho... 1056 " FIXME: sometimes, hit-enter prompt appears. but no idea for the reason.
51c76703 » kana 2007-10-10 Key Mappings / Tab-pages ho... 1057 " Fallback "{{{3
1058
1059 " the prefix key.
1060 " -- see Tag jumping subsection for alternative keys for the original action
1061 " of <C-t>.
205b649f » kana 2007-05-22 KEY MAPPINGS / Tab-pages ho... 1062 nnoremap <C-t> <Nop>
1063
51c76703 » kana 2007-10-10 Key Mappings / Tab-pages ho... 1064
1065 " Basic "{{{3
1066
f4ac71ac » kana 2008-02-12 vim/dot.vimrc: 1067 " Move new tabpage at the last.
1068 nnoremap <silent> <C-t>n :<C-u>tabnew \| tabmove<Return>
bc03e7c8 » kana 2008-01-12 vim/dot.vimrc: 1069 nnoremap <silent> <C-t>c :<C-u>tabclose<Return>
1070 nnoremap <silent> <C-t>o :<C-u>tabonly<Return>
1071 nnoremap <silent> <C-t>i :<C-u>tabs<Return>
205b649f » kana 2007-05-22 KEY MAPPINGS / Tab-pages ho... 1072
1073 nmap <C-t><C-n> <C-t>n
1074 nmap <C-t><C-c> <C-t>c
1075 nmap <C-t><C-o> <C-t>o
1076 nmap <C-t><C-i> <C-t>i
1077
aab101ef » kana 2008-01-22 vim/dot.vimrc: 1078 nnoremap <silent> <C-t>T :<C-u>TabTitle<Return>
1079
205b649f » kana 2007-05-22 KEY MAPPINGS / Tab-pages ho... 1080
1081 " Moving around tabs. "{{{3
51c76703 » kana 2007-10-10 Key Mappings / Tab-pages ho... 1082
bc03e7c8 » kana 2008-01-12 vim/dot.vimrc: 1083 nnoremap <silent> <C-t>j :<C-u>execute 'tabnext'
1084 \ 1 + (tabpagenr() + v:count1 - 1) % tabpagenr('$')
1085 \<Return>
1086 nnoremap <silent> <C-t>k :Execute tabprevious [count]<Return>
1087 nnoremap <silent> <C-t>K :<C-u>tabfirst<Return>
1088 nnoremap <silent> <C-t>J :<C-u>tablast<Return>
205b649f » kana 2007-05-22 KEY MAPPINGS / Tab-pages ho... 1089
1090 nmap <C-t><C-j> <C-t>j
1091 nmap <C-t><C-k> <C-t>k
aab101ef » kana 2008-01-22 vim/dot.vimrc: 1092 nmap <C-t><C-t> <C-t>j
205b649f » kana 2007-05-22 KEY MAPPINGS / Tab-pages ho... 1093
d671d479 » kana 2008-01-19 vim/dot.vimrc: 1094 " GNU screen like mappings.
55bd4e49 » kana 2008-02-11 vim/dot.vimrc: 1095 " Note that the numbers in {lhs}s are 0-origin. See also 'tabline'.
d671d479 » kana 2008-01-19 vim/dot.vimrc: 1096 for i in range(10)
1097 execute 'nnoremap <silent>' ('<C-t>'.(i)) ((i+1).'gt')
1098 endfor
1099 unlet i
1100
205b649f » kana 2007-05-22 KEY MAPPINGS / Tab-pages ho... 1101
1102 " Moving tabs themselves. "{{{3
51c76703 » kana 2007-10-10 Key Mappings / Tab-pages ho... 1103
bc03e7c8 » kana 2008-01-12 vim/dot.vimrc: 1104 nnoremap <silent> <C-t>l :<C-u>execute 'tabmove'
1105 \ min([tabpagenr() + v:count1 - 1, tabpagenr('$')])
1106 \<Return>
1107 nnoremap <silent> <C-t>h :<C-u>execute 'tabmove'
1108 \ max([tabpagenr() - v:count1 - 1, 0])
1109 \<Return>
1110 nnoremap <silent> <C-t>L :<C-u>tabmove<Return>
1111 nnoremap <silent> <C-t>H :<C-u>tabmove 0<Return>
205b649f » kana 2007-05-22 KEY MAPPINGS / Tab-pages ho... 1112
1113 nmap <C-t><C-l> <C-t>l
1114 nmap <C-t><C-h> <C-t>h
1115
1116
1117
1118
067981b3 » kana 2008-03-13 vim: vimrc: Add mapings for... 1119 " Argument list "{{{2
1120
1121 " the prefix key.
1122 " -- the default action of <C-g> is almost never used.
1123 nnoremap <C-g> <Nop>
1124
1125
1126 nnoremap <C-g><Space> :<C-u>args<Space>
1127 nnoremap <silent> <C-g>l :<C-u>args<Return>
1128 nnoremap <silent> <C-g>j :<C-u>next<Return>
1129 nnoremap <silent> <C-g>k :<C-u>previous<Return>
1130 nnoremap <silent> <C-g>J :<C-u>last<Return>
1131 nnoremap <silent> <C-g>K :<C-u>first<Return>
1132 nnoremap <silent> <C-g>wj :<C-u>wnext<Return>
1133 nnoremap <silent> <C-g>wk :<C-u>wprevious<Return>
1134
1135 nmap <C-g><C-l> <C-g>l
1136 nmap <C-g><C-j> <C-g>j
1137 nmap <C-g><C-k> <C-g>k
1138 nmap <C-g><C-w><C-j> <C-g>wj
1139 nmap <C-g><C-w><C-k> <C-g>wk
1140
1141
1142
1143
75a92eab » kana 2007-10-10 Key Mappings / For command-... 1144 " Command-line editting "{{{2
48be31de » kana 2007-07-26 Revise some comments and co... 1145
369f7c4c » kana 2007-09-26 r740@colinux (orig r224): ... 1146 " pseudo vi-like keys
a3a0414f » kana 2007-02-16 Fix style: separate lhs and... 1147 cnoremap <Esc>h <Left>
1148 cnoremap <Esc>j <Down>
1149 cnoremap <Esc>k <Up>
1150 cnoremap <Esc>l <Right>
1151 cnoremap <Esc>H <Home>
1152 cnoremap <Esc>L <End>
1153 cnoremap <Esc>w <S-Right>
1154 cnoremap <Esc>b <S-Left>
1155 cnoremap <Esc>x <Del>
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 1156
369f7c4c » kana 2007-09-26 r740@colinux (orig r224): ... 1157 " escape Command-line mode if the command line is empty (like <C-h>)
1158 cnoremap <expr> <C-u> <SID>KeysToEscapeCommandlineModeIfEmpty("\<C-u>")
1159 cnoremap <expr> <C-w> <SID>KeysToEscapeCommandlineModeIfEmpty("\<C-w>")
1160
fc25b38b » kana 2007-10-10 Key Mappings / Command-line... 1161 " Search slashes easily (too lazy to prefix backslashes to slashes)
1162 cnoremap <expr> / getcmdtype() == '/' ? '\/' : '/'
1163
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 1164
195a83f9 » kana 2007-02-16 Fix the layout. 1165
1166
81c10af2 » kana 2007-10-10 Key Mappings / Input: datet... 1167 " Input: datetime "{{{2
1168 "
1169 " Input the current date/time (Full, Date, Time).
1170 "
1171 " FIXME: use timezone of the system, instead of static one.
a4ff89a0 » kana 2008-01-12 vim/dot.vimrc: 1172 " FIXME: revise the {lhs}s, compare with the default keys of textobj-datetime.
48be31de » kana 2007-07-26 Revise some comments and co... 1173
ff8f7036 » kana 2007-02-16 Fix style: write control ke... 1174 inoremap <Leader>dF <C-r>=strftime('%Y-%m-%dT%H:%M:%S+09:00')<Return>
1175 inoremap <Leader>df <C-r>=strftime('%Y-%m-%dT%H:%M:%S')<Return>
1176 inoremap <Leader>dd <C-r>=strftime('%Y-%m-%d')<Return>
1177 inoremap <Leader>dT <C-r>=strftime('%H:%M:%S')<Return>
1178 inoremap <Leader>dt <C-r>=strftime('%H:%M')<Return>
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 1179
1180
195a83f9 » kana 2007-02-16 Fix the layout. 1181
1182
685d1646 » kana 2007-10-10 Key Mappings / Section jump... 1183 " Section jumping "{{{2
1184 "
1185 " Enable *consistent* ]] and other motions in Visual and Operator-pending
a4ff89a0 » kana 2008-01-12 vim/dot.vimrc: 1186 " mode. Because some ftplugins provide these motions only for Normal mode and
1187 " other ftplugins provide these motions with some faults, e.g., not countable.
48be31de » kana 2007-07-26 Revise some comments and co... 1188
ff8f7036 » kana 2007-02-16 Fix style: write control ke... 1189 vnoremap <silent> ]] :<C-u>call <SID>JumpSectionV(']]')<Return>
1190 vnoremap <silent> ][ :<C-u>call <SID>JumpSectionV('][')<Return>
1191 vnoremap <silent> [[ :<C-u>call <SID>JumpSectionV('[[')<Return>
1192 vnoremap <silent> [] :<C-u>call <SID>JumpSectionV('[]')<Return>
1193 onoremap <silent> ]] :<C-u>call <SID>JumpSectionO(']]')<Return>
1194 onoremap <silent> ][ :<C-u>call <SID>JumpSectionO('][')<Return>
1195 onoremap <silent> [[ :<C-u>call <SID>JumpSectionO('[[')<Return>
1196 onoremap <silent> [] :<C-u>call <SID>JumpSectionO('[]')<Return>
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 1197
1198
1199
1200
cc915f0d » kana 2007-10-10 Key Mappings / The <Space>: 1201 " The <Space> "{{{2
1202 "
57d0ad0f » kana 2007-10-10 Revise KEY MAPPINGS section: 1203 " Various hotkeys prefixed by <Space>.
cc915f0d » kana 2007-10-10 Key Mappings / The <Space>: 1204
1205 " to show <Space> in the bottom line.
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1206 map <Space> [Space]
57d0ad0f » kana 2007-10-10 Revise KEY MAPPINGS section: 1207
cc915f0d » kana 2007-10-10 Key Mappings / The <Space>: 1208 " fallback
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1209 noremap [Space] <Nop>
cc915f0d » kana 2007-10-10 Key Mappings / The <Space>: 1210
1211
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1212 nnoremap <silent> [Space]/ :<C-u>nohlsearch<Return>
cc915f0d » kana 2007-10-10 Key Mappings / The <Space>: 1213
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1214 nnoremap <silent> [Space]? :<C-u>call <SID>HelpWindowClose()<Return>
cc915f0d » kana 2007-10-10 Key Mappings / The <Space>: 1215
05d3a3da » kana 2008-01-12 vim/dot.vimrc: 1216 " append one character
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1217 nnoremap [Space]A A<C-r>=<SID>KeysToInsertOneCharacter()<Return>
1218 nnoremap [Space]a a<C-r>=<SID>KeysToInsertOneCharacter()<Return>
cc915f0d » kana 2007-10-10 Key Mappings / The <Space>: 1219
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1220 nnoremap <silent> [Space]e :<C-u>setlocal enc? tenc? fenc? fencs?<Return>
1221 nnoremap <silent> [Space]f :<C-u>setlocal ft? fenc? ff?<Return>
cc915f0d » kana 2007-10-10 Key Mappings / The <Space>: 1222
05d3a3da » kana 2008-01-12 vim/dot.vimrc: 1223 " insert one character
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1224 nnoremap [Space]I I<C-r>=<SID>KeysToInsertOneCharacter()<Return>
1225 nnoremap [Space]i i<C-r>=<SID>KeysToInsertOneCharacter()<Return>
cc915f0d » kana 2007-10-10 Key Mappings / The <Space>: 1226
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1227 nnoremap <silent> [Space]J :<C-u>call <SID>JoinHere(1)<Return>
05d3a3da » kana 2008-01-12 vim/dot.vimrc: 1228 nnoremap <silent> [Space]gJ :<C-u>call <SID>JoinHere(0)<Return>
cc915f0d » kana 2007-10-10 Key Mappings / The <Space>: 1229
05d3a3da » kana 2008-01-12 vim/dot.vimrc: 1230 " unjoin " BUGS: side effect - destroy the last inserted text (".).
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1231 nnoremap [Space]j i<Return><Esc>
cc915f0d » kana 2007-10-10 Key Mappings / The <Space>: 1232
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1233 nnoremap <silent> [Space]m :<C-u>marks<Return>
1ebd5ad7 » kana 2008-01-13 vim/dot.vimrc: 1234
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1235 nnoremap [Space]o <Nop>
05d3a3da » kana 2008-01-12 vim/dot.vimrc: 1236 nnoremap <silent> [Space]ob :<C-u>call <SID>ToggleBell()<Return>
1237 nnoremap <silent> [Space]ow :<C-u>call <SID>ToggleOption('wrap')<Return>
cc915f0d » kana 2007-10-10 Key Mappings / The <Space>: 1238
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1239 nnoremap <silent> [Space]q :<C-u>help quickref<Return>
cc915f0d » kana 2007-10-10 Key Mappings / The <Space>: 1240
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1241 nnoremap <silent> [Space]r :<C-u>registers<Return>
cc915f0d » kana 2007-10-10 Key Mappings / The <Space>: 1242
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1243 nnoremap [Space]s <Nop>
4b7fc36c » kana 2008-02-11 vim/dot.vimrc: 1244 nnoremap <silent> [Space]s. :<C-u>Source $MYVIMRC<Return>
1245 nnoremap <silent> [Space]ss :<C-u>Source %<Return>
cc915f0d » kana 2007-10-10 Key Mappings / The <Space>: 1246
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1247 vnoremap <silent> [Space]s :sort<Return>
57d0ad0f » kana 2007-10-10 Revise KEY MAPPINGS section: 1248
05d3a3da » kana 2008-01-12 vim/dot.vimrc: 1249 " for backward compatibility
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1250 nmap [Space]w [Space]ow
05d3a3da » kana 2008-01-12 vim/dot.vimrc: 1251
1252 " for other use.
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1253 noremap [Space]x <Nop>
35338586 » kana 2007-12-27 vim/dot.vimrc: 1254
57d0ad0f » kana 2007-10-10 Revise KEY MAPPINGS section: 1255
cc915f0d » kana 2007-10-10 Key Mappings / The <Space>: 1256
1257
2b2b6d8d » kana 2007-10-17 Key Mappings / Windows: 1258 " Windows "{{{2
1259
f74349c0 » kana 2007-10-26 Utilities / Misc.: 1260 " Synonyms for the default mappings, with single key strokes.
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1261 nmap <Tab> <C-i>
1262 nmap <S-Tab> <Esc>i
1263 nnoremap <C-i> <C-w>w
1264 nnoremap <Esc>i <C-w>W
fdb133d3 » kana 2007-11-17 Key Mappings / Windows: 1265 " For other mappings (<Esc>{x} to <C-w>{x}).
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1266 nmap <Esc> <C-w>
fdb133d3 » kana 2007-11-17 Key Mappings / Windows: 1267
2b2b6d8d » kana 2007-10-17 Key Mappings / Windows: 1268
451b030a » kana 2008-01-12 vim/dot.vimrc: 1269 for i in ['H', 'J', 'K', 'L']
1270 execute 'nnoremap <silent> <Esc>'.i
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1271 \ ':<C-u>call <SID>MoveWindowThenEqualizeIfNecessary("'.i.'")<Return>'
451b030a » kana 2008-01-12 vim/dot.vimrc: 1272 endfor
1273 unlet i
1274
fdb133d3 » kana 2007-11-17 Key Mappings / Windows: 1275
451b030a » kana 2008-01-12 vim/dot.vimrc: 1276 " This {lhs} overrides the default action (Move cursor to top-left window).
1277 " But I rarely use its {lhs}s, so this mapping is not problematic.
55d71fe9 » kana 2008-01-12 vim/dot.vimrc: 1278 nnoremap <silent> <C-w><C-t>
55bd4e49 » kana 2008-02-11 vim/dot.vimrc: 1279 \ :<C-u>call <SID>MoveWindowIntoTabPage(<SID>AskTabPageNumber())<Return>
1280 function! s:AskTabPageNumber()
1281 echon 'Which tabpage to move this window into? '
1282
1283 let c = nr2char(getchar())
1284 if c =~# '[0-9]'
1285 " Convert 0-origin number (typed by user) into 1-origin number (used by
1286 " Vim's internal functions). See also 'tabline'.
1287 return 1 + char2nr(c) - char2nr('0')
1288 elseif c =~# "[\<C-c>\<Esc>]"
1289 return -1
1290 else
1291 return 0
1292 endif
1293 endfunction
fdb133d3 » kana 2007-11-17 Key Mappings / Windows: 1294
f74349c0 » kana 2007-10-26 Utilities / Misc.: 1295
451b030a » kana 2008-01-12 vim/dot.vimrc: 1296 " like GNU Emacs' (scroll-other-window),
1297 " but the target to scroll is the previous window.
75cd3f25 » kana 2007-12-29 vim/dot.vimrc: 1298 for i in ['f', 'b', 'd', 'u', 'e', 'y']
1299 execute 'nnoremap <silent> <Esc><C-'.i.'>'
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1300 \ ':<C-u>call <SID>ScrollOtherWindow("<Bslash><LT>C-'.i.'>")<Return>'
75cd3f25 » kana 2007-12-29 vim/dot.vimrc: 1301 endfor
1302 unlet i
1303
f74349c0 » kana 2007-10-26 Utilities / Misc.: 1304
1f58eadb » kana 2008-03-21 vim: vimrc: Add operator ve... 1305 " Adjust the height of the current window as same as the selected range.
a10f9091 » kana 2008-03-21 vim: vimrc: Move a key mapp... 1306 vnoremap <silent> _
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1307 \ <Esc>:execute (line("'>") - line("'<") + 1) 'wincmd' '_'<Return>`<zt
1f58eadb » kana 2008-03-21 vim: vimrc: Add operator ve... 1308 nnoremap <silent> _
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1309 \ :set operatorfunc=<SID>AdjustWindowHeightToTheSelection<Return>g@
1f58eadb » kana 2008-03-21 vim: vimrc: Add operator ve... 1310 function! s:AdjustWindowHeightToTheSelection(visual_mode)
1311 normal! `[v`]
1312 normal _
1313 endfunction
a10f9091 » kana 2008-03-21 vim: vimrc: Move a key mapp... 1314
1315
f7ffdc65 » kana 2008-04-24 vim: vimrc: Add "<C-w>Q" to... 1316 " Like "<C-w>q", but does ":quit!".
1317 nnoremap <C-w>Q :<C-u>quit!<Return>
1318
1319
2b2b6d8d » kana 2007-10-17 Key Mappings / Windows: 1320
1321
cc915f0d » kana 2007-10-10 Key Mappings / The <Space>: 1322 " Misc. "{{{2
1323
1324 nnoremap <C-h> :h<Space>
1325 nnoremap <C-o> :e<Space>
1326 nnoremap <C-w>. :e .<Return>
1327
1328
57d0ad0f » kana 2007-10-10 Revise KEY MAPPINGS section: 1329 " Jump list
1330 nnoremap <C-j> <C-i>
1331 nnoremap <C-k> <C-o>
1332
1333
1334 " Switch to the previously edited file (like Vz)
1335 nnoremap <Esc>2 :e #<Return>
1336 nmap <F2> <Esc>2
1337
1338
efd32a63 » kana 2008-04-09 vim: vimrc: Fix hacks on se... 1339 " Lazy man's hacks on the Semicolon key.
ce47e7d2 » kana 2008-04-11 vim: Add the layer to abstr... 1340 " - Don't want to press Shift to enter the Command-line mode.
1341 " - Don't want to press far Return key to input <Return>.
1342 noremap <Plug>(physical-key-;) :
1343 noremap <Plug>(physical-key-:) ;
1344 noremap <Plug>(physical-key-<Return>) <Return>
1345 noremap <Plug>(physical-key-<S-Return>) <S-Return>
1346 noremap! <Plug>(physical-key-;) <Return>
1347 noremap! <Plug>(physical-key-:) <S-Return>
1348 noremap! <Plug>(physical-key-<Return>) ;
1349 noremap! <Plug>(physical-key-<S-Return>) :
57d0ad0f » kana 2007-10-10 Revise KEY MAPPINGS section: 1350
1351
1352 " Disable some dangerous key.
1353 nnoremap ZZ <Nop>
1354 nnoremap ZQ <Nop>
1355
1356
1357 " Use a backslash (\) to repeat last change.
1358 " Since a dot (.) is used as <LocalLeader>.
1359 nnoremap \ .
1360
1361
1362 " Complete or indent.
1363 inoremap <expr> <C-i> (<SID>ShouldIndentRatherThanCompleteP()
1364 \ ? '<C-i>'
1365 \ : <SID>KeysToComplete())
1366
1367 function! s:ShouldIndentRatherThanCompleteP()
1368 let m = match(getline('.'), '\S')
1369 return m == -1 || col('.')-1 <= m
1370 endfunction
1371
1372
1373 " Swap ` and ' -- I prefer ` to ' and ` is not easy to type.
eef0b1c1 » kana 2007-11-13 Key Mappings / Misc.: 1374 " <SID>jump-default and <SID>jump-another are the name for these actions
1375 " to use other places in this file.
1376 map ' <SID>jump-default
1377 map ` <SID>jump-another
1378 noremap <SID>jump-default `
1379 noremap <SID>jump-another '
57d0ad0f » kana 2007-10-10 Revise KEY MAPPINGS section: 1380
1381
1382 " To be able to undo these types of deletion in Insert mode.
1383 inoremap <C-w> <C-g>u<C-w>
1384 inoremap <C-u> <C-g>u<C-u>
1385
1386
1387 " Search the word nearest to the cursor in new window.
1388 nnoremap <C-w>* <C-w>s*
1389 nnoremap <C-w># <C-g>s#
1390
1391
1d22b6d9 » kana 2007-10-13 Key Mappings / Misc.: 1392 " Synonyms for <> and [], same as plugin surround.
b5f5bab4 » kana 2007-11-13 Key Mappings / Misc.: 1393 onoremap aa a>
1394 onoremap ia i>
1d22b6d9 » kana 2007-10-13 Key Mappings / Misc.: 1395 vnoremap aa a>
1396 vnoremap ia i>
1397
b5f5bab4 » kana 2007-11-13 Key Mappings / Misc.: 1398 onoremap ar a]
1399 onoremap ir i]
1d22b6d9 » kana 2007-10-13 Key Mappings / Misc.: 1400 vnoremap ar a]
1401 vnoremap ir i]
1402
1403
29ed691a » kana 2007-10-26 Key Mappings / Misc.: 1404 " Delete the content of the current line (not the line itself).
32a11004 » kana 2007-11-16 Key Mappings / Misc.: 1405 " BUGS: not repeatable.
1406 " BUGS: the default behavior is overridden, but it's still available via "x".
1407 nnoremap dl 0d$
29ed691a » kana 2007-10-26 Key Mappings / Misc.: 1408
1409
3ec1acb0 » kana 2007-11-13 Key Mappings / Misc.: 1410 " Like gv, but select the last changed text.
1411 nnoremap gc `[v`]
1412
1413
073d86a2 » kana 2007-11-13 Key Mappings / Misc.: 1414 " Make I/A available in characterwise-visual and linewise-visual.
8c94298a » kana 2008-02-05 vim/dot.vimrc: 1415 vnoremap <silent> I :<C-u>call <SID>ForceBlockwiseVisual('I')<Return>
1416 vnoremap <silent> A :<C-u>call <SID>ForceBlockwiseVisual('A')<Return>
7b8df1e9 » kana 2007-11-30 vim/dot.vimrc: 1417
1418 function! s:ForceBlockwiseVisual(next_key)
26824f81 » kana 2007-12-26 vim/dot.vimrc: 1419 if visualmode() ==# 'V'
1420 execute "normal! `<0\<C-v>`>$"
1421 else
1422 execute "normal! `<\<C-v>`>"
7b8df1e9 » kana 2007-11-30 vim/dot.vimrc: 1423 endif
1424 call feedkeys(a:next_key, 'n')
1425 endfunction
073d86a2 » kana 2007-11-13 Key Mappings / Misc.: 1426
1427
e164498e » kana 2007-11-16 Key Mappings / Misc.: 1428 " Start Insert mode with [count] blank lines.
ada646b8 » kana 2007-12-15 vim/dot.vimrc: 1429 " The default [count] is 0, so no blank line is inserted.
e164498e » kana 2007-11-16 Key Mappings / Misc.: 1430 " (I prefer this behavior to the default behavior of [count]o/O
1431 " -- repeat the next insertion [count] times.)
8c94298a » kana 2008-02-05 vim/dot.vimrc: 1432 nnoremap <silent> o :<C-u>call <SID>StartInsertModeWithBlankLines('o')<Return>
1433 nnoremap <silent> O :<C-u>call <SID>StartInsertModeWithBlankLines('O')<Return>
e164498e » kana 2007-11-16 Key Mappings / Misc.: 1434
1435 function! s:StartInsertModeWithBlankLines(command)
1436 " Do "[count]o<Esc>o" and so forth.
1437 " BUGS: In map-<expr>, v:count and v:count1 don't hold correct values.
d53acd9f » kana 2007-12-26 vim/dot.vimrc: 1438 " FIXME: improper indenting in comments.
1439 " FIXME: imperfect repeating (blank lines will not be repeated).
ada646b8 » kana 2007-12-15 vim/dot.vimrc: 1440
1441 if v:count != v:count1 " [count] is not specified?
1442 call feedkeys(a:command, 'n')
1443 return
e164498e » kana 2007-11-16 Key Mappings / Misc.: 1444 endif
ada646b8 » kana 2007-12-15 vim/dot.vimrc: 1445
1446 let script = v:count . a:command . "\<Esc>"
1447 if a:command ==# 'O'
1448 let script .= "\<Down>" . v:count . "\<Up>" " Adjust the cursor position.
1449 endif
1450
1451 execute 'normal!' script
1452 redraw
bd03351b » kana 2007-12-29 vim/dot.vimrc: 1453 Echo ModeMsg '-- INSERT (open) --'
ada646b8 » kana 2007-12-15 vim/dot.vimrc: 1454 echohl None
1455 let c = nr2char(getchar())
1456 call feedkeys((c != "\<Esc>" ? a:command : 'A'), 'n')
1457 call feedkeys(c, 'n')
d53acd9f » kana 2007-12-26 vim/dot.vimrc: 1458
1459 " to undo the next inserted text and the preceding blank lines in 1 step.
1460 undojoin
e164498e » kana 2007-11-16 Key Mappings / Misc.: 1461 endfunction
1462
1463
a6d6a75d » kana 2007-11-17 Key Mappings / Misc.: 1464 " Search for the selected text.
1465 vnoremap * :<C-u>call <SID>SearchForTheSelectedText()<Return>
1466
1467 " FIXME: escape to search the selected text literaly.
1468 function! s:SearchForTheSelectedText()
1469 let reg_u = @"
1470 let reg_0 = @0
1471
1472 normal! gvy
1473 let @/ = @0
1474 call histadd('/', @0)
1475 normal! n
1476
1477 let @0 = reg_0
1478 let @" = reg_u
1479 endfunction
1480
e164498e » kana 2007-11-16 Key Mappings / Misc.: 1481
76d636b0 » kana 2008-01-19 vim/dot.vimrc: 1482 " Pseudo :suspend with automtic cd.
1483 " Assumption: Use GNU screen.
1484 " Assumption: There is a window with the title "another".
1485 noremap <silent> <C-z> :<C-u>call <SID>PseudoSuspendWithAutomaticCD()<Return>
1486
1487 if !exists('s:gnu_screen_availablep')
3f3865aa » kana 2008-01-20 vim/dot.vimrc: 1488 " Check the existence of $WINDOW to avoid using GNU screen in Vim on
1489 " a remote machine (for example, "screen -t remote ssh example.com").
1490 let s:gnu_screen_availablep = len($WINDOW) != 0
76d636b0 » kana 2008-01-19 vim/dot.vimrc: 1491 endif
1492 function! s:PseudoSuspendWithAutomaticCD()
1493 if s:gnu_screen_availablep
1494 " \015 = <C-m>
1449493b » kana 2008-01-21 vim/dot.vimrc: 1495 " To avoid adding the cd script into the command-line history,
1496 " there are extra leading whitespaces in the cd script.
76d636b0 » kana 2008-01-19 vim/dot.vimrc: 1497 silent execute '!screen -X eval'
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1498 \ '''select another'''
1499 \ '''stuff " cd \"'.getcwd().'\" \#\#,vim-auto-cd\015"'''
76d636b0 » kana 2008-01-19 vim/dot.vimrc: 1500 redraw!
1501 let s:gnu_screen_availablep = (v:shell_error == 0)
1502 endif
1503
1504 if !s:gnu_screen_availablep
1505 suspend
1506 endif
1507 endfunction
1508
1509
e0a9c52d » kana 2008-01-31 vim/dot.vimrc: 1510 " Show the lines which match to the last search pattern.
1511 nnoremap g/ :g/<Return>
1512 vnoremap g/ :g/<Return>
1513
1514
57d0ad0f » kana 2007-10-10 Revise KEY MAPPINGS section: 1515
1516
195a83f9 » kana 2007-02-16 Fix the layout. 1517
1518
1519
1520
933b1512 » kana 2007-10-10 Filetypes: 1521 " Filetypes "{{{1
184db961 » kana 2008-03-11 vim: vimrc: Revise comments... 1522 " All filetypes "{{{2
1523 " Here also contains misc. autocommands.
0846ad45 » kana 2007-02-16 Filetype: Revise layout. 1524
933b1512 » kana 2007-10-10 Filetypes: 1525 autocmd MyAutoCmd FileType *
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1526 \ call <SID>FileType_any()
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 1527 function! s:FileType_any()
195a83f9 » kana 2007-02-16 Fix the layout. 1528 " To use my global mappings for section jumping,
933b1512 » kana 2007-10-10 Filetypes: 1529 " remove buffer local mappings defined by ftplugin.
a3a0414f » kana 2007-02-16 Fix style: separate lhs and... 1530 silent! vunmap <buffer> ]]
1531 silent! vunmap <buffer> ][
1532 silent! vunmap <buffer> []
1533 silent! vunmap <buffer> [[
1534 silent! ounmap <buffer> ]]
1535 silent! ounmap <buffer> ][
1536 silent! ounmap <buffer> []
1537 silent! ounmap <buffer> [[
da61c319 » kana 2008-01-10 vim/dot.vimrc: 1538
1539 " Make omni completion available for all filetypes.
1540 if &l:omnifunc == ''
1541 setlocal omnifunc=syntaxcomplete#Complete
1542 endif
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 1543 endfunction
1544
195a83f9 » kana 2007-02-16 Fix the layout. 1545
00dbed8e » kana 2007-10-26 Filetypes / All: 1546 " Fix 'fileencoding' to use 'encoding'
1547 " if the buffer only contains 7-bit characters.
4c3debc3 » kana 2007-10-26 Filetypes / Any filetype: 1548 " Note that if the buffer is not 'modifiable',
1549 " its 'fileencoding' cannot be changed, so that such buffers are skipped.
00dbed8e » kana 2007-10-26 Filetypes / All: 1550 autocmd MyAutoCmd BufReadPost *
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1551 \ if &modifiable && !search('[^\x00-\x7F]', 'cnw')
1552 \ | setlocal fileencoding=
1553 \ | endif
00dbed8e » kana 2007-10-26 Filetypes / All: 1554
1555
184db961 » kana 2008-03-11 vim: vimrc: Revise comments... 1556 " Adjust highlight settings according to the current colorscheme.
933b1512 » kana 2007-10-10 Filetypes: 1557 autocmd MyAutoCmd ColorScheme *
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1558 \ call <SID>ExtendHighlight('Pmenu', 'Normal', 'cterm=underline')
1559 \ | call <SID>ExtendHighlight('PmenuSel', 'Search', 'cterm=underline')
1560 \ | call <SID>ExtendHighlight('PmenuSbar', 'Normal', 'cterm=reverse')
1561 \ | call <SID>ExtendHighlight('PmenuThumb', 'Search', '')
1562 \
1563 \ | highlight TabLineSel
1564 \ term=bold,reverse
1565 \ cterm=bold,underline ctermfg=lightgray ctermbg=darkgray
1566 \ | highlight TabLine
1567 \ term=reverse
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1568 \ cterm=NONE ctermfg=lightgray ctermbg=darkgray
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1569 \ | highlight TabLineFill
1570 \ term=reverse
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1571 \ cterm=NONE ctermfg=lightgray ctermbg=darkgray
933b1512 » kana 2007-10-10 Filetypes: 1572 doautocmd MyAutoCmd ColorScheme because-colorscheme-has-been-set-above.
1573
1574
ae41016e » kana 2008-03-10 vim: vimrc: Shift to Insert... 1575 " Automatically shift to the Insert mode
1576 " when a multibyte character is typed in Normal mode.
1577 " Note: To use nonstandard event NCmdUndefined, use the following version:
1578 " http://repo.or.cz/w/vim-kana.git?a=shortlog;h=hack/ncmdundefined
1579 silent! autocmd MyAutoCmd NCmdUndefined *
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1580 \ call <SID>ShiftToInsertMode(expand('<amatch>'))
ae41016e » kana 2008-03-10 vim: vimrc: Shift to Insert... 1581 function! s:ShiftToInsertMode(not_a_command_character)
1582 if char2nr(a:not_a_command_character) <= 0xFF " not a multibyte character?
1583 return " should beep as same as the default behavior, but how?
1584 endif
1585
1586 " Take all keys in the typeahead buffer.
1587 let keys = a:not_a_command_character
1588 while !0
1589 let c = getchar(0)
1590 if c == 0
1591 break
1592 endif
1593 let keys .= nr2char(c)
1594 endwhile
1595
1596 " Shfit to Insert mode, then emulate typing the keys.
1597 " Note: If :startinsert is used to shifting to Insert mode,
1598 " instead of keys[0], unexpected string '<t_<fd>_>' will be inserted.
1599 call feedkeys('i', 'n')
1600 call feedkeys(keys, 't')
1601 endfunction
1602
1603
912565d2 » kana 2008-03-11 vim: vimrc: Unset 'paste' a... 1604 " Unset 'paste' automatically. It's often hard to do so because of most
1605 " mappings are disabled in Paste mode.
1606 autocmd MyAutoCmd InsertLeave * set nopaste
1607
1608
195a83f9 » kana 2007-02-16 Fix the layout. 1609
1610
3c0add31 » kana 2007-10-20 Filetypes / css: 1611 " css "{{{2
1612
1613 autocmd MyAutoCmd FileType css
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1614 \ call <SID>SetShortIndent()
3c0add31 » kana 2007-10-20 Filetypes / css: 1615
1616
1617
1618
933b1512 » kana 2007-10-10 Filetypes: 1619 " dosini (.ini) "{{{2
1620
1621 autocmd MyAutoCmd FileType dosini
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1622 \ call <SID>FileType_dosini()
0846ad45 » kana 2007-02-16 Filetype: Revise layout. 1623
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 1624 function! s:FileType_dosini()
e63e08e5 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1625 nnoremap <buffer> <silent> ]]
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1626 \ :<C-u>call <SID>JumpSectionN('/^\[')<Return>
e63e08e5 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1627 nnoremap <buffer> <silent> ][
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1628 \ :<C-u>call <SID>JumpSectionN('/\n\[\@=')<Return>
e63e08e5 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1629 nnoremap <buffer> <silent> [[
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1630 \ :<C-u>call <SID>JumpSectionN('?^\[')<Return>
e63e08e5 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1631 nnoremap <buffer> <silent> []
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1632 \ :<C-u>call <SID>JumpSectionN('?\n\[\@=')<Return>
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 1633 endfunction
1634
1635
195a83f9 » kana 2007-02-16 Fix the layout. 1636
1637
e453bfd6 » kana 2007-11-16 Filetype / help: 1638 " help "{{{2
1639
1640 autocmd MyAutoCmd FileType help
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1641 \ call textobj#user#define('|[^| \t]*|', '', '', {
1642 \ 'move-to-next': '<buffer> gj',
1643 \ 'move-to-prev': '<buffer> gk',
1644 \ })
e453bfd6 » kana 2007-11-16 Filetype / help: 1645
1646
1647
1648
933b1512 » kana 2007-10-10 Filetypes: 1649 " lua "{{{2
1650
1651 autocmd MyAutoCmd FileType lua
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1652 \ call <SID>SetShortIndent()
933b1512 » kana 2007-10-10 Filetypes: 1653
1654
1655
1656
1657 " netrw "{{{2
1658 "
1659 " Consider these buffers have "another" filetype=netrw.
1660
1661 autocmd MyAutoCmd BufReadPost {dav,file,ftp,http,rcp,rsync,scp,sftp}://*
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1662 \ setlocal bufhidden=hide
933b1512 » kana 2007-10-10 Filetypes: 1663
1664
1665
1666
1667 " python "{{{2
1668
1669 autocmd MyAutoCmd FileType python
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1670 \ call <SID>SetShortIndent()
1671 \ | let python_highlight_numbers=1
1672 \ | let python_highlight_builtins=1
1673 \ | let python_highlight_space_errors=1
933b1512 » kana 2007-10-10 Filetypes: 1674
1675
1676
1677
711dabd4 » kana 2008-01-10 vim/dot.vimrc: 1678 " ruby "{{{2
1679
1680 autocmd MyAutoCmd FileType ruby
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1681 \ call <SID>SetShortIndent()
711dabd4 » kana 2008-01-10 vim/dot.vimrc: 1682
1683
1684
1685
0846ad45 » kana 2007-02-16 Filetype: Revise layout. 1686 " sh "{{{2
1687
933b1512 » kana 2007-10-10 Filetypes: 1688 autocmd MyAutoCmd FileType sh
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1689 \ call <SID>SetShortIndent()
933b1512 » kana 2007-10-10 Filetypes: 1690
1691 " FIXME: use $SHELL.
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 1692 let g:is_bash = 1
1693
1694
1695
1696
933b1512 » kana 2007-10-10 Filetypes: 1697 " tex "{{{2
1698
1699 autocmd MyAutoCmd FileType tex
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1700 \ call <SID>SetShortIndent()
933b1512 » kana 2007-10-10 Filetypes: 1701
1702
1703
1704
f85121c9 » kana 2008-01-06 vim/dot.vimrc: 1705 " vcsicommit "{{{2
1706 " 'filetype' for commit log buffers created by vcsi.
3664863a » kana 2007-11-22 Filetypes / vcscommit: 1707
95e8edab » kana 2008-01-12 vim/dot.vimrc: 1708 autocmd MyAutoCmd FileType {vcsicommit,*.vcsicommit}
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1709 \ setlocal comments=sr:*,mb:\ ,ex:NOT_DEFINED
3664863a » kana 2007-11-22 Filetypes / vcscommit: 1710
1711
1712
1713
933b1512 » kana 2007-10-10 Filetypes: 1714 " vim "{{{2
1715
1716 autocmd MyAutoCmd FileType vim
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1717 \ call <SID>FileType_vim()
0846ad45 » kana 2007-02-16 Filetype: Revise layout. 1718
c1683ca2 » kana 2007-02-16 Filetype (vim): Add the set... 1719 function! s:FileType_vim()
1720 call <SID>SetShortIndent()
1721 let vim_indent_cont = &shiftwidth
f5168657 » kana 2007-11-13 Filetype / vim: 1722
1723 iabbr <buffer> jf function!()<Return>
1724 \endfunction<Return>
1725 \<Up><Up><End><Left><Left>
1726 iabbr <buffer> ji if<Return>
1727 \endif<Return>
1728 \<Up><Up><End>
1729 iabbr <buffer> je if<Return>
1730 \else<Return>
1731 \endif<Return>
1732 \<Up><Up><Up><End>
1733 iabbr <buffer> jw while<Return>
1734 \endwhile<Return>
1735 \<Up><Up><End>
4679e2f7 » kana 2007-11-16 Filetype / vim: 1736
1737 " Fix the default syntax to properly highlight
1738 " autoload#function() and dictionary.function().
1739 syntax clear vimFunc
1740 syntax match vimFunc
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1741 \ "\%([sS]:\|<[sS][iI][dD]>\|\<\%(\I\i*[#.]\)\+\)\=\I\i*\ze\s*("
1742 \ contains=vimFuncName,vimUserFunc,vimCommand,vimNotFunc,vimExecute
4679e2f7 » kana 2007-11-16 Filetype / vim: 1743 syntax clear vimUserFunc
1744 syntax match vimUserFunc contained
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1745 \ "\%([sS]:\|<[sS][iI][dD]>\|\<\%(\I\i*[#.]\)\+\)\i\+\|\<\u\i*\>\|\<if\>"
1746 \ contains=vimNotation,vimCommand
c1683ca2 » kana 2007-02-16 Filetype (vim): Add the set... 1747 endfunction
1748
1749
1750
1751
d8163626 » kana 2007-05-26 FILETYPE (xml): 1752 " XML/SGML and other applications "{{{2
1753
933b1512 » kana 2007-10-10 Filetypes: 1754 autocmd MyAutoCmd FileType html,xhtml,xml,xslt
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1755 \ call <SID>FileType_xml()
933b1512 » kana 2007-10-10 Filetypes: 1756
d8163626 » kana 2007-05-26 FILETYPE (xml): 1757 function! s:FileType_xml()
1758 call <SID>SetShortIndent()
1759
1bb39e13 » kana 2007-05-26 FILETYPE (xml): 1760 " To deal with namespace prefixes and tag-name-including-hyphens.
1761 setlocal iskeyword+=45 " hyphen (-)
1762 setlocal iskeyword+=58 " colon (:)
1763
351ac437 » kana 2007-06-05 FILETYPE (xml): 1764 " Support to input some parts of tags.
d8163626 » kana 2007-05-26 FILETYPE (xml): 1765 inoremap <buffer> <LT>? </
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1766 imap <buffer> ?<LT> <LT>?
d8163626 » kana 2007-05-26 FILETYPE (xml): 1767 inoremap <buffer> ?> />
ab470bba » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1768 imap <buffer> >? ?>
d8163626 » kana 2007-05-26 FILETYPE (xml): 1769
351ac437 » kana 2007-06-05 FILETYPE (xml): 1770 " Support to input some blocks.
1771 inoremap <buffer> <LT>!C <LT>![CDATA[]]><Left><Left><Left>
1772 inoremap <buffer> <LT># <LT>!----><Left><Left><Left><C-r>=
692abb34 » kana 2008-01-12 vim/dot.vimrc: 1773 \<SID>FileType_xml_comment_dispatch()
1774 \<Return>
351ac437 » kana 2007-06-05 FILETYPE (xml): 1775
67122dc3 » kana 2007-07-05 FILETYPE (xml): 1776 " Complete proper end-tags.
1777 " In the following description, {|} means the cursor position.
d8163626 » kana 2007-05-26 FILETYPE (xml): 1778
67122dc3 » kana 2007-07-05 FILETYPE (xml): 1779 " Insert the end tag after the cursor.
d8163626 » kana 2007-05-26 FILETYPE (xml): 1780 " Before: <code{|}
1781 " After: <code>{|}</code>
67122dc3 » kana 2007-07-05 FILETYPE (xml): 1782 inoremap <buffer> <LT><LT> ><LT>/<C-x><C-o><C-r>=
692abb34 » kana 2008-01-12 vim/dot.vimrc: 1783 \<SID>KeysToStopInsertModeCompletion()
1784 \<Return><C-o>F<LT>
d8163626 » kana 2007-05-26 FILETYPE (xml): 1785
67122dc3 » kana 2007-07-05 FILETYPE (xml): 1786 " Wrap the cursor with the tag.
d8163626 » kana 2007-05-26 FILETYPE (xml): 1787 " Before: <code{|}
1788 " After: <code>
1789 " {|}
1790 " </code>
67122dc3 » kana 2007-07-05 FILETYPE (xml): 1791 inoremap <buffer> >> ><Return>X<Return><LT>/<C-x><C-o><C-r>=
692abb34 » kana 2008-01-12 vim/dot.vimrc: 1792 \<SID>KeysToStopInsertModeCompletion()
1793 \<Return><C-o><Up><BS>
f90a3cd6 » kana 2007-05-26 FILETYPE (xml): 1794 endfunction
1795
d8163626 » kana 2007-05-26 FILETYPE (xml): 1796
351ac437 » kana 2007-06-05 FILETYPE (xml): 1797 function! s:FileType_xml_comment_dispatch()
1798 let c = nr2char(getchar())
1799 return get(s:FileType_xml_comment_data, c, c)
1800 endfunction
1801 let s:FileType_xml_comment_data = {
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1802 \ "\<Space>": "\<Space>\<Space>\<Left>",
1803 \ "\<Return>": "\<Return>X\<Return>\<Up>\<End>\<BS>",
1804 \ '_': '',
1805 \ '-': '',
1806 \ '{': '{{'. "{\<Esc>",
1807 \ '}': '}}'. "}\<Esc>",
1808 \ '1': '{{'."{1\<Esc>",
1809 \ '2': '{{'."{2\<Esc>",
1810 \ '3': '{{'."{3\<Esc>",
1811 \ '4': '{{'."{4\<Esc>",
1812 \ '5': '{{'."{5\<Esc>",
1813 \ '6': '{{'."{6\<Esc>",
1814 \ '7': '{{'."{7\<Esc>",
1815 \ '8': '{{'."{8\<Esc>",
1816 \ '9': '{{'."{9\<Esc>",
1817 \ '!': '{{'."{1\<Esc>",
1818 \ '@': '{{'."{2\<Esc>",
1819 \ '#': '{{'."{3\<Esc>",
1820 \ '$': '{{'."{4\<Esc>",
1821 \ '%': '{{'."{5\<Esc>",
1822 \ '^': '{{'."{6\<Esc>",
1823 \ '&': '{{'."{7\<Esc>",
1824 \ '*': '{{'."{8\<Esc>",
1825 \ '(': '{{'."{9\<Esc>",
1826 \ }
351ac437 » kana 2007-06-05 FILETYPE (xml): 1827
1828
d8163626 » kana 2007-05-26 FILETYPE (xml): 1829
1830
195a83f9 » kana 2007-02-16 Fix the layout. 1831
1832
1833
1834
b6850cdf » kana 2007-10-10 Divide MISC. section into P... 1835 " Plugins "{{{1
f9532b38 » kana 2008-02-08 vim/dot.vim/autoload/ku.vim: 1836 " ku "{{{2
1837
82a90f3d » kana 2008-02-11 vim/dot.vimrc: 1838 autocmd MyAutoCmd User KuLoaded call <SID>on_KuLoaded()
1839 function! s:on_KuLoaded()
f9532b38 » kana 2008-02-08 vim/dot.vim/autoload/ku.vim: 1840 function! s:ku_type_any_action_my_cd(item)
1841 " FIXME: escape special characters.
1842 if isdirectory(a:item.word)
1843 execute 'CD' a:item.word
1844 elseif filereadable(a:item.word)
1845 execute 'CD' fnamemodify(a:item.word, ':h')
1846 else
1847 echo printf('Item %s (type: %s) is not a file or directory.',
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1848 \ a:item.word, a:item._ku_type.name)
f9532b38 » kana 2008-02-08 vim/dot.vim/autoload/ku.vim: 1849 endif
1850 endfunction
1851
82a90f3d » kana 2008-02-11 vim/dot.vimrc: 1852 call ku#custom_action('*fallback*', 'cd',
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1853 \ function(s:SID_PREFIX() . 'ku_type_any_action_my_cd'))
f9532b38 » kana 2008-02-08 vim/dot.vim/autoload/ku.vim: 1854 endfunction
1855
82a90f3d » kana 2008-02-11 vim/dot.vimrc: 1856
1857 autocmd MyAutoCmd User KuBufferInitialize call <SID>on_KuBufferInitialize()
1858 function! s:on_KuBufferInitialize()
1859 call ku#default_key_mappings()
1860 endfunction
1861
1862
f9532b38 » kana 2008-02-08 vim/dot.vim/autoload/ku.vim: 1863 nnoremap [Space]ka :<C-u>Ku<Return>
1864 nnoremap [Space]kb :<C-u>Ku buffer<Return>
1865 nnoremap [Space]kf :<C-u>Ku file<Return>
1866
1867
1868
1869
35338586 » kana 2007-12-27 vim/dot.vimrc: 1870 " narrow "{{{2
1871
1872 noremap [Space]xn :Narrow<Return>
1873 noremap [Space]xw :<C-u>Widen<Return>
1874
1875
1876
1877
b69d2ab4 » kana 2007-10-10 Plugins / scratch: 1878 " scratch "{{{2
1879
ffb5a054 » kana 2007-12-25 vim/dot.vim/plugin/scratch.... 1880 nmap <Leader>s <Plug>(scratch-open)
974998b4 » kana 2007-12-24 vim (plugin scratch): 1881
1882
ba6366d1 » kana 2008-04-11 vim: vimrc: Fix all {lhs} t... 1883 " I already use <C-m>/<Return> for tag jumping.
b69d2ab4 » kana 2007-10-10 Plugins / scratch: 1884 " But I don't use it in the scratch buffer, so it should be overridden.
974998b4 » kana 2007-12-24 vim (plugin scratch): 1885 autocmd MyAutoCmd User PluginScratchInitializeAfter
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1886 \ map <buffer> <Plug>(physical-key-<Return>) <Plug>(scratch-evaluate)
b69d2ab4 » kana 2007-10-10 Plugins / scratch: 1887
1888
1889
1890
b6850cdf » kana 2007-10-10 Divide MISC. section into P... 1891 " surround "{{{2
4dc73ea5 » kana 2007-07-05 MISC. (Plugin: surround): 1892
1893 " The default mapping ys for <Plug>Ysurround is not consistent with
1894 " the default mappings of vi -- y is for yank.
1895 nmap s <Plug>Ysurround
44fbfc65 » kana 2007-10-01 r1273@colinux: kecak | 20... 1896 nmap ss <Plug>Yssurround
1897
46b71104 » kana 2007-11-30 vim/dot.vimrc: 1898 " See also ~/.vim/plugin/surround_config.vim .
4dc73ea5 » kana 2007-07-05 MISC. (Plugin: surround): 1899
1900
1901
1902
66db3a2a » kana 2008-01-13 vim/dot.vimrc: 1903 " vcsi "{{{2
1904
1905 let g:vcsi_diff_in_commit_logp = 1
1906
1907
1908
1909
b6850cdf » kana 2007-10-10 Divide MISC. section into P... 1910 " xml_autons "{{{2
48be31de » kana 2007-07-26 Revise some comments and co... 1911
219f75c9 » kana 2007-05-22 MISC. / Plugin: xml_autons: 1912 let g:AutoXMLns_Dict = {}
1913 let g:AutoXMLns_Dict['http://www.w3.org/2000/svg'] = 'svg11'
1914
1915
1916
1917
b6850cdf » kana 2007-10-10 Divide MISC. section into P... 1918
1919
1920
1921
1922 " Fin. "{{{1
e1220d18 » kana 2007-10-01 r1272@colinux: kecak | 20... 1923
97eae278 » kana 2007-10-01 r1274@colinux: kecak | 20... 1924 if !exists('s:loaded_my_vimrc')
1925 let s:loaded_my_vimrc = 1
9fcea0cc » kana 2007-12-27 vim/dot.vim/plugin/cygclip.... 1926 " autocmd MyAutoCmd VimEnter *
eaf21d90 » kana 2008-05-04 vim: vimrc: Update "Notes" ... 1927 " \ doautocmd MyAutoCmd User DelayedSettings
97eae278 » kana 2007-10-01 r1274@colinux: kecak | 20... 1928 else
9fcea0cc » kana 2007-12-27 vim/dot.vim/plugin/cygclip.... 1929 " doautocmd MyAutoCmd User DelayedSettings
97eae278 » kana 2007-10-01 r1274@colinux: kecak | 20... 1930 endif
1931
1932
1933
1934
b6850cdf » kana 2007-10-10 Divide MISC. section into P... 1935 set secure " must be written at the last. see :help 'secure'.
1936
1937
1938
1939
b3e2b9b0 » kana 2007-01-15 Import vim config from the ... 1940
e1220d18 » kana 2007-10-01 r1272@colinux: kecak | 20... 1941
1942
1943
e6241e13 » kana 2007-10-10 Revise the modelines. 1944 " __END__ "{{{1
1945 " vim: expandtab softtabstop=2 shiftwidth=2
1946 " vim: foldmethod=marker