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