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