This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
kana (author)
Sun Nov 22 19:41:18 -0800 2009
| 661b53ea » | kana | 2008-02-15 | 1 | " My .vimrc | |
| 8fdfe5f1 » | kana | 2007-10-10 | 2 | " Notes "{{{1 | |
| 3 | " | ||||
| 4 | " * This file consists of "sections". | ||||
| 5 | " | ||||
| ee2fb8d1 » | kana | 2008-05-04 | 6 | " - The name of each section should be single word. | |
| 60783901 » | kana | 2007-10-10 | 7 | " | |
| 8fdfe5f1 » | kana | 2007-10-10 | 8 | " * Each section consists of zero or more "subsections". | |
| 9 | " | ||||
| 60783901 » | kana | 2007-10-10 | 10 | " - There is no rule for the name of each subsection. | |
| 11 | " | ||||
| b6850cdf » | kana | 2007-10-10 | 12 | " * The last subsection in a section should be named as "Misc.". | |
| 8fdfe5f1 » | kana | 2007-10-10 | 13 | " | |
| 14 | " * Whenever new subsection is inserted, | ||||
| ee2fb8d1 » | kana | 2008-05-04 | 15 | " it should be inserted just before "Misc." subsection. | |
| 8fdfe5f1 » | kana | 2007-10-10 | 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 | 21 | " "Plugins" section. | |
| 8fdfe5f1 » | kana | 2007-10-10 | 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 | 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 | 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 | " | ||||
| a74ad62d » | kana | 2008-08-24 | 48 | " * Sort arguments for :command such as -nargs=* and others by alphabetically | |
| 49 | " order. | ||||
| 50 | " | ||||
| e63e08e5 » | kana | 2008-05-04 | 51 | " * Write the full name for each command -- don't abbreviate it. | |
| 52 | " For example, write "nnoremap", not "nn". | ||||
| 60783901 » | kana | 2007-10-10 | 53 | " | |
| 8fdfe5f1 » | kana | 2007-10-10 | 54 | " * Key Notation: | |
| 55 | " | ||||
| 56 | " - Control-keys: Write as <C-x>, neither <C-X> nor <c-x>. | ||||
| 57 | " | ||||
| 58 | " - Carriage return: Write as <Return>, neither <Enter> nor <CR>. | ||||
| 59 | " | ||||
| 60 | " - Other characters: Write as same as :help key-notation | ||||
| bc03e7c8 » | kana | 2008-01-12 | 61 | " | |
| 62 | " * Line continuation: | ||||
| 63 | " | ||||
| eaf21d90 » | kana | 2008-05-04 | 64 | " - At the middle of key mappings, abbreviations and other proler places: | |
| 65 | " Write "\" at the previous column of the start of the {rhs}. | ||||
| bc03e7c8 » | kana | 2008-01-12 | 66 | " | |
| eaf21d90 » | kana | 2008-05-04 | 67 | " - Others: Write "\" at the same column of the beggining of the command. | |
| bc03e7c8 » | kana | 2008-01-12 | 68 | " | |
| 69 | " - Examples: | ||||
| 70 | " | ||||
| eaf21d90 » | kana | 2008-05-04 | 71 | " execute "echo" | |
| 72 | " \ "foo" | ||||
| 73 | " \ "baz" | ||||
| bc03e7c8 » | kana | 2008-01-12 | 74 | " | |
| eaf21d90 » | kana | 2008-05-04 | 75 | " map <silent> xyzzy :<C-u>if has('cryptv') | |
| 76 | " \| X | ||||
| 77 | " \|endif<Return> | ||||
| ab470bba » | kana | 2008-05-04 | 78 | " | |
| 79 | " * Don't align columns. So don't write like the following code: | ||||
| 80 | " | ||||
| 81 | " map <expr> foo bar | ||||
| 82 | " noremap <silent> bar baz | ||||
| 83 | " | ||||
| 84 | " instead, write like the following code: | ||||
| 85 | " | ||||
| 86 | " map <expr> foo bar | ||||
| 87 | " noremap <silent> bar baz | ||||
| 414cc3df » | kana | 2008-05-04 | 88 | " | |
| 89 | " * Naming: | ||||
| 90 | " | ||||
| 91 | " - Functions: Don't use upper case characters if possible. | ||||
| 92 | " | ||||
| 93 | " - Functions: Use "cmd_{command}" for a {command} such as: | ||||
| 94 | " command! -nargs=* {command} call s:cmd_{command}(<f-args>) | ||||
| 95 | " | ||||
| 96 | " - Functions: Use "complete_{type}" for :command-completion-custom or | ||||
| 97 | " :command-completion-customlist functions. | ||||
| 98 | " | ||||
| 99 | " - Functions: Use "on_{event}_{mod}" for a handler of :autocmd {event}. | ||||
| 26dcd217 » | kana | 2008-12-11 | 100 | " | |
| aebdf5f3 » | kana | 2008-12-11 | 101 | " - Use "tabpage" instead of "tab_page" or "tab page" or "tab". | |
| 0cc2491f » | kana | 2009-05-22 | 102 | " | |
| 103 | " * Register usage: | ||||
| 104 | " | ||||
| 105 | " - "g for :global. | ||||
| 106 | " | ||||
| 107 | " - Don't overwrite other named registers. | ||||
| 8fdfe5f1 » | kana | 2007-10-10 | 108 | ||
| 109 | |||||
| 110 | |||||
| 111 | |||||
| 112 | |||||
| 113 | |||||
| 114 | |||||
| 115 | |||||
| 88559863 » | kana | 2007-10-10 | 116 | " Basic "{{{1 | |
| 117 | " Absolute "{{{2 | ||||
| b3e2b9b0 » | kana | 2007-01-15 | 118 | ||
| a4fe3709 » | kana | 2009-05-13 | 119 | if !exists('s:loaded_my_vimrc') | |
| 120 | " Don't reset twice on reloading - 'compatible' has SO many side effects. | ||||
| 121 | set nocompatible " to use many extensions of Vim. | ||||
| 122 | endif | ||||
| b3e2b9b0 » | kana | 2007-01-15 | 123 | ||
| 124 | |||||
| f6426230 » | kana | 2008-02-24 | 125 | function! s:SID_PREFIX() | |
| 126 | return matchstr(expand('<sfile>'), '<SNR>\d\+_') | ||||
| 127 | endfunction | ||||
| 128 | |||||
| 129 | |||||
| 88559863 » | kana | 2007-10-10 | 130 | ||
| 131 | |||||
| 132 | " Encoding "{{{2 | ||||
| 133 | |||||
| 195a83f9 » | kana | 2007-02-16 | 134 | " To deal with Japanese language. | |
| 2b61c23d » | kana | 2009-04-28 | 135 | if $ENV_WORKING ==# 'summer' | |
| eafef300 » | kana | 2007-09-10 | 136 | set encoding=japan | |
| 2ba08681 » | kana | 2009-04-27 | 137 | else | |
| 138 | set encoding=utf-8 | ||||
| eafef300 » | kana | 2007-09-10 | 139 | endif | |
| c7010d9a » | kana | 2009-01-12 | 140 | ||
| 141 | if has('iconv') | ||||
| b3e2b9b0 » | kana | 2007-01-15 | 142 | let s:enc_euc = 'euc-jp' | |
| 143 | let s:enc_jis = 'iso-2022-jp' | ||||
| 144 | |||||
| 145 | " Does iconv support JIS X 0213 ? | ||||
| 692abb34 » | kana | 2008-01-12 | 146 | if iconv("\x87\x64\x87\x6a", 'cp932', 'euc-jisx0213') ==# "\xad\xc5\xad\xcb" | |
| b3e2b9b0 » | kana | 2007-01-15 | 147 | let s:enc_euc = 'euc-jisx0213,euc-jp' | |
| 148 | let s:enc_jis = 'iso-2022-jp-3' | ||||
| 149 | endif | ||||
| 150 | |||||
| 151 | " Make fileencodings | ||||
| eafef300 » | kana | 2007-09-10 | 152 | let &fileencodings = 'ucs-bom' | |
| e2da61a6 » | kana | 2007-09-10 | 153 | if &encoding !=# 'utf-8' | |
| 154 | let &fileencodings = &fileencodings . ',' . 'ucs-2le' | ||||
| 155 | let &fileencodings = &fileencodings . ',' . 'ucs-2' | ||||
| 156 | endif | ||||
| b3e2b9b0 » | kana | 2007-01-15 | 157 | let &fileencodings = &fileencodings . ',' . s:enc_jis | |
| 158 | |||||
| eafef300 » | kana | 2007-09-10 | 159 | if &encoding ==# 'utf-8' | |
| 160 | let &fileencodings = &fileencodings . ',' . s:enc_euc | ||||
| 161 | let &fileencodings = &fileencodings . ',' . 'cp932' | ||||
| 162 | elseif &encoding =~# '^euc-\%(jp\|jisx0213\)$' | ||||
| b3e2b9b0 » | kana | 2007-01-15 | 163 | let &encoding = s:enc_euc | |
| eafef300 » | kana | 2007-09-10 | 164 | let &fileencodings = &fileencodings . ',' . 'utf-8' | |
| 165 | let &fileencodings = &fileencodings . ',' . 'cp932' | ||||
| 166 | else " cp932 | ||||
| 167 | let &fileencodings = &fileencodings . ',' . 'utf-8' | ||||
| 168 | let &fileencodings = &fileencodings . ',' . s:enc_euc | ||||
| b3e2b9b0 » | kana | 2007-01-15 | 169 | endif | |
| eafef300 » | kana | 2007-09-10 | 170 | let &fileencodings = &fileencodings . ',' . &encoding | |
| b3e2b9b0 » | kana | 2007-01-15 | 171 | ||
| 172 | unlet s:enc_euc | ||||
| 173 | unlet s:enc_jis | ||||
| 174 | endif | ||||
| 175 | |||||
| 176 | |||||
| 2b61c23d » | kana | 2009-04-28 | 177 | if $ENV_ACCESS ==# 'summer' | |
| b765a4dc » | kana | 2007-05-05 | 178 | set termencoding=cp932 | |
| 1e8f2dd7 » | kana | 2007-11-17 | 179 | else " fallback | |
| 180 | set termencoding= " same as 'encoding' | ||||
| b765a4dc » | kana | 2007-05-05 | 181 | endif | |
| 182 | |||||
| 183 | |||||
| b3e2b9b0 » | kana | 2007-01-15 | 184 | ||
| 185 | |||||
| 88559863 » | kana | 2007-10-10 | 186 | " Options "{{{2 | |
| b3e2b9b0 » | kana | 2007-01-15 | 187 | ||
| 71bda839 » | kana | 2009-06-14 | 188 | if (1 < &t_Co || has('gui')) && has('syntax') | |
| d8fe4914 » | kana | 2007-04-05 | 189 | if &term ==# 'rxvt-cygwin-native' | |
| 190 | set t_Co=256 | ||||
| 191 | endif | ||||
| b3e2b9b0 » | kana | 2007-01-15 | 192 | syntax enable | |
| 4231e025 » | kana | 2008-08-26 | 193 | if !exists('g:colors_name') " Don't override colorscheme on reloading. | |
| 5bb5ea73 » | kana | 2008-08-26 | 194 | colorscheme desert | |
| 4231e025 » | kana | 2008-08-26 | 195 | set background=dark | |
| 196 | endif | ||||
| b3e2b9b0 » | kana | 2007-01-15 | 197 | endif | |
| 198 | |||||
| 199 | filetype plugin indent on | ||||
| 200 | |||||
| 201 | |||||
| 1d8429d4 » | kana | 2007-10-04 | 202 | set ambiwidth=double | |
| b3e2b9b0 » | kana | 2007-01-15 | 203 | set autoindent | |
| 204 | set backspace=indent,eol,start | ||||
| 205 | set backup | ||||
| 206 | set backupcopy& | ||||
| 207 | set backupdir=.,~/tmp | ||||
| ec95550e » | kana | 2007-07-05 | 208 | set backupskip& | |
| 2149f670 » | kana | 2007-07-09 | 209 | set backupskip+=svn-commit.tmp,svn-commit.[0-9]*.tmp | |
| 5e26906f » | kana | 2007-02-15 | 210 | set cinoptions=:0,t0,(0,W1s | |
| b3e2b9b0 » | kana | 2007-01-15 | 211 | set directory=.,~/tmp | |
| 212 | set noequalalways | ||||
| 086e70b4 » | kana | 2007-09-21 | 213 | set formatoptions=tcroqnlM1 | |
| e50ead64 » | kana | 2007-11-22 | 214 | set formatlistpat& | |
| 7612ae3c » | kana | 2007-12-25 | 215 | let &formatlistpat .= '\|^\s*[*+-]\s*' | |
| b3e2b9b0 » | kana | 2007-01-15 | 216 | set history=100 | |
| 217 | set hlsearch | ||||
| ade507da » | kana | 2008-01-21 | 218 | nohlsearch " To avoid (re)highlighting the last search pattern | |
| 219 | " whenever $MYVIMRC is (re)loaded. | ||||
| 03a19ef8 » | kana | 2009-04-26 | 220 | " set grepprg=... " See s:toggle_grepprg(). | |
| b3e2b9b0 » | kana | 2007-01-15 | 221 | set incsearch | |
| 780ddd3f » | kana | 2007-10-25 | 222 | set laststatus=2 " always show status lines. | |
| b3e2b9b0 » | kana | 2007-01-15 | 223 | set mouse= | |
| 224 | set ruler | ||||
| 225 | set showcmd | ||||
| 226 | set showmode | ||||
| 4b1c3791 » | kana | 2009-09-26 | 227 | set updatetime=4000 | |
| b3e2b9b0 » | kana | 2007-01-15 | 228 | set title | |
| eafef300 » | kana | 2007-09-10 | 229 | set titlestring=Vim:\ %f\ %h%r%m | |
| ac175a16 » | kana | 2008-11-08 | 230 | set ttimeoutlen=50 " Reduce annoying delay for key codes, especially <Esc>... | |
| 4099e419 » | kana | 2007-09-23 | 231 | set wildmenu | |
| b3e2b9b0 » | kana | 2007-01-15 | 232 | set viminfo=<50,'10,h,r/a,n~/.viminfo | |
| 233 | |||||
| 929617dd » | kana | 2007-10-21 | 234 | " default 'statusline' with 'fileencoding'. | |
| 235 | let &statusline = '' | ||||
| a251119f » | kana | 2008-01-14 | 236 | let &statusline .= '%<%f %h%m%r%w' | |
| 929617dd » | kana | 2007-10-21 | 237 | let &statusline .= '%=' | |
| c3b76d8a » | kana | 2008-02-21 | 238 | "" temporary disabled. | |
| 741790d7 » | kana | 2008-02-24 | 239 | "let &statusline .= '(%{' . s:SID_PREFIX() . 'vcs_branch_name(getcwd())}) ' | |
| c7010d9a » | kana | 2009-01-12 | 240 | let &statusline .= '[%{&l:fileencoding == "" ? &encoding : &l:fileencoding}]' | |
| 929617dd » | kana | 2007-10-21 | 241 | let &statusline .= ' %-14.(%l,%c%V%) %P' | |
| 242 | |||||
| aebdf5f3 » | kana | 2008-12-11 | 243 | function! s:my_tabline() "{{{ | |
| d87dedaf » | kana | 2007-11-22 | 244 | let s = '' | |
| 245 | |||||
| 246 | for i in range(1, tabpagenr('$')) | ||||
| 08e68c23 » | kana | 2008-01-23 | 247 | let bufnrs = tabpagebuflist(i) | |
| 248 | let curbufnr = bufnrs[tabpagewinnr(i) - 1] " first window, first appears | ||||
| 249 | |||||
| 55bd4e49 » | kana | 2008-02-11 | 250 | let no = (i <= 10 ? i-1 : '#') " display 0-origin tabpagenr. | |
| 08e68c23 » | kana | 2008-01-23 | 251 | let mod = len(filter(bufnrs, 'getbufvar(v:val, "&modified")')) ? '+' : ' ' | |
| 414cc3df » | kana | 2008-05-04 | 252 | let title = s:gettabvar(i, 'title') | |
| 253 | let title = len(title) ? title : fnamemodify(s:gettabvar(i, 'cwd'), ':t') | ||||
| 08e68c23 » | kana | 2008-01-23 | 254 | let title = len(title) ? title : fnamemodify(bufname(curbufnr),':t') | |
| 255 | let title = len(title) ? title : '[No Name]' | ||||
| d87dedaf » | kana | 2007-11-22 | 256 | ||
| 257 | let s .= '%'.i.'T' | ||||
| 258 | let s .= '%#' . (i == tabpagenr() ? 'TabLineSel' : 'TabLine') . '#' | ||||
| 73ac2940 » | kana | 2008-01-22 | 259 | let s .= no | |
| 260 | let s .= mod | ||||
| 261 | let s .= title | ||||
| d87dedaf » | kana | 2007-11-22 | 262 | let s .= '%#TabLineFill#' | |
| 263 | let s .= ' ' | ||||
| 264 | endfor | ||||
| 265 | |||||
| 266 | let s .= '%#TabLineFill#%T' | ||||
| b28b2a8f » | kana | 2008-02-24 | 267 | let s .= '%=%#TabLine#' | |
| c365129d » | kana | 2008-02-25 | 268 | let s .= '| ' | |
| 269 | let s .= '%999X' | ||||
| a6745698 » | kana | 2008-02-24 | 270 | let branch_name = s:vcs_branch_name(getcwd()) | |
| c365129d » | kana | 2008-02-25 | 271 | let s .= (branch_name != '' ? branch_name : '?') | |
| 272 | let s .= '%X' | ||||
| d87dedaf » | kana | 2007-11-22 | 273 | return s | |
| 274 | endfunction "}}} | ||||
| aebdf5f3 » | kana | 2008-12-11 | 275 | let &tabline = '%!' . s:SID_PREFIX() . 'my_tabline()' | |
| d87dedaf » | kana | 2007-11-22 | 276 | ||
| 48be31de » | kana | 2007-07-26 | 277 | " To automatically detect the width and the height of the terminal, | |
| 195a83f9 » | kana | 2007-02-16 | 278 | " the followings must not be set. | |
| 279 | " | ||||
| 0b630120 » | kana | 2007-02-16 | 280 | " set columns=80 | |
| b3e2b9b0 » | kana | 2007-01-15 | 281 | " set lines=25 | |
| 282 | |||||
| 283 | |||||
| 50c990ef » | kana | 2008-06-29 | 284 | let mapleader = ',' | |
| 285 | let maplocalleader = '.' | ||||
| b3e2b9b0 » | kana | 2007-01-15 | 286 | ||
| 287 | |||||
| 112db63e » | kana | 2008-10-24 | 288 | ||
| 289 | |||||
| 290 | " Misc. "{{{2 | ||||
| 291 | |||||
| 0d470d94 » | kana | 2007-10-10 | 292 | " Use this group for any autocmd defined in this file. | |
| 293 | augroup MyAutoCmd | ||||
| 294 | autocmd! | ||||
| 295 | augroup END | ||||
| 296 | |||||
| 297 | |||||
| fc408a4d » | kana | 2009-06-14 | 298 | call altercmd#load() | |
| ac175a16 » | kana | 2008-11-08 | 299 | call arpeggio#load() | |
| 82a12043 » | kana | 2008-04-26 | 300 | call idwintab#load() | |
| 301 | |||||
| 302 | |||||
| b3e2b9b0 » | kana | 2007-01-15 | 303 | ||
| 304 | |||||
| 195a83f9 » | kana | 2007-02-16 | 305 | ||
| 306 | |||||
| 307 | |||||
| 308 | |||||
| eb470fc7 » | kana | 2008-05-04 | 309 | " Syntax "{{{1 | |
| 310 | " User-defined commands to extend Vim script syntax. | ||||
| c457fd1c » | kana | 2008-05-10 | 311 | " - Place commands which are for interactive use at the bottom. | |
| eb470fc7 » | kana | 2008-05-04 | 312 | " FIXME: syntax highlighting | |
| 313 | " FIXME: completion | ||||
| 0a89677f » | kana | 2008-05-04 | 314 | " Stuffs "{{{2 | |
| 315 | |||||
| 2d161c4d » | kana | 2008-05-05 | 316 | let s:FALSE = 0 | |
| 317 | let s:TRUE = !s:FALSE | ||||
| 318 | |||||
| 319 | |||||
| 0a89677f » | kana | 2008-05-04 | 320 | function! s:separate_list(list, regexp) | |
| 321 | let i = 0 | ||||
| 322 | while i < len(a:list) && a:list[i] =~# a:regexp | ||||
| 323 | let i += 1 | ||||
| 324 | endwhile | ||||
| 325 | return [(0 < i ? a:list[:i-1] : []), a:list[(i):]] | ||||
| 326 | endfunction | ||||
| 327 | |||||
| 328 | |||||
| 2d161c4d » | kana | 2008-05-05 | 329 | function! s:contains_p(list, regexp) | |
| 330 | for item in a:list | ||||
| 331 | if item =~# a:regexp | ||||
| 332 | return s:TRUE | ||||
| 333 | endif | ||||
| 334 | endfor | ||||
| 335 | return s:FALSE | ||||
| 336 | endfunction | ||||
| 337 | |||||
| 338 | |||||
| 0a89677f » | kana | 2008-05-04 | 339 | ||
| 340 | |||||
| 0ad2eb2d » | kana | 2008-10-24 | 341 | " :map wrappers "{{{2 | |
| 342 | " Allmap - :map in all modes "{{{3 | ||||
| e6b322e9 » | kana | 2008-05-05 | 343 | ||
| 344 | command! -nargs=+ Allmap | ||||
| 345 | \ execute 'map' <q-args> | ||||
| 346 | \ | execute 'map!' <q-args> | ||||
| 347 | |||||
| 348 | command! -nargs=+ Allnoremap | ||||
| 349 | \ execute 'noremap' <q-args> | ||||
| 350 | \ | execute 'noremap!' <q-args> | ||||
| 351 | |||||
| 352 | command! -nargs=+ Allunmap | ||||
| 78e0cf35 » | kana | 2008-09-09 | 353 | \ execute 'unmap' <q-args> | |
| 354 | \ | execute 'unmap!' <q-args> | ||||
| e6b322e9 » | kana | 2008-05-05 | 355 | ||
| 356 | |||||
| 0ad2eb2d » | kana | 2008-10-24 | 357 | " Cmap - wrapper of :map to easily execute commands "{{{3 | |
| 2d161c4d » | kana | 2008-05-05 | 358 | " | |
| 359 | " :Cmap {lhs} {script} | ||||
| 360 | " Other variants: | ||||
| 1ac8b1b5 » | kana | 2008-09-09 | 361 | " Cmap!, Ccmap, Cimap, Clmap, Cnmap, Comap, Csmap, Cvmap, Cxmap, | |
| 362 | " Callmap, Cobjmap. | ||||
| 2d161c4d » | kana | 2008-05-05 | 363 | " | |
| 364 | " {lhs} | ||||
| 4b200539 » | kana | 2008-05-05 | 365 | " Same as :map. As additional :map-arguments, <count> and <noexec> are | |
| 366 | " available. | ||||
| 367 | " | ||||
| 368 | " <count> | ||||
| 369 | " Whenever {script} are executed, count effect (e.g. typing "3:" will be | ||||
| 370 | " treated as ":.,+2") is ignored unless <count> is specified. | ||||
| 2d161c4d » | kana | 2008-05-05 | 371 | " | |
| 4b200539 » | kana | 2008-05-05 | 372 | " <noexec> | |
| 373 | " If <noexec> is specified, {script} is just inserted in the | ||||
| 374 | " Command-line, but it's not executed. | ||||
| 2d161c4d » | kana | 2008-05-05 | 375 | " | |
| 376 | " {script} | ||||
| 377 | " A script which is executed whenever key sequence {lhs} are typed. | ||||
| 378 | |||||
| 025451f2 » | kana | 2008-09-09 | 379 | command! -bang -nargs=* Cmap call s:cmd_Cmap('', '<bang>', [<f-args>]) | |
| 380 | command! -nargs=* Ccmap call s:cmd_Cmap('c', '', [<f-args>]) | ||||
| 381 | command! -nargs=* Cimap call s:cmd_Cmap('i', '', [<f-args>]) | ||||
| 382 | command! -nargs=* Clmap call s:cmd_Cmap('l', '', [<f-args>]) | ||||
| 383 | command! -nargs=* Cnmap call s:cmd_Cmap('n', '', [<f-args>]) | ||||
| 384 | command! -nargs=* Comap call s:cmd_Cmap('o', '', [<f-args>]) | ||||
| 385 | command! -nargs=* Csmap call s:cmd_Cmap('s', '', [<f-args>]) | ||||
| 386 | command! -nargs=* Cvmap call s:cmd_Cmap('v', '', [<f-args>]) | ||||
| 387 | command! -nargs=* Cxmap call s:cmd_Cmap('x', '', [<f-args>]) | ||||
| 1ac8b1b5 » | kana | 2008-09-09 | 388 | command! -nargs=* Callmap call s:cmd_Cmap('All', '', [<f-args>]) | |
| 389 | command! -nargs=* Cobjmap call s:cmd_Cmap('Obj', '', [<f-args>]) | ||||
| 2d161c4d » | kana | 2008-05-05 | 390 | function! s:cmd_Cmap(prefix, suffix, args) | |
| 391 | " FIXME: This parsing may not be compatible with the original one. | ||||
| 392 | let [options, rest] = s:separate_list(a:args, | ||||
| 4b200539 » | kana | 2008-05-05 | 393 | \ '^\c<\(buffer\|expr\|script\|silent\|special\|unique\|count\|noexec\)>$') | |
| 2d161c4d » | kana | 2008-05-05 | 394 | if len(rest) < 2 | |
| 395 | throw 'Insufficient number of arguments: ' . string(rest) | ||||
| 396 | endif | ||||
| 397 | let lhs = rest[0] | ||||
| 398 | let script = rest[1:] | ||||
| 4b200539 » | kana | 2008-05-05 | 399 | let count_p = s:contains_p(options, '^\c<count>$') | |
| 400 | let noexec_p = s:contains_p(options, '^\c<noexec>$') | ||||
| 401 | call filter(options, 'v:val !~# ''^\c<\(count\|noexec\)>$''') | ||||
| 2d161c4d » | kana | 2008-05-05 | 402 | ||
| 403 | execute a:prefix.'noremap'.a:suffix join(options) lhs | ||||
| 20ff02ca » | kana | 2008-05-10 | 404 | \ ':'.(count_p ? '' : '<C-u>') . join(script) . (noexec_p ? '' : '<Return>') | |
| 2d161c4d » | kana | 2008-05-05 | 405 | endfunction | |
| 406 | |||||
| 407 | |||||
| 0ad2eb2d » | kana | 2008-10-24 | 408 | " Fmap - wrapper of :map to easily call a function "{{{3 | |
| d469a3fe » | kana | 2008-09-09 | 409 | " | |
| 410 | " :Fmap {lhs} {expression} | ||||
| 411 | " Other variants: | ||||
| 1ac8b1b5 » | kana | 2008-09-09 | 412 | " Fmap!, Fcmap, Fimap, Flmap, Fnmap, Fomap, Fsmap, Fvmap, Fxmap, | |
| 413 | " Fallmap, Fobjmap. | ||||
| d469a3fe » | kana | 2008-09-09 | 414 | " | |
| 415 | " {lhs} | ||||
| 416 | " Same as :map. | ||||
| 417 | " | ||||
| 418 | " {expression} | ||||
| 419 | " An expression to call a function (without :call). This expression is | ||||
| 420 | " executed whenever key sequence {lhs} are typed. | ||||
| 421 | |||||
| 422 | command! -bang -nargs=* Fmap call s:cmd_Fmap('', '<bang>', [<f-args>]) | ||||
| 423 | command! -nargs=* Fcmap call s:cmd_Fmap('c', '', [<f-args>]) | ||||
| 424 | command! -nargs=* Fimap call s:cmd_Fmap('i', '', [<f-args>]) | ||||
| 425 | command! -nargs=* Flmap call s:cmd_Fmap('l', '', [<f-args>]) | ||||
| 426 | command! -nargs=* Fnmap call s:cmd_Fmap('n', '', [<f-args>]) | ||||
| 427 | command! -nargs=* Fomap call s:cmd_Fmap('o', '', [<f-args>]) | ||||
| 428 | command! -nargs=* Fsmap call s:cmd_Fmap('s', '', [<f-args>]) | ||||
| 429 | command! -nargs=* Fvmap call s:cmd_Fmap('v', '', [<f-args>]) | ||||
| 430 | command! -nargs=* Fxmap call s:cmd_Fmap('x', '', [<f-args>]) | ||||
| 1ac8b1b5 » | kana | 2008-09-09 | 431 | command! -nargs=* Fallmap call s:cmd_Fmap('All', '', [<f-args>]) | |
| 432 | command! -nargs=* Fobjmap call s:cmd_Fmap('Obj', '', [<f-args>]) | ||||
| d469a3fe » | kana | 2008-09-09 | 433 | function! s:cmd_Fmap(prefix, suffix, args) | |
| 434 | " FIXME: This parsing may not be compatible with the original one. | ||||
| 435 | let [options, rest] = s:separate_list(a:args, | ||||
| 436 | \ '^\c<\(buffer\|expr\|script\|silent\|special\|unique\)>$') | ||||
| 437 | if len(rest) < 2 | ||||
| 438 | throw 'Insufficient number of arguments: ' . string(rest) | ||||
| 439 | endif | ||||
| 440 | let lhs = rest[0] | ||||
| 441 | let rhs = rest[1:] | ||||
| 442 | |||||
| 443 | execute a:prefix.'noremap'.a:suffix join(options) lhs | ||||
| 444 | \ ':<C-u>call' join(rhs) '<Return>' | ||||
| 445 | endfunction | ||||
| 446 | |||||
| 447 | |||||
| 0ad2eb2d » | kana | 2008-10-24 | 448 | " Objmap - :map for text objects "{{{3 | |
| 7bbd97b0 » | kana | 2008-10-24 | 449 | " | |
| 0ad2eb2d » | kana | 2008-10-24 | 450 | " Keys for text objects should be mapped in Visual mode and Operator-pending | |
| 451 | " mode. The following commands are just wrappers to avoid DRY violation. | ||||
| 7bbd97b0 » | kana | 2008-10-24 | 452 | ||
| 0ad2eb2d » | kana | 2008-10-24 | 453 | command! -nargs=+ Objmap | |
| 454 | \ execute 'omap' <q-args> | ||||
| 455 | \ | execute 'vmap' <q-args> | ||||
| 7bbd97b0 » | kana | 2008-10-24 | 456 | ||
| 0ad2eb2d » | kana | 2008-10-24 | 457 | command! -nargs=+ Objnoremap | |
| 458 | \ execute 'onoremap' <q-args> | ||||
| 459 | \ | execute 'vnoremap' <q-args> | ||||
| 7bbd97b0 » | kana | 2008-10-24 | 460 | ||
| 0ad2eb2d » | kana | 2008-10-24 | 461 | command! -nargs=+ Objunmap | |
| 462 | \ execute 'ounmap' <q-args> | ||||
| 463 | \ | execute 'vunmap' <q-args> | ||||
| 7bbd97b0 » | kana | 2008-10-24 | 464 | ||
| 465 | |||||
| 0ad2eb2d » | kana | 2008-10-24 | 466 | " Operatormap - :map for oeprators "{{{3 | |
| d469a3fe » | kana | 2008-09-09 | 467 | " | |
| 0ad2eb2d » | kana | 2008-10-24 | 468 | " Keys for operators should be mapped in Normal mode and Visual mode. The | |
| 469 | " following commands are just wrappers to avoid DRY violation. | ||||
| 0b247147 » | kana | 2009-05-22 | 470 | " | |
| 471 | " FIXME: How about mapping to g@ in Operator-pending mode | ||||
| 472 | " to use {operator}{operator} pattern? | ||||
| d469a3fe » | kana | 2008-09-09 | 473 | ||
| 0ad2eb2d » | kana | 2008-10-24 | 474 | command! -nargs=+ Operatormap | |
| 475 | \ execute 'nmap' <q-args> | ||||
| 476 | \ | execute 'vmap' <q-args> | ||||
| 477 | |||||
| 478 | command! -nargs=+ Operatornoremap | ||||
| 479 | \ execute 'nnoremap' <q-args> | ||||
| 480 | \ | execute 'vnoremap' <q-args> | ||||
| 481 | |||||
| 482 | command! -nargs=+ Operatorunmap | ||||
| 483 | \ execute 'nunmap' <q-args> | ||||
| 484 | \ | execute 'vunmap' <q-args> | ||||
| d469a3fe » | kana | 2008-09-09 | 485 | ||
| 486 | |||||
| 487 | |||||
| 488 | |||||
| 0ad2eb2d » | kana | 2008-10-24 | 489 | " CD - alternative :cd with more user-friendly completion "{{{2 | |
| 490 | |||||
| aebdf5f3 » | kana | 2008-12-11 | 491 | command! -complete=customlist,s:complete_cdpath -nargs=+ CD TabpageCD <args> | |
| 0ad2eb2d » | kana | 2008-10-24 | 492 | function! s:complete_cdpath(arglead, cmdline, cursorpos) | |
| 493 | return split(globpath(&cdpath, | ||||
| 494 | \ join(split(a:cmdline, '\s', s:TRUE)[1:], ' ') . '*/'), | ||||
| 495 | \ "\n") | ||||
| 496 | endfunction | ||||
| 497 | |||||
| fc408a4d » | kana | 2009-06-14 | 498 | AlterCommand cd CD | |
| 0ad2eb2d » | kana | 2008-10-24 | 499 | ||
| 500 | |||||
| 501 | |||||
| 502 | |||||
| 7f80f75b » | kana | 2008-05-08 | 503 | " Hecho, Hechon, Hechomsg - various :echo with highlight specification "{{{2 | |
| 504 | |||||
| 025451f2 » | kana | 2008-09-09 | 505 | command! -bar -nargs=+ Hecho call s:cmd_Hecho('echo', [<f-args>]) | |
| 506 | command! -bar -nargs=+ Hechon call s:cmd_Hecho('echon', [<f-args>]) | ||||
| 507 | command! -bar -nargs=+ Hechomsg call s:cmd_Hecho('echomsg', [<f-args>]) | ||||
| 7f80f75b » | kana | 2008-05-08 | 508 | function! s:cmd_Hecho(echo_command, args) | |
| 509 | let highlight_name = a:args[0] | ||||
| 510 | let messages = a:args[1:] | ||||
| 511 | |||||
| 512 | execute 'echohl' highlight_name | ||||
| 513 | execute a:echo_command join(messages) | ||||
| 514 | echohl None | ||||
| 515 | endfunction | ||||
| 516 | |||||
| 517 | |||||
| 518 | |||||
| 519 | |||||
| 0ad2eb2d » | kana | 2008-10-24 | 520 | " KeyboardLayout - declare differences of logical and physical layouts "{{{2 | |
| 521 | " | ||||
| 522 | " :KeyboardLayout {physical-key} {logical-key} | ||||
| 523 | " | ||||
| 524 | " Declare that whenever Vim gets a character {logical-key}, the | ||||
| 525 | " corresponding physical key is {physical-key}. This declaration is useful | ||||
| 526 | " to define a mapping based on physical keyboard layout. | ||||
| 527 | " | ||||
| 528 | " Example: Map the physical key {X} to {rhs}: | ||||
| 529 | " noremap <Plug>(physical-key-{X}) {rhs} | ||||
| 530 | |||||
| 531 | command! -nargs=+ KeyboardLayout call s:cmd_KeyboardLayout(<f-args>) | ||||
| 532 | function! s:cmd_KeyboardLayout(physical_key, logical_key) | ||||
| 533 | let indirect_key = '<Plug>(physical-key-' . a:physical_key . ')' | ||||
| 534 | execute 'Allmap' a:logical_key indirect_key | ||||
| 535 | execute 'Allnoremap' indirect_key a:logical_key | ||||
| 536 | endfunction | ||||
| 537 | |||||
| 538 | |||||
| 539 | |||||
| 540 | |||||
| c369f45c » | kana | 2008-05-05 | 541 | " OnFileType - wrapper of :autocmd FileType for compound 'filetype' "{{{2 | |
| 46d31b9f » | kana | 2008-02-15 | 542 | " | |
| 661b53ea » | kana | 2008-02-15 | 543 | " To write a bit of customization per 'filetype', an easy way is to write some | |
| 3cb0ddfc » | kana | 2008-03-07 | 544 | " ":autocmd"s like "autocmd FileType c". But it doesn't match to compound | |
| 661b53ea » | kana | 2008-02-15 | 545 | " 'filetype' such as "c.doxygen". So the pattern should be | |
| 3cb0ddfc » | kana | 2008-03-07 | 546 | " "{c,*.c,c.*,*.c.*}", but it's hard to read and to write. :OnFileType is | |
| 547 | " a wrapper for ":autocmd FileType" to support to write such customization. | ||||
| 661b53ea » | kana | 2008-02-15 | 548 | " | |
| 549 | " Note: If a:filetype contains one of the following characters: | ||||
| 550 | " * ? { } [ ] | ||||
| 551 | " a:filetype will be treated as-is to write customization for compound | ||||
| 552 | " 'filetype' with :OnFileType. | ||||
| 3cb0ddfc » | kana | 2008-03-07 | 553 | " | |
| 661b53ea » | kana | 2008-02-15 | 554 | " Note: If a:filetype contains one or more ",", :OnFileType will be called for | |
| 555 | " each ","-separated filetype in a:filetype. | ||||
| 46d31b9f » | kana | 2008-02-15 | 556 | " | |
| 557 | " FIXME: syntax highlighting and completion. | ||||
| 3cb0ddfc » | kana | 2008-03-07 | 558 | " | |
| 559 | " BUGS: This doesn't work for most cases because of the limit of the maximum | ||||
| 560 | " number of arguments to a function. | ||||
| 46d31b9f » | kana | 2008-02-15 | 561 | ||
| f6ad0c11 » | kana | 2008-06-29 | 562 | command! -nargs=+ OnFileType call s:cmd_OnFileType(<f-args>) | |
| 414cc3df » | kana | 2008-05-04 | 563 | function! s:cmd_OnFileType(group, filetype, ...) | |
| 46d31b9f » | kana | 2008-02-15 | 564 | let group = (a:group == '-' ? '' : a:group) | |
| 661b53ea » | kana | 2008-02-15 | 565 | let commands = join(a:000) | |
| 566 | |||||
| 567 | let SPECIAL_CHARS = '[*?{}[\]]' | ||||
| 568 | if a:filetype !~ SPECIAL_CHARS && a:filetype =~ ',' | ||||
| 569 | for ft in split(a:filetype, ',') | ||||
| 414cc3df » | kana | 2008-05-04 | 570 | call s:cmd_OnFileType(group, ft, commands) | |
| 661b53ea » | kana | 2008-02-15 | 571 | endfor | |
| 572 | return | ||||
| 573 | endif | ||||
| 574 | let filetype = (a:filetype =~ SPECIAL_CHARS | ||||
| eaf21d90 » | kana | 2008-05-04 | 575 | \ ? a:filetype | |
| 576 | \ : substitute('{x,x.*,*.x,*.x.*}', 'x', a:filetype, 'g')) | ||||
| 46d31b9f » | kana | 2008-02-15 | 577 | ||
| 578 | execute 'autocmd' group 'FileType' filetype commands | ||||
| 579 | endfunction | ||||
| 580 | |||||
| 581 | |||||
| 582 | |||||
| 583 | |||||
| c457fd1c » | kana | 2008-05-10 | 584 | " Qexecute - variant of :execute with some extensions "{{{2 | |
| 585 | " | ||||
| 586 | " Like :execute but all arguments are treated as single string like <q-args>. | ||||
| 587 | " As an extension, "[count]" will be expanded to the currently given count. | ||||
| 588 | |||||
| a74ad62d » | kana | 2008-08-24 | 589 | command! -complete=command -nargs=* Qexecute call s:cmd_Qexecute(<q-args>) | |
| c457fd1c » | kana | 2008-05-10 | 590 | function! s:cmd_Qexecute(script) | |
| 591 | execute substitute(a:script, '\[count\]', s:count(), 'g') | ||||
| 592 | endfunction | ||||
| 593 | |||||
| 594 | function! s:count(...) | ||||
| 595 | if v:count == v:count1 " is count given? | ||||
| 596 | return v:count | ||||
| 597 | else " count isn't given. (the default '' is useful for special value) | ||||
| 598 | return a:0 == 0 ? '' : a:1 | ||||
| 599 | endif | ||||
| 600 | endfunction | ||||
| 601 | |||||
| 602 | |||||
| 603 | |||||
| 604 | |||||
| 605 | " Source - wrapper of :source with echo. "{{{2 | ||||
| 606 | " FIXME: better name. | ||||
| 607 | |||||
| 608 | command! -bar -nargs=1 Source | ||||
| 609 | \ echo 'Sourcing ...' expand(<q-args>) | ||||
| 610 | \ | source <args> | ||||
| 611 | |||||
| 612 | |||||
| 613 | |||||
| 614 | |||||
| 9d585281 » | kana | 2008-10-25 | 615 | " SuspendWithAutomticCD "{{{2 | |
| 616 | " Assumption: Use GNU screen. | ||||
| 617 | " Assumption: There is a window with the title "another". | ||||
| 618 | |||||
| a58c2fb9 » | kana | 2008-10-25 | 619 | if !exists('s:GNU_SCREEN_AVAILABLE_P') | |
| 9d585281 » | kana | 2008-10-25 | 620 | " Check the existence of $WINDOW to avoid using GNU screen in Vim on | |
| 621 | " a remote machine (for example, "screen -t remote ssh example.com"). | ||||
| a58c2fb9 » | kana | 2008-10-25 | 622 | let s:GNU_SCREEN_AVAILABLE_P = len($WINDOW) != 0 | |
| 9d585281 » | kana | 2008-10-25 | 623 | endif | |
| 624 | |||||
| 625 | command! -bar -nargs=0 SuspendWithAutomticCD | ||||
| 626 | \ call s:cmd_SuspendWithAutomticCD() | ||||
| 627 | function! s:cmd_SuspendWithAutomticCD() | ||||
| a58c2fb9 » | kana | 2008-10-25 | 628 | if s:GNU_SCREEN_AVAILABLE_P | |
| 9d585281 » | kana | 2008-10-25 | 629 | " \015 = <C-m> | |
| 630 | " To avoid adding the cd script into the command-line history, | ||||
| 631 | " there are extra leading whitespaces in the cd script. | ||||
| 632 | silent execute '!screen -X eval' | ||||
| 633 | \ '''select another''' | ||||
| 634 | \ '''stuff " cd \"'.getcwd().'\" \#\#,vim-auto-cd\015"''' | ||||
| 635 | redraw! | ||||
| a58c2fb9 » | kana | 2008-10-25 | 636 | let s:GNU_SCREEN_AVAILABLE_P = (v:shell_error == 0) | |
| 9d585281 » | kana | 2008-10-25 | 637 | endif | |
| 638 | |||||
| a58c2fb9 » | kana | 2008-10-25 | 639 | if !s:GNU_SCREEN_AVAILABLE_P | |
| 9d585281 » | kana | 2008-10-25 | 640 | suspend | |
| 641 | endif | ||||
| 642 | endfunction | ||||
| 643 | |||||
| 644 | |||||
| 645 | |||||
| 646 | |||||
| aebdf5f3 » | kana | 2008-12-11 | 647 | " TabpageCD - wrapper of :cd to keep cwd for each tabpage "{{{2 | |
| c369f45c » | kana | 2008-05-05 | 648 | ||
| aebdf5f3 » | kana | 2008-12-11 | 649 | command! -nargs=? TabpageCD | |
| 0ad2eb2d » | kana | 2008-10-24 | 650 | \ execute 'cd' fnameescape(<q-args>) | |
| 651 | \ | let t:cwd = getcwd() | ||||
| c369f45c » | kana | 2008-05-05 | 652 | ||
| 0ad2eb2d » | kana | 2008-10-24 | 653 | autocmd MyAutoCmd TabEnter * | |
| 654 | \ if !exists('t:cwd') | ||||
| 655 | \ | let t:cwd = getcwd() | ||||
| 656 | \ | endif | ||||
| 657 | \ | execute 'cd' fnameescape(t:cwd) | ||||
| c369f45c » | kana | 2008-05-05 | 658 | ||
| 659 | |||||
| 660 | |||||
| 661 | |||||
| aebdf5f3 » | kana | 2008-12-11 | 662 | " TabpageTitle - name the current tabpage "{{{2 | |
| c369f45c » | kana | 2008-05-05 | 663 | ||
| aebdf5f3 » | kana | 2008-12-11 | 664 | command! -bar -nargs=* TabpageTitle | |
| 0ad2eb2d » | kana | 2008-10-24 | 665 | \ if <q-args> == '' | |
| 666 | \ | let t:title = input("Set tabpage's title to: ",'') | ||||
| 667 | \ | else | ||||
| 668 | \ | let t:title = <q-args> | ||||
| 669 | \ | endif | ||||
| c369f45c » | kana | 2008-05-05 | 670 | ||
| 60783901 » | kana | 2007-10-10 | 671 | ||
| 672 | |||||
| 673 | |||||
| 2ab6e640 » | kana | 2008-05-10 | 674 | " UsualDays - set up the layout of my usual days "{{{2 | |
| 675 | |||||
| 676 | command! -bar -nargs=0 UsualDays call s:cmd_UsualDays() | ||||
| 677 | function! s:cmd_UsualDays() | ||||
| 678 | normal! 'T | ||||
| 679 | execute 'CD' fnamemodify(expand('%'), ':p:h') | ||||
| aebdf5f3 » | kana | 2008-12-11 | 680 | TabpageTitle meta | |
| 2ab6e640 » | kana | 2008-05-10 | 681 | ||
| 682 | tabnew | ||||
| 683 | normal! 'V | ||||
| 684 | execute 'CD' fnamemodify(expand('%'), ':p:h:h') | ||||
| aebdf5f3 » | kana | 2008-12-11 | 685 | TabpageTitle config | |
| 2ab6e640 » | kana | 2008-05-10 | 686 | endfunction | |
| 687 | |||||
| 688 | |||||
| 689 | |||||
| 690 | |||||
| 0ad2eb2d » | kana | 2008-10-24 | 691 | " Utf8 and others - :edit with specified 'fileencoding' "{{{2 | |
| 692 | |||||
| 693 | command! -bang -bar -complete=file -nargs=? Cp932 | ||||
| 694 | \ edit<bang> ++enc=cp932 <args> | ||||
| 695 | command! -bang -bar -complete=file -nargs=? Eucjp | ||||
| 696 | \ edit<bang> ++enc=euc-jp <args> | ||||
| 697 | command! -bang -bar -complete=file -nargs=? Iso2022jp | ||||
| 698 | \ edit<bang> ++enc=iso-2022-jp <args> | ||||
| 699 | command! -bang -bar -complete=file -nargs=? Utf8 | ||||
| 700 | \ edit<bang> ++enc=utf-8 <args> | ||||
| 701 | |||||
| 702 | command! -bang -bar -complete=file -nargs=? Jis Iso2022jp<bang> <args> | ||||
| 703 | command! -bang -bar -complete=file -nargs=? Sjis Cp932<bang> <args> | ||||
| 704 | |||||
| 705 | |||||
| 706 | |||||
| 707 | |||||
| 4ec72cc8 » | kana | 2008-05-10 | 708 | ||
| 709 | |||||
| 710 | |||||
| 711 | |||||
| 712 | " Utilities "{{{1 | ||||
| 27a67454 » | kana | 2009-09-14 | 713 | " :grep wrappers "{{{2 | |
| 714 | " | ||||
| 715 | " To edit {pattern} easily via Command-line mode history, | ||||
| 716 | " define :Grep as follows: | ||||
| 717 | " | ||||
| 718 | " :Grep {file} ... {pattern} ==> :grep /{pattern}/ {file} ... | ||||
| 719 | " | ||||
| 720 | " :Lgrep is a :lgrep wrapper like :Grep. | ||||
| 721 | |||||
| c6b8fc16 » | kana | 2009-11-08 | 722 | command! -bar -complete=file -nargs=+ Grep call s:grep('grep', [<f-args>]) | |
| 8208536f » | kana | 2009-09-24 | 723 | command! -bar -complete=file -nargs=+ Lgrep call s:grep('lgrep', [<f-args>]) | |
| 27a67454 » | kana | 2009-09-14 | 724 | ||
| 8208536f » | kana | 2009-09-24 | 725 | function! s:grep(command, args) | |
| 4150041a » | kana | 2009-11-08 | 726 | execute a:command '/'.a:args[-1].'/' join(a:args[:-2]) | |
| 8208536f » | kana | 2009-09-24 | 727 | endfunction | |
| 27a67454 » | kana | 2009-09-14 | 728 | ||
| 729 | |||||
| 730 | |||||
| 731 | |||||
| 60783901 » | kana | 2007-10-10 | 732 | " Help-related stuffs "{{{2 | |
| 733 | |||||
| 414cc3df » | kana | 2008-05-04 | 734 | function! s:helpbufwinnr() | |
| 60783901 » | kana | 2007-10-10 | 735 | let wn = 1 | |
| 736 | while wn <= winnr('$') | ||||
| 737 | let bn = winbufnr(wn) | ||||
| 738 | if getbufvar(bn, '&buftype') == 'help' | ||||
| 739 | return [bn, wn] | ||||
| 740 | endif | ||||
| 741 | let wn = wn + 1 | ||||
| 742 | endwhile | ||||
| 743 | return [-1, 0] | ||||
| 744 | endfunction | ||||
| 745 | |||||
| 414cc3df » | kana | 2008-05-04 | 746 | function! s:close_help_window() | |
| 747 | let [help_bufnr, help_winnr] = s:helpbufwinnr() | ||||
| 60783901 » | kana | 2007-10-10 | 748 | if help_bufnr == -1 | |
| 749 | return | ||||
| 750 | endif | ||||
| 751 | |||||
| 752 | let current_winnr = winnr() | ||||
| 753 | execute help_winnr 'wincmd w' | ||||
| 754 | execute 'wincmd c' | ||||
| 755 | if current_winnr < help_winnr | ||||
| 756 | execute current_winnr 'wincmd w' | ||||
| 757 | elseif help_winnr < current_winnr | ||||
| 758 | execute (current_winnr-1) 'wincmd w' | ||||
| 759 | else | ||||
| 760 | " NOP | ||||
| 761 | endif | ||||
| 762 | endfunction | ||||
| 763 | |||||
| 764 | |||||
| 765 | |||||
| 766 | |||||
| 767 | " High-level key sequences "{{{2 | ||||
| 768 | |||||
| 414cc3df » | kana | 2008-05-04 | 769 | function! s:keys_to_complete() | |
| 06ae6e4d » | kana | 2008-01-13 | 770 | if &l:filetype ==# 'vim' | |
| 60783901 » | kana | 2007-10-10 | 771 | return "\<C-x>\<C-v>" | |
| 06ae6e4d » | kana | 2008-01-13 | 772 | elseif strlen(&l:omnifunc) | |
| 773 | return "\<C-x>\<C-o>" | ||||
| 60783901 » | kana | 2007-10-10 | 774 | else | |
| 775 | return "\<C-n>" | ||||
| 776 | endif | ||||
| 777 | endfunction | ||||
| 778 | |||||
| 779 | |||||
| 414cc3df » | kana | 2008-05-04 | 780 | function! s:keys_to_escape_command_line_mode_if_empty(key) | |
| 60783901 » | kana | 2007-10-10 | 781 | if getcmdline() == '' | |
| 782 | return "\<Esc>" | ||||
| 783 | else | ||||
| 784 | return a:key | ||||
| 785 | end | ||||
| 786 | endfunction | ||||
| 787 | |||||
| 788 | |||||
| 414cc3df » | kana | 2008-05-04 | 789 | function! s:keys_to_insert_one_character() | |
| 7f80f75b » | kana | 2008-05-08 | 790 | Hecho ModeMsg '-- INSERT (one char) --' | |
| 8d4d8c22 » | kana | 2007-10-17 | 791 | return nr2char(getchar()) . "\<Esc>" | |
| 792 | endfunction | ||||
| 793 | |||||
| 794 | |||||
| 3865d6e5 » | kana | 2009-09-26 | 795 | function! s:keys_to_select_the_last_changed_text() | |
| 796 | " It is not possible to determine whether the last operation to change text | ||||
| 797 | " is linewise or not, so guess the wise of the last operation from the range | ||||
| 798 | " of '[ and '], like wise of a register content set by setreg() without | ||||
| 799 | " {option}. | ||||
| 800 | |||||
| 801 | let col_begin = col("'[") | ||||
| 802 | let col_end = col("']") | ||||
| 803 | let length_end = len(getline("']")) | ||||
| 804 | |||||
| 805 | let maybe_linewise_p = (col_begin == 1 | ||||
| 806 | \ && (col_end == length_end | ||||
| 807 | \ || (length_end == 0 && col_end == 1))) | ||||
| 808 | return '`[' . (maybe_linewise_p ? 'V' : 'v') . '`]' | ||||
| 809 | endfunction | ||||
| 810 | |||||
| 811 | |||||
| 155b2296 » | kana | 2009-09-26 | 812 | function! s:keys_to_stop_insert_mode_completion() | |
| 813 | if pumvisible() | ||||
| 814 | return "\<C-y>" | ||||
| 815 | else | ||||
| 816 | return "\<Space>\<BS>" | ||||
| 817 | endif | ||||
| 818 | endfunction | ||||
| 819 | |||||
| 820 | |||||
| 60783901 » | kana | 2007-10-10 | 821 | ||
| 822 | |||||
| 823 | " Jump sections "{{{2 | ||||
| 824 | |||||
| 825 | " for normal mode. a:pattern is '/regexp' or '?regexp'. | ||||
| 414cc3df » | kana | 2008-05-04 | 826 | function! s:jump_section_n(pattern) | |
| ead9ab7b » | kana | 2008-10-24 | 827 | let pattern = a:pattern[1:] | |
| 828 | let forward_p = a:pattern[0] == '/' | ||||
| 829 | let flags = forward_p ? 'W' : 'Wb' | ||||
| 60783901 » | kana | 2007-10-10 | 830 | ||
| 831 | mark ' | ||||
| 832 | let i = 0 | ||||
| 833 | while i < v:count1 | ||||
| 834 | if search(pattern, flags) == 0 | ||||
| ead9ab7b » | kana | 2008-10-24 | 835 | if forward_p | |
| 60783901 » | kana | 2007-10-10 | 836 | normal! G | |
| ead9ab7b » | kana | 2008-10-24 | 837 | else | |
| 838 | normal! gg | ||||
| 60783901 » | kana | 2007-10-10 | 839 | endif | |
| 840 | break | ||||
| 841 | endif | ||||
| 842 | let i = i + 1 | ||||
| 843 | endwhile | ||||
| 844 | endfunction | ||||
| 845 | |||||
| 846 | |||||
| 847 | " for visual mode. a:motion is '[[', '[]', ']]' or ']['. | ||||
| 414cc3df » | kana | 2008-05-04 | 848 | function! s:jump_section_v(motion) | |
| 60783901 » | kana | 2007-10-10 | 849 | execute 'normal!' "gv\<Esc>" | |
| 850 | execute 'normal' v:count1 . a:motion | ||||
| 851 | let line = line('.') | ||||
| 852 | let col = col('.') | ||||
| 853 | |||||
| 854 | normal! gv | ||||
| 855 | call cursor(line, col) | ||||
| 856 | endfunction | ||||
| 857 | |||||
| 858 | |||||
| 859 | " for operator-pending mode. a:motion is '[[', '[]', ']]' or ']['. | ||||
| 414cc3df » | kana | 2008-05-04 | 860 | function! s:jump_section_o(motion) | |
| 60783901 » | kana | 2007-10-10 | 861 | execute 'normal' v:count1 . a:motion | |
| 862 | endfunction | ||||
| 863 | |||||
| 864 | |||||
| 865 | |||||
| 866 | |||||
| 468f5aea » | kana | 2009-04-26 | 867 | " Sum numbers "{{{2 | |
| 868 | |||||
| 869 | command! -bang -bar -nargs=* -range Sum | ||||
| 870 | \ <line1>,<line2>call s:cmd_Sum(<bang>0, <f-args>) | ||||
| 871 | function! s:cmd_Sum(banged_p, ...) range | ||||
| 872 | let field_number = (1 <= a:0 ? a:1 : 1) | ||||
| 873 | let field_separator = (2 <= a:0 ? a:2 : 0) | ||||
| 874 | execute a:firstline ',' a:lastline '!awk' | ||||
| 875 | \ (field_separator is 0 ? '' : '-F'.field_separator) | ||||
| 876 | \ "'" | ||||
| 877 | \ 'BEGIN {x = 0}' | ||||
| 878 | \ '{x = x + $'.field_number '}' | ||||
| 879 | \ '{if (\!' a:banged_p ') print $0}' | ||||
| 880 | \ 'END {print x}' | ||||
| 881 | \ "'" | ||||
| 882 | endfunction | ||||
| 883 | |||||
| 884 | |||||
| 885 | |||||
| 886 | |||||
| 293c926e » | kana | 2008-10-24 | 887 | " Toggle options "{{{2 | |
| 888 | |||||
| 889 | function! s:toggle_bell() | ||||
| 890 | if &visualbell | ||||
| 891 | set novisualbell t_vb& | ||||
| 892 | echo 'bell on' | ||||
| 893 | else | ||||
| 894 | set visualbell t_vb= | ||||
| 895 | echo 'bell off' | ||||
| 896 | endif | ||||
| 897 | endfunction | ||||
| 898 | |||||
| 03a19ef8 » | kana | 2009-04-26 | 899 | function! s:toggle_grepprg() | |
| 900 | " Toggle, more precisely, rotate the value of 'grepprg'. | ||||
| 901 | " If 'grepprg' has a value not listed in VALUES, | ||||
| 902 | " treat VALUES[0] as the default/fallback value, | ||||
| 903 | " and set 'grepprg' to the value. | ||||
| 904 | let VALUES = ['git grep -n', 'internal'] | ||||
| 905 | let i = (index(VALUES, &grepprg) + 1) % len(VALUES) | ||||
| 906 | |||||
| 907 | let grepprg = &grepprg | ||||
| 908 | let &grepprg = VALUES[i] | ||||
| 909 | echo "'grepprg' =" &grepprg '(was' grepprg.')' | ||||
| 910 | endfunction | ||||
| 911 | if !exists('s:loaded_my_vimrc') | ||||
| 912 | " Set 'grepprg' to my default value. In this scope, 'grepprg' has Vim's | ||||
| 913 | " default value and it differs from what I want to use. So that calling | ||||
| 914 | " s:toggle_grepprg() at here does set 'grepprg' to my default value. | ||||
| 915 | silent call s:toggle_grepprg() | ||||
| f2d0f658 » | kana | 2009-09-14 | 916 | ||
| 917 | if !has('unix') | ||||
| 918 | " For non-*nix environments, git is not usually available. To avoid error | ||||
| 919 | " and manual toggling, set 'grepprg' to my alternative value. | ||||
| 920 | silent call s:toggle_grepprg() | ||||
| 921 | endif | ||||
| 03a19ef8 » | kana | 2009-04-26 | 922 | endif | |
| 923 | |||||
| 293c926e » | kana | 2008-10-24 | 924 | function! s:toggle_option(option_name) | |
| 925 | execute 'setlocal' a:option_name.'!' | ||||
| 926 | execute 'setlocal' a:option_name.'?' | ||||
| 927 | endfunction | ||||
| 928 | |||||
| 929 | |||||
| 930 | |||||
| 931 | |||||
| 1b973ca0 » | kana | 2008-01-12 | 932 | " Window-related stuffs "{{{2 | |
| 933 | |||||
| 934 | " Are the windows :split'ed and :vsplit'ed? | ||||
| 414cc3df » | kana | 2008-05-04 | 935 | function! s:windows_jumbled_p() | |
| 1b973ca0 » | kana | 2008-01-12 | 936 | " Calculate the terminal height by some values other than 'lines'. | |
| 937 | " Don't consider about :vsplit. | ||||
| 938 | let calculated_height = &cmdheight | ||||
| 939 | let winid = winnr('$') | ||||
| 940 | while 0 < winid | ||||
| 941 | let calculated_height += 1 " statusline | ||||
| 942 | let calculated_height += winheight(winid) | ||||
| 943 | let winid = winid - 1 | ||||
| 944 | endwhile | ||||
| 945 | if &laststatus == 0 | ||||
| 946 | let calculated_height -= 1 | ||||
| 947 | elseif &laststatus == 1 && winnr('$') == 1 | ||||
| 948 | let calculated_height -= 1 | ||||
| 949 | else " &laststatus == 2 | ||||
| 950 | " nothing to do | ||||
| 951 | endif | ||||
| 952 | |||||
| 953 | " Calculate the terminal width by some values other than 'columns'. | ||||
| 954 | " Don't consider about :split. | ||||
| 955 | let calculated_width = 0 | ||||
| 956 | let winid = winnr('$') | ||||
| 957 | while 0 < winid | ||||
| 958 | let calculated_width += 1 " VertSplit | ||||
| 959 | let calculated_width += winwidth(winid) | ||||
| 960 | let winid = winid - 1 | ||||
| 961 | endwhile | ||||
| 962 | let calculated_width -= 1 | ||||
| 963 | |||||
| 964 | " If the windows are only :split'ed, &lines == calculated_height. | ||||
| 965 | " If the windows are only :vsplit'ed, &columns == calculated_width. | ||||
| 966 | " If there is only one window, both pairs are same. | ||||
| 967 | " If the windows are :split'ed and :vsplit'ed, both pairs are different. | ||||
| 968 | return (&lines != calculated_height) && (&columns != calculated_width) | ||||
| 969 | endfunction | ||||
| 970 | |||||
| 971 | |||||
| 414cc3df » | kana | 2008-05-04 | 972 | function! s:move_window_then_equalize_if_necessary(direction) | |
| 973 | let jumbled_beforep = s:windows_jumbled_p() | ||||
| 1b973ca0 » | kana | 2008-01-12 | 974 | execute 'wincmd' a:direction | |
| 414cc3df » | kana | 2008-05-04 | 975 | let jumbled_afterp = s:windows_jumbled_p() | |
| 1b973ca0 » | kana | 2008-01-12 | 976 | ||
| 977 | if jumbled_beforep || jumbled_afterp | ||||
| 978 | wincmd = | ||||
| 979 | endif | ||||
| 980 | endfunction | ||||
| 981 | |||||
| 982 | |||||
| 26dcd217 » | kana | 2008-12-11 | 983 | function! s:move_window_into_tabpage(target_tabpagenr) | |
| 55d71fe9 » | kana | 2008-01-12 | 984 | " Move the current window into a:target_tabpagenr. | |
| 26dcd217 » | kana | 2008-12-11 | 985 | " If a:target_tabpagenr is 0, move into new tabpage. | |
| 55bd4e49 » | kana | 2008-02-11 | 986 | if a:target_tabpagenr < 0 " ignore invalid number. | |
| 987 | return | ||||
| 988 | endif | ||||
| 1b973ca0 » | kana | 2008-01-12 | 989 | let original_tabnr = tabpagenr() | |
| 990 | let target_bufnr = bufnr('') | ||||
| 55d71fe9 » | kana | 2008-01-12 | 991 | let window_view = winsaveview() | |
| 1b973ca0 » | kana | 2008-01-12 | 992 | ||
| 55d71fe9 » | kana | 2008-01-12 | 993 | if a:target_tabpagenr == 0 | |
| 994 | tabnew | ||||
| f4ac71ac » | kana | 2008-02-12 | 995 | tabmove " Move new tabpage at the last. | |
| 55d71fe9 » | kana | 2008-01-12 | 996 | execute target_bufnr 'buffer' | |
| 997 | let target_tabpagenr = tabpagenr() | ||||
| 998 | else | ||||
| 999 | execute a:target_tabpagenr 'tabnext' | ||||
| 1000 | let target_tabpagenr = a:target_tabpagenr | ||||
| 8bf39459 » | kana | 2008-12-11 | 1001 | " FIXME: be customizable? | |
| 1002 | execute 'topleft' target_bufnr 'sbuffer' | ||||
| 55d71fe9 » | kana | 2008-01-12 | 1003 | endif | |
| 1004 | call winrestview(window_view) | ||||
| 1b973ca0 » | kana | 2008-01-12 | 1005 | ||
| 1006 | execute original_tabnr 'tabnext' | ||||
| 1007 | if 1 < winnr('$') | ||||
| 1008 | close | ||||
| 1009 | else | ||||
| 1010 | enew | ||||
| 1011 | endif | ||||
| 1012 | |||||
| 55d71fe9 » | kana | 2008-01-12 | 1013 | execute target_tabpagenr 'tabnext' | |
| 1b973ca0 » | kana | 2008-01-12 | 1014 | endfunction | |
| 1015 | |||||
| 1016 | |||||
| 414cc3df » | kana | 2008-05-04 | 1017 | function! s:scroll_other_window(scroll_command) | |
| 93c494f8 » | kana | 2008-08-25 | 1018 | if winnr('#') == 0 || winnr('#') == winnr() | |
| 1019 | " Do nothing if there is not proper previous window. | ||||
| 1020 | " Note that winnr('#') sometime returns the number for the current window | ||||
| 1021 | " instead of 0. So the latter condition is necessary. | ||||
| 1022 | " | ||||
| 1023 | " Example session to reproduce the winnr('#') problem: | ||||
| 1024 | " tabnew | ||||
| 1025 | " wincmd v | ||||
| 1026 | " wincmd h | ||||
| 1027 | " wincmd l | ||||
| 1028 | " wincmd h | ||||
| 1029 | " echo winnr('#') " ==> 2 | ||||
| 1030 | " wincmd l | ||||
| 1031 | " wincmd c | ||||
| 1032 | " echo winnr('#') " ==> 1 -- although it should be 0. | ||||
| 1f72c0f4 » | kana | 2008-08-25 | 1033 | Hecho WarningMsg 'No window to scroll' | |
| 1b973ca0 » | kana | 2008-01-12 | 1034 | else | |
| 2904d744 » | kana | 2008-08-25 | 1035 | wincmd p | |
| 414cc3df » | kana | 2008-05-04 | 1036 | execute 'normal!' (s:count() . a:scroll_command) | |
| 2904d744 » | kana | 2008-08-25 | 1037 | wincmd p | |
| 1b973ca0 » | kana | 2008-01-12 | 1038 | endif | |
| 1039 | endfunction | ||||
| 1040 | |||||
| 1041 | |||||
| f5cfce1c » | kana | 2008-09-28 | 1042 | command! -bar -nargs=0 SplitNicely call s:split_nicely() | |
| 4e180a22 » | kana | 2008-09-28 | 1043 | function! s:split_nicely() | |
| 1044 | if 80*2 * 15/16 <= winwidth(0) " FIXME: threshold customization | ||||
| 1045 | vsplit | ||||
| 1046 | else | ||||
| 1047 | split | ||||
| 1048 | endif | ||||
| 1049 | endfunction | ||||
| 1050 | |||||
| 1051 | |||||
| 1b973ca0 » | kana | 2008-01-12 | 1052 | ||
| 1053 | |||||
| b6638a87 » | kana | 2008-02-24 | 1054 | " VCS branch name "{{{2 | |
| 1055 | " Returns the name of the current branch of the given directory. | ||||
| 1056 | " BUGS: git is only supported. | ||||
| 741790d7 » | kana | 2008-02-24 | 1057 | let s:_vcs_branch_name_cache = {} " dir_path = [branch_name, key_file_mtime] | |
| 1058 | |||||
| 1059 | |||||
| 1060 | function! s:vcs_branch_name(dir) | ||||
| 1061 | let cache_entry = get(s:_vcs_branch_name_cache, a:dir, 0) | ||||
| 1062 | if cache_entry is 0 | ||||
| eaf21d90 » | kana | 2008-05-04 | 1063 | \ || cache_entry[1] < getftime(s:_vcs_branch_name_key_file(a:dir)) | |
| 741790d7 » | kana | 2008-02-24 | 1064 | unlet cache_entry | |
| 1065 | let cache_entry = s:_vcs_branch_name(a:dir) | ||||
| 1066 | let s:_vcs_branch_name_cache[a:dir] = cache_entry | ||||
| 1067 | endif | ||||
| 1068 | |||||
| 1069 | return cache_entry[0] | ||||
| 1070 | endfunction | ||||
| 1071 | |||||
| 1072 | |||||
| 1073 | function! s:_vcs_branch_name_key_file(dir) | ||||
| 1074 | return a:dir . '/.git/HEAD' | ||||
| 1075 | endfunction | ||||
| 1076 | |||||
| 1077 | |||||
| 1078 | function! s:_vcs_branch_name(dir) | ||||
| 1079 | let head_file = s:_vcs_branch_name_key_file(a:dir) | ||||
| 1080 | let branch_name = '' | ||||
| b6638a87 » | kana | 2008-02-24 | 1081 | ||
| 1082 | if filereadable(head_file) | ||||
| 1083 | let ref_info = s:first_line(head_file) | ||||
| 1084 | if ref_info =~ '^\x\{40}$' | ||||
| e1fbc681 » | kana | 2008-02-25 | 1085 | let remote_refs_dir = a:dir . '/.git/refs/remotes/' | |
| 1086 | let remote_branches = split(glob(remote_refs_dir . '**'), "\n") | ||||
| b6638a87 » | kana | 2008-02-24 | 1087 | call filter(remote_branches, 's:first_line(v:val) ==# ref_info') | |
| 1088 | if 1 <= len(remote_branches) | ||||
| e1fbc681 » | kana | 2008-02-25 | 1089 | let branch_name = 'remote: '. remote_branches[0][len(remote_refs_dir):] | |
| b6638a87 » | kana | 2008-02-24 | 1090 | endif | |
| 1091 | else | ||||
| 1092 | let branch_name = matchlist(ref_info, '^ref: refs/heads/\(\S\+\)$')[1] | ||||
| 1093 | if branch_name == '' | ||||
| 1094 | let branch_name = ref_info | ||||
| 1095 | endif | ||||
| 1096 | endif | ||||
| 1097 | endif | ||||
| 1098 | |||||
| 741790d7 » | kana | 2008-02-24 | 1099 | return [branch_name, getftime(head_file)] | |
| b6638a87 » | kana | 2008-02-24 | 1100 | endfunction | |
| 1101 | |||||
| 1102 | |||||
| 1103 | |||||
| 1104 | |||||
| 6828f990 » | kana | 2008-10-27 | 1105 | function! s:count_sum_of_fields() "{{{2 | |
| 1106 | '<,'>!awk 'BEGIN{c=0} {c+=$1} END{print c}' | ||||
| 1107 | let _ = getline('.') | ||||
| 1108 | undo | ||||
| 1109 | '>put =_ | ||||
| 1110 | endfunction | ||||
| 1111 | |||||
| 1112 | |||||
| 1113 | |||||
| 1114 | |||||
| 293c926e » | kana | 2008-10-24 | 1115 | function! s:extend_highlight(target_group, original_group, new_settings) "{{{2 | |
| 49f2d127 » | kana | 2007-01-21 | 1116 | redir => resp | |
| 1117 | silent execute 'highlight' a:original_group | ||||
| 1118 | redir END | ||||
| 1119 | if resp =~# 'xxx cleared' | ||||
| 1120 | let original_settings = '' | ||||
| 1121 | elseif resp =~# 'xxx links to' | ||||
| 414cc3df » | kana | 2008-05-04 | 1122 | return s:extend_highlight( | |
| eaf21d90 » | kana | 2008-05-04 | 1123 | \ a:target_group, | |
| 1124 | \ substitute(resp, '\_.*xxx links to\s\+\(\S\+\)', '\1', ''), | ||||
| 1125 | \ a:new_settings | ||||
| 1126 | \ ) | ||||
| 49f2d127 » | kana | 2007-01-21 | 1127 | else " xxx {key}={arg} ... | |
| b244da18 » | kana | 2007-01-23 | 1128 | let t = substitute(resp,'\_.*xxx\(\(\_s\+[^= \t]\+=[^= \t]\+\)*\)','\1','') | |
| 1129 | let original_settings = substitute(t, '\_s\+', ' ', 'g') | ||||
| 49f2d127 » | kana | 2007-01-21 | 1130 | endif | |
| 1131 | |||||
| b244da18 » | kana | 2007-01-23 | 1132 | silent execute 'highlight' a:target_group 'NONE' | |
| eaf21d90 » | kana | 2008-05-04 | 1133 | \ '|' 'highlight' a:target_group original_settings | |
| 1134 | \ '|' 'highlight' a:target_group a:new_settings | ||||
| 49f2d127 » | kana | 2007-01-21 | 1135 | endfunction | |
| 1136 | |||||
| 1137 | |||||
| 293c926e » | kana | 2008-10-24 | 1138 | ||
| 1139 | |||||
| 1140 | function! s:first_line(file) "{{{2 | ||||
| 1141 | let lines = readfile(a:file, '', 1) | ||||
| 1142 | return 1 <= len(lines) ? lines[0] : '' | ||||
| 1143 | endfunction | ||||
| 1144 | |||||
| 1145 | |||||
| 1146 | |||||
| 1147 | |||||
| aebdf5f3 » | kana | 2008-12-11 | 1148 | function! s:gettabvar(tabpagenr, varname) "{{{2 | |
| 293c926e » | kana | 2008-10-24 | 1149 | " Wrapper for non standard (my own) built-in function gettabvar(). | |
| aebdf5f3 » | kana | 2008-12-11 | 1150 | return exists('*gettabvar') ? gettabvar(a:tabpagenr, a:varname) : '' | |
| 293c926e » | kana | 2008-10-24 | 1151 | endfunction | |
| 1152 | |||||
| 1153 | |||||
| 1154 | |||||
| 1155 | |||||
| 1156 | function! s:join_here(...) "{{{2 | ||||
| 1157 | " like join (J), but move the next line into the cursor position. | ||||
| 1158 | |||||
| ebab41d2 » | kana | 2007-10-04 | 1159 | let adjust_spacesp = a:0 ? a:1 : 1 | |
| 88ff7005 » | kana | 2007-09-21 | 1160 | let pos = getpos('.') | |
| ebab41d2 » | kana | 2007-10-04 | 1161 | let r = @" | |
| 88ff7005 » | kana | 2007-09-21 | 1162 | ||
| 6b7b0c04 » | kana | 2007-12-26 | 1163 | if line('.') == line('$') | |
| 7f80f75b » | kana | 2008-05-08 | 1164 | Hecho ErrorMsg 'Unable to join at the bottom line.' | |
| 6b7b0c04 » | kana | 2007-12-26 | 1165 | return | |
| 1166 | endif | ||||
| 1167 | |||||
| ebab41d2 » | kana | 2007-10-04 | 1168 | if adjust_spacesp " adjust spaces between texts being joined as same as J. | |
| 1169 | normal! D | ||||
| 1170 | let l = @" | ||||
| 88ff7005 » | kana | 2007-09-21 | 1171 | ||
| ebab41d2 » | kana | 2007-10-04 | 1172 | normal! J | |
| 1173 | |||||
| 1174 | call append(line('.'), '') | ||||
| 1175 | call setreg('"', l, 'c') | ||||
| 1176 | normal! jpkJ | ||||
| 1177 | else " don't adjust spaces like gJ. | ||||
| 1178 | call setreg('"', getline(line('.') + 1), 'c') | ||||
| 1179 | normal! ""Pjdd | ||||
| 1180 | endif | ||||
| 1181 | |||||
| 1182 | let @" = r | ||||
| 88ff7005 » | kana | 2007-09-21 | 1183 | call setpos('.', pos) | |
| 1184 | endfunction | ||||
| 1185 | |||||
| 1186 | |||||
| 73ac2940 » | kana | 2008-01-22 | 1187 | ||
| 1188 | |||||
| 668bc915 » | kana | 2009-09-04 | 1189 | function! s:operator_adjust_window_height(motion_wiseness) "{{{2 | |
| 1190 | execute (line("']") - line("'[") + 1) 'wincmd' '_' | ||||
| 1191 | normal! `[zt | ||||
| 1192 | endfunction | ||||
| 1193 | |||||
| 1194 | |||||
| 1195 | |||||
| 1196 | |||||
| 293c926e » | kana | 2008-10-24 | 1197 | function! s:set_short_indent() "{{{2 | |
| 1198 | setlocal expandtab softtabstop=2 shiftwidth=2 | ||||
| c3b76d8a » | kana | 2008-02-21 | 1199 | endfunction | |
| 1200 | |||||
| 1201 | |||||
| 195a83f9 » | kana | 2007-02-16 | 1202 | ||
| 1203 | |||||
| 1204 | |||||
| 1205 | |||||
| 1206 | |||||
| 1207 | |||||
| ee2fb8d1 » | kana | 2008-05-04 | 1208 | " Mappings "{{{1 | |
| 792cc7d6 » | kana | 2007-10-10 | 1209 | " FIXME: some mappings are not countable. | |
| 41fad213 » | kana | 2008-04-17 | 1210 | " Physical/Logical keyboard layout declaration "{{{2 | |
| 1211 | |||||
| 35475d81 » | kana | 2009-04-28 | 1212 | if $ENV_WORKING != 'summer' && $ENV_WORKING !=# 'winter' | |
| 7ddaf8fe » | kana | 2009-04-28 | 1213 | " Semicolon and Return are swapped by KeyRemap4MacBook, Mayu or Kinesis on | |
| 1214 | " some environments. | ||||
| eee737d5 » | kana | 2008-05-05 | 1215 | KeyboardLayout ; <Return> | |
| 1216 | KeyboardLayout : <S-Return> | ||||
| 1217 | KeyboardLayout <Return> ; | ||||
| 1218 | KeyboardLayout <S-Return> : | ||||
| 41fad213 » | kana | 2008-04-17 | 1219 | else | |
| eee737d5 » | kana | 2008-05-05 | 1220 | KeyboardLayout ; ; | |
| 1221 | KeyboardLayout : : | ||||
| 1222 | KeyboardLayout <Return> <Return> | ||||
| 1223 | KeyboardLayout <S-Return> <S-Return> | ||||
| 41fad213 » | kana | 2008-04-17 | 1224 | endif | |
| 1225 | |||||
| 1226 | |||||
| 79b462c7 » | kana | 2008-06-01 | 1227 | ||
| 1228 | |||||
| 1229 | " Lazy man's hacks on the Semicolon key "{{{2 | ||||
| 1230 | " | ||||
| ac1bb3d9 » | kana | 2008-05-04 | 1231 | " - Don't want to press Shift to enter the Command-line mode. | |
| 1232 | " - Don't want to press far Return key to input <Return>. | ||||
| 79b462c7 » | kana | 2008-06-01 | 1233 | " | |
| ac1bb3d9 » | kana | 2008-05-04 | 1234 | " Note: To override these definitions by other mappings, these must be written | |
| 1235 | " before them. | ||||
| 79b462c7 » | kana | 2008-06-01 | 1236 | ||
| ac1bb3d9 » | kana | 2008-05-04 | 1237 | noremap <Plug>(physical-key-;) : | |
| 1238 | noremap <Plug>(physical-key-:) ; | ||||
| 1239 | noremap <Plug>(physical-key-<Return>) <Return> | ||||
| 1240 | noremap <Plug>(physical-key-<S-Return>) <S-Return> | ||||
| 1241 | noremap! <Plug>(physical-key-;) <Return> | ||||
| 1242 | noremap! <Plug>(physical-key-:) <S-Return> | ||||
| 1243 | noremap! <Plug>(physical-key-<Return>) ; | ||||
| 1244 | noremap! <Plug>(physical-key-<S-Return>) : | ||||
| 1245 | |||||
| 8c8ca86b » | kana | 2009-01-17 | 1246 | " Synonyms for the far Return key. | |
| 1247 | map [Space]<Return> <Plug>(physical-key-<Return>) | ||||
| 1248 | map [Space]; <Plug>(physical-key-<Return>) | ||||
| 1249 | |||||
| 79b462c7 » | kana | 2008-06-01 | 1250 | " Experimental: to input semicolon/colon without the far Semicolon key. | |
| 9bb3b6ac » | kana | 2008-12-06 | 1251 | noremap! <Esc>, ; | |
| 1252 | noremap! <Esc>. : | ||||
| 1253 | noremap! <Esc>/ ; | ||||
| 1254 | noremap! <Esc>? : | ||||
| 79b462c7 » | kana | 2008-06-01 | 1255 | ||
| ac1bb3d9 » | kana | 2008-05-04 | 1256 | ||
| 41fad213 » | kana | 2008-04-17 | 1257 | ||
| 1258 | |||||
| b44c6353 » | kana | 2007-10-10 | 1259 | " Tag jumping "{{{2 | |
| f2552813 » | kana | 2007-10-10 | 1260 | " FIXME: the target window of :split/:vsplit version. | |
| 7ae3d3dd » | kana | 2007-03-03 | 1261 | " Fallback "{{{3 | |
| 1262 | |||||
| 1263 | " ``T'' is also disabled for consistency. | ||||
| ab470bba » | kana | 2008-05-04 | 1264 | noremap t <Nop> | |
| 1265 | noremap T <Nop> | ||||
| 7ae3d3dd » | kana | 2007-03-03 | 1266 | ||
| 1267 | " Alternatives for the original actions. | ||||
| ab470bba » | kana | 2008-05-04 | 1268 | noremap [Space]t t | |
| 1269 | noremap [Space]T T | ||||
| 7ae3d3dd » | kana | 2007-03-03 | 1270 | ||
| 1271 | |||||
| b44c6353 » | kana | 2007-10-10 | 1272 | " Basic "{{{3 | |
| 1273 | |||||
| ab470bba » | kana | 2008-05-04 | 1274 | nnoremap tt <C-]> | |
| 1275 | vnoremap tt <C-]> | ||||
| 4b200539 » | kana | 2008-05-05 | 1276 | Cnmap <silent> tj tag | |
| 1277 | Cnmap <silent> tk pop | ||||
| 1278 | Cnmap <silent> tl tags | ||||
| 1279 | Cnmap <silent> tn tnext | ||||
| 1280 | Cnmap <silent> tp tprevious | ||||
| 1281 | Cnmap <silent> tP tfirst | ||||
| 1282 | Cnmap <silent> tN tlast | ||||
| 7ae3d3dd » | kana | 2007-03-03 | 1283 | ||
| c8c91080 » | kana | 2008-01-12 | 1284 | " additions, like Web browsers | |
| ba6366d1 » | kana | 2008-04-11 | 1285 | nmap <Plug>(physical-key-<Return>) tt | |
| 1286 | vmap <Plug>(physical-key-<Return>) tt | ||||
| 7ae3d3dd » | kana | 2007-03-03 | 1287 | ||
| c8c91080 » | kana | 2008-01-12 | 1288 | " addition, interactive use. | |
| 4b200539 » | kana | 2008-05-05 | 1289 | Cnmap <noexec> t<Space> tag<Space> | |
| c8c91080 » | kana | 2008-01-12 | 1290 | ||
| 7ae3d3dd » | kana | 2007-03-03 | 1291 | ||
| b44c6353 » | kana | 2007-10-10 | 1292 | " With the preview window "{{{3 | |
| 1293 | |||||
| ab470bba » | kana | 2008-05-04 | 1294 | nnoremap t't <C-w>} | |
| 1295 | vnoremap t't <C-w>} | ||||
| 4b200539 » | kana | 2008-05-05 | 1296 | Cnmap <silent> t'n ptnext | |
| d983dc23 » | kana | 2009-09-16 | 1297 | Cnmap <silent> t'p ptprevious | |
| 4b200539 » | kana | 2008-05-05 | 1298 | Cnmap <silent> t'P ptfirst | |
| 1299 | Cnmap <silent> t'N ptlast | ||||
| 7ae3d3dd » | kana | 2007-03-03 | 1300 | ||
| 1301 | " although :pclose is not related to tag. | ||||
| 5c117084 » | kana | 2008-01-17 | 1302 | " BUGS: t'' is not related to the default meaning of ''. | |
| 4b200539 » | kana | 2008-05-05 | 1303 | Cnmap <silent> t'c pclose | |
| ab470bba » | kana | 2008-05-04 | 1304 | nmap t'z t'c | |
| 1305 | nmap t'' t'c | ||||
| 7ae3d3dd » | kana | 2007-03-03 | 1306 | ||
| 1307 | |||||
| 1308 | " With :split "{{{3 | ||||
| b44c6353 » | kana | 2007-10-10 | 1309 | ||
| ab470bba » | kana | 2008-05-04 | 1310 | nnoremap tst <C-w>] | |
| 1311 | vnoremap tst <C-w>] | ||||
| 4b200539 » | kana | 2008-05-05 | 1312 | Cnmap <silent> tsn split \| tnext | |
| 1313 | Cnmap <silent> tsp split \| tpevious | ||||
| 1314 | Cnmap <silent> tsP split \| tfirst | ||||
| 1315 | Cnmap <silent> tsN split \| tlast | ||||
| 7ae3d3dd » | kana | 2007-03-03 | 1316 | ||
| 1317 | |||||
| 1318 | " With :vertical split "{{{3 | ||||
| b44c6353 » | kana | 2007-10-10 | 1319 | ||
| 2006f11d » | kana | 2007-03-03 | 1320 | " |:vsplit|-then-|<C-]>| is simple | |
| 1321 | " but its modification to tag stacks is not same as |<C-w>]|. | ||||
| ab470bba » | kana | 2008-05-04 | 1322 | nnoremap <silent> tvt <C-]>:<C-u>vsplit<Return><C-w>p<C-t><C-w>p | |
| 1323 | vnoremap <silent> tvt <C-]>:<C-u>vsplit<Return><C-w>p<C-t><C-w>p | ||||
| 4b200539 » | kana | 2008-05-05 | 1324 | Cnmap <silent> tvn vsplit \| tnext | |
| 1325 | Cnmap <silent> tvp vsplit \| tpevious | ||||
| 1326 | Cnmap <silent> tvP vsplit \| tfirst | ||||
| 1327 | Cnmap <silent> tvN vsplit \| tlast | ||||
| 7ae3d3dd » | kana | 2007-03-03 | 1328 | ||
| 1329 | |||||
| 1330 | |||||
| 1331 | |||||
| a8b99bc4 » | kana | 2007-10-10 | 1332 | " Quickfix "{{{2 | |
| 1333 | " Fallback "{{{3 | ||||
| 1334 | |||||
| 1335 | " the prefix key. | ||||
| ab470bba » | kana | 2008-05-04 | 1336 | nnoremap q <Nop> | |
| ea54ec4d » | kana | 2007-02-26 | 1337 | ||
| a8b99bc4 » | kana | 2007-10-10 | 1338 | " alternative key for the original action. | |
| 1339 | " -- Ex-mode will be never used and recordings are rarely used. | ||||
| ab470bba » | kana | 2008-05-04 | 1340 | nnoremap Q q | |
| a8b99bc4 » | kana | 2007-10-10 | 1341 | ||
| 1342 | |||||
| 1343 | " For quickfix list "{{{3 | ||||
| 1344 | |||||
| 19899429 » | kana | 2008-05-10 | 1345 | Cnmap <silent> qj Qexecute cnext [count] | |
| 1346 | Cnmap <silent> qk Qexecute cprevious [count] | ||||
| 1347 | Cnmap <silent> qr Qexecute crewind [count] | ||||
| 1348 | Cnmap <silent> qK Qexecute cfirst [count] | ||||
| 1349 | Cnmap <silent> qJ Qexecute clast [count] | ||||
| 1350 | Cnmap <silent> qfj Qexecute cnfile [count] | ||||
| 1351 | Cnmap <silent> qfk Qexecute cpfile [count] | ||||
| 4b200539 » | kana | 2008-05-05 | 1352 | Cnmap <silent> ql clist | |
| 19899429 » | kana | 2008-05-10 | 1353 | Cnmap <silent> qq Qexecute cc [count] | |
| 1354 | Cnmap <silent> qo Qexecute copen [count] | ||||
| 4b200539 » | kana | 2008-05-05 | 1355 | Cnmap <silent> qc cclose | |
| 19899429 » | kana | 2008-05-10 | 1356 | Cnmap <silent> qp Qexecute colder [count] | |
| 1357 | Cnmap <silent> qn Qexecute cnewer [count] | ||||
| 4b200539 » | kana | 2008-05-05 | 1358 | Cnmap <silent> qm make | |
| 1359 | Cnmap <noexec> qM make<Space> | ||||
| 1360 | Cnmap <noexec> q<Space> make<Space> | ||||
| 27a67454 » | kana | 2009-09-14 | 1361 | Cnmap <noexec> qg Grep<Space> | |
| ea54ec4d » | kana | 2007-02-26 | 1362 | ||
| a8b99bc4 » | kana | 2007-10-10 | 1363 | ||
| 1364 | " For location list (mnemonic: Quickfix list for the current Window) "{{{3 | ||||
| 1365 | |||||
| 19899429 » | kana | 2008-05-10 | 1366 | Cnmap <silent> qwj Qexecute lnext [count] | |
| 1367 | Cnmap <silent> qwk Qexecute lprevious [count] | ||||
| 1368 | Cnmap <silent> qwr Qexecute lrewind [count] | ||||
| 1369 | Cnmap <silent> qwK Qexecute lfirst [count] | ||||
| 1370 | Cnmap <silent> qwJ Qexecute llast [count] | ||||
| 1371 | Cnmap <silent> qwfj Qexecute lnfile [count] | ||||
| 1372 | Cnmap <silent> qwfk Qexecute lpfile [count] | ||||
| 4b200539 » | kana | 2008-05-05 | 1373 | Cnmap <silent> qwl llist | |
| 19899429 » | kana | 2008-05-10 | 1374 | Cnmap <silent> qwq Qexecute ll [count] | |
| 1375 | Cnmap <silent> qwo Qexecute lopen [count] | ||||
| 4b200539 » | kana | 2008-05-05 | 1376 | Cnmap <silent> qwc lclose | |
| 19899429 » | kana | 2008-05-10 | 1377 | Cnmap <silent> qwp Qexecute lolder [count] | |
| 1378 | Cnmap <silent> qwn Qexecute lnewer [count] | ||||
| 4b200539 » | kana | 2008-05-05 | 1379 | Cnmap <silent> qwm lmake | |
| 1380 | Cnmap <noexec> qwM lmake<Space> | ||||
| 1381 | Cnmap <noexec> qw<Space> lmake<Space> | ||||
| 27a67454 » | kana | 2009-09-14 | 1382 | Cnmap <noexec> qwg Lgrep<Space> | |
| dc1c4a00 » | kana | 2007-02-15 | 1383 | ||
| b3e2b9b0 » | kana | 2007-01-15 | 1384 | ||
| 195a83f9 » | kana | 2007-02-16 | 1385 | ||
| 1386 | |||||
| aebdf5f3 » | kana | 2008-12-11 | 1387 | " Tabpages "{{{2 | |
| 51c76703 » | kana | 2007-10-10 | 1388 | " The mappings defined here are similar to the ones for windows. | |
| 205b649f » | kana | 2007-05-22 | 1389 | " FIXME: sometimes, hit-enter prompt appears. but no idea for the reason. | |
| 51c76703 » | kana | 2007-10-10 | 1390 | " Fallback "{{{3 | |
| 1391 | |||||
| 1392 | " the prefix key. | ||||
| 1393 | " -- see Tag jumping subsection for alternative keys for the original action | ||||
| 1394 | " of <C-t>. | ||||
| 205b649f » | kana | 2007-05-22 | 1395 | nnoremap <C-t> <Nop> | |
| 1396 | |||||
| 51c76703 » | kana | 2007-10-10 | 1397 | ||
| 1398 | " Basic "{{{3 | ||||
| 1399 | |||||
| f4ac71ac » | kana | 2008-02-12 | 1400 | " Move new tabpage at the last. | |
| 4b200539 » | kana | 2008-05-05 | 1401 | Cnmap <silent> <C-t>n tabnew \| tabmove | |
| 1402 | Cnmap <silent> <C-t>c tabclose | ||||
| 42772b54 » | kana | 2009-04-27 | 1403 | Cnmap <silent> <C-t>C tabclose! | |
| 4b200539 » | kana | 2008-05-05 | 1404 | Cnmap <silent> <C-t>o tabonly | |
| 1405 | Cnmap <silent> <C-t>i tabs | ||||
| 205b649f » | kana | 2007-05-22 | 1406 | ||
| 1407 | nmap <C-t><C-n> <C-t>n | ||||
| 1408 | nmap <C-t><C-c> <C-t>c | ||||
| 1409 | nmap <C-t><C-o> <C-t>o | ||||
| 1410 | nmap <C-t><C-i> <C-t>i | ||||
| 1411 | |||||
| aebdf5f3 » | kana | 2008-12-11 | 1412 | Cnmap <silent> <C-t>T TabpageTitle | |
| aab101ef » | kana | 2008-01-22 | 1413 | ||
| 205b649f » | kana | 2007-05-22 | 1414 | ||
| aebdf5f3 » | kana | 2008-12-11 | 1415 | " Moving around tabpages. "{{{3 | |
| 51c76703 » | kana | 2007-10-10 | 1416 | ||
| 4b200539 » | kana | 2008-05-05 | 1417 | Cnmap <silent> <C-t>j | |
| 1418 | \ execute 'tabnext' 1 + (tabpagenr() + v:count1 - 1) % tabpagenr('$') | ||||
| 19899429 » | kana | 2008-05-10 | 1419 | Cnmap <silent> <C-t>k Qexecute tabprevious [count] | |
| 4b200539 » | kana | 2008-05-05 | 1420 | Cnmap <silent> <C-t>K tabfirst | |
| 1421 | Cnmap <silent> <C-t>J tablast | ||||
| 205b649f » | kana | 2007-05-22 | 1422 | ||
| 1423 | nmap <C-t><C-j> <C-t>j | ||||
| 1424 | nmap <C-t><C-k> <C-t>k | ||||
| aab101ef » | kana | 2008-01-22 | 1425 | nmap <C-t><C-t> <C-t>j | |
| 205b649f » | kana | 2007-05-22 | 1426 | ||
| d671d479 » | kana | 2008-01-19 | 1427 | " GNU screen like mappings. | |
| 55bd4e49 » | kana | 2008-02-11 | 1428 | " Note that the numbers in {lhs}s are 0-origin. See also 'tabline'. | |
| d671d479 » | kana | 2008-01-19 | 1429 | for i in range(10) | |
| 1430 | execute 'nnoremap <silent>' ('<C-t>'.(i)) ((i+1).'gt') | ||||
| 1431 | endfor | ||||
| 1432 | unlet i | ||||
| 1433 | |||||
| 205b649f » | kana | 2007-05-22 | 1434 | ||
| aebdf5f3 » | kana | 2008-12-11 | 1435 | " Moving tabpages themselves. "{{{3 | |
| 51c76703 » | kana | 2007-10-10 | 1436 | ||
| 4b200539 » | kana | 2008-05-05 | 1437 | Cnmap <silent> <C-t>l | |
| 1438 | \ execute 'tabmove' min([tabpagenr() + v:count1 - 1, tabpagenr('$')]) | ||||
| 1439 | Cnmap <silent> <C-t>h | ||||
| 1440 | \ execute 'tabmove' max([tabpagenr() - v:count1 - 1, 0]) | ||||
| 1441 | Cnmap <silent> <C-t>L tabmove | ||||
| 1442 | Cnmap <silent> <C-t>H tabmove 0 | ||||
| 205b649f » | kana | 2007-05-22 | 1443 | ||
| 1444 | nmap <C-t><C-l> <C-t>l | ||||
| 1445 | nmap <C-t><C-h> <C-t>h | ||||
| 1446 | |||||
| 1447 | |||||
| 1448 | |||||
| 1449 | |||||
| 067981b3 » | kana | 2008-03-13 | 1450 | " Argument list "{{{2 | |
| 1451 | |||||
| 1452 | " the prefix key. | ||||
| 1453 | " -- the default action of <C-g> is almost never used. | ||||
| 1454 | nnoremap <C-g> <Nop> | ||||
| 1455 | |||||
| 1456 | |||||
| 4b200539 » | kana | 2008-05-05 | 1457 | Cnmap <noexec> <C-g><Space> args<Space> | |
| 1458 | Cnmap <silent> <C-g>l args | ||||
| 1459 | Cnmap <silent> <C-g>j next | ||||
| 1460 | Cnmap <silent> <C-g>k previous | ||||
| 1461 | Cnmap <silent> <C-g>J last | ||||
| 1462 | Cnmap <silent> <C-g>K first | ||||
| 1463 | Cnmap <silent> <C-g>wj wnext | ||||
| 1464 | Cnmap <silent> <C-g>wk wprevious | ||||
| 067981b3 » | kana | 2008-03-13 | 1465 | ||
| 1466 | nmap <C-g><C-l> <C-g>l | ||||
| 1467 | nmap <C-g><C-j> <C-g>j | ||||
| 1468 | nmap <C-g><C-k> <C-g>k | ||||
| 1469 | nmap <C-g><C-w><C-j> <C-g>wj | ||||
| 1470 | nmap <C-g><C-w><C-k> <C-g>wk | ||||
| 1471 | |||||
| 1472 | |||||
| 1473 | |||||
| 1474 | |||||
| 75a92eab » | kana | 2007-10-10 | 1475 | " Command-line editting "{{{2 | |
| 48be31de » | kana | 2007-07-26 | 1476 | ||
| 369f7c4c » | kana | 2007-09-26 | 1477 | " pseudo vi-like keys | |
| 9bb3b6ac » | kana | 2008-12-06 | 1478 | cnoremap <Esc>h <Left> | |
| 1479 | cnoremap <Esc>j <Down> | ||||
| 1480 | cnoremap <Esc>k <Up> | ||||
| 1481 | cnoremap <Esc>l <Right> | ||||
| 1482 | cnoremap <Esc>H <Home> | ||||
| 1483 | cnoremap <Esc>L <End> | ||||
| 1484 | cnoremap <Esc>w <S-Right> | ||||
| 1485 | cnoremap <Esc>b <S-Left> | ||||
| 1486 | cnoremap <Esc>x <Del> | ||||
| b3e2b9b0 » | kana | 2007-01-15 | 1487 | ||
| 369f7c4c » | kana | 2007-09-26 | 1488 | " escape Command-line mode if the command line is empty (like <C-h>) | |
| 414cc3df » | kana | 2008-05-04 | 1489 | cnoremap <expr> <C-u> <SID>keys_to_escape_command_line_mode_if_empty("\<C-u>") | |
| 1490 | cnoremap <expr> <C-w> <SID>keys_to_escape_command_line_mode_if_empty("\<C-w>") | ||||
| 369f7c4c » | kana | 2007-09-26 | 1491 | ||
| fc25b38b » | kana | 2007-10-10 | 1492 | " Search slashes easily (too lazy to prefix backslashes to slashes) | |
| 7498824f » | kana | 2008-12-13 | 1493 | cnoremap <expr> / getcmdtype() == '/' ? '\/' : '/' | |
| fc25b38b » | kana | 2007-10-10 | 1494 | ||
| b3e2b9b0 » | kana | 2007-01-15 | 1495 | ||
| 195a83f9 » | kana | 2007-02-16 | 1496 | ||
| 1497 | |||||
| cffef6b3 » | kana | 2008-08-25 | 1498 | " Experimental: Little movement in Insert mode "{{{2 | |
| 1499 | |||||
| 9bb3b6ac » | kana | 2008-12-06 | 1500 | inoremap <Esc>h <Left> | |
| 1501 | inoremap <Esc>j <Down> | ||||
| 1502 | inoremap <Esc>k <Up> | ||||
| 1503 | inoremap <Esc>l <Right> | ||||
| 1504 | |||||
| 1505 | inoremap <Esc>w <C-Right> | ||||
| 1506 | inoremap <Esc>b <C-Left> | ||||
| 1507 | inoremap <Esc>e <C-o>e | ||||
| 1508 | inoremap <Esc>W <C-o>W | ||||
| 1509 | inoremap <Esc>B <C-o>B | ||||
| 1510 | inoremap <Esc>E <C-o>E | ||||
| cffef6b3 » | kana | 2008-08-25 | 1511 | ||
| 1512 | |||||
| 1513 | |||||
| 1514 | |||||
| 81c10af2 » | kana | 2007-10-10 | 1515 | " Input: datetime "{{{2 | |
| 1516 | " | ||||
| 1517 | " Input the current date/time (Full, Date, Time). | ||||
| 1518 | " | ||||
| 1519 | " FIXME: use timezone of the system, instead of static one. | ||||
| a4ff89a0 » | kana | 2008-01-12 | 1520 | " FIXME: revise the {lhs}s, compare with the default keys of textobj-datetime. | |
| 48be31de » | kana | 2007-07-26 | 1521 | ||
| ff8f7036 » | kana | 2007-02-16 | 1522 | inoremap <Leader>dF <C-r>=strftime('%Y-%m-%dT%H:%M:%S+09:00')<Return> | |
| 1523 | inoremap <Leader>df <C-r>=strftime('%Y-%m-%dT%H:%M:%S')<Return> | ||||
| 1524 | inoremap <Leader>dd <C-r>=strftime('%Y-%m-%d')<Return> | ||||
| 5f6b32dd » | kana | 2009-09-03 | 1525 | inoremap <Leader>dm <C-r>=strftime('%Y-%m')<Return> | |
| 1526 | inoremap <Leader>dy <C-r>=strftime('%Y')<Return> | ||||
| ff8f7036 » | kana | 2007-02-16 | 1527 | inoremap <Leader>dT <C-r>=strftime('%H:%M:%S')<Return> | |
| 1528 | inoremap <Leader>dt <C-r>=strftime('%H:%M')<Return> | ||||
| b3e2b9b0 » | kana | 2007-01-15 | 1529 | ||
| 1530 | |||||
| 195a83f9 » | kana | 2007-02-16 | 1531 | ||
| 1532 | |||||
| 685d1646 » | kana | 2007-10-10 | 1533 | " Section jumping "{{{2 | |
| 1534 | " | ||||
| 1535 | " Enable *consistent* ]] and other motions in Visual and Operator-pending | ||||
| a4ff89a0 » | kana | 2008-01-12 | 1536 | " mode. Because some ftplugins provide these motions only for Normal mode and | |
| 1537 | " other ftplugins provide these motions with some faults, e.g., not countable. | ||||
| 48be31de » | kana | 2007-07-26 | 1538 | ||
| b34ae810 » | kana | 2008-05-05 | 1539 | Fvmap <silent> ]] <SID>jump_section_v(']]') | |
| 1540 | Fvmap <silent> ][ <SID>jump_section_v('][') | ||||
| 1541 | Fvmap <silent> [[ <SID>jump_section_v('[[') | ||||
| 1542 | Fvmap <silent> [] <SID>jump_section_v('[]') | ||||
| 1543 | Fomap <silent> ]] <SID>jump_section_o(']]') | ||||
| 1544 | Fomap <silent> ][ <SID>jump_section_o('][') | ||||
| 1545 | Fomap <silent> [[ <SID>jump_section_o('[[') | ||||
| 1546 | Fomap <silent> [] <SID>jump_section_o('[]') | ||||
| b3e2b9b0 » | kana | 2007-01-15 | 1547 | ||
| 1548 | |||||
| 1549 | |||||
| 1550 | |||||
| cc915f0d » | kana | 2007-10-10 | 1551 | " The <Space> "{{{2 | |
| 1552 | " | ||||
| 57d0ad0f » | kana | 2007-10-10 | 1553 | " Various hotkeys prefixed by <Space>. | |
| cc915f0d » | kana | 2007-10-10 | 1554 | ||
| 1555 | " to show <Space> in the bottom line. | ||||
| ab470bba » | kana | 2008-05-04 | 1556 | map <Space> [Space] | |
| 57d0ad0f » | kana | 2007-10-10 | 1557 | ||
| cc915f0d » | kana | 2007-10-10 | 1558 | " fallback | |
| ab470bba » | kana | 2008-05-04 | 1559 | noremap [Space] <Nop> | |
| cc915f0d » | kana | 2007-10-10 | 1560 | ||
| 1561 | |||||
| 4b200539 » | kana | 2008-05-05 | 1562 | Cnmap <silent> [Space]/ nohlsearch | |
| cc915f0d » | kana | 2007-10-10 | 1563 | ||
| b34ae810 » | kana | 2008-05-05 | 1564 | Fnmap <silent> [Space]? <SID>close_help_window() | |
| cc915f0d » | kana | 2007-10-10 | 1565 | ||
| 05d3a3da » | kana | 2008-01-12 | 1566 | " append one character | |
| 414cc3df » | kana | 2008-05-04 | 1567 | nnoremap [Space]A A<C-r>=<SID>keys_to_insert_one_character()<Return> | |
| 1568 | nnoremap [Space]a a<C-r>=<SID>keys_to_insert_one_character()<Return> | ||||
| cc915f0d » | kana | 2007-10-10 | 1569 | ||
| 6828f990 » | kana | 2008-10-27 | 1570 | Fvmap <silent> [Space]c <SID>count_sum_of_fields() | |
| 1571 | |||||
| 316ef859 » | kana | 2008-10-27 | 1572 | Cnmap <silent> [Space]e | |
| 1573 | \ setlocal encoding? termencoding? fileencoding? fileencodings? | ||||
| 1574 | Cnmap <silent> [Space]f setlocal filetype? fileencoding? fileformat? | ||||
| cc915f0d » | kana | 2007-10-10 | 1575 | ||
| f3f7e023 » | kana | 2008-11-14 | 1576 | " Close a fold. | |
| 1577 | nnoremap [Space]h zc | ||||
| 1578 | |||||
| 05d3a3da » | kana | 2008-01-12 | 1579 | " insert one character | |
| 414cc3df » | kana | 2008-05-04 | 1580 | nnoremap [Space]I I<C-r>=<SID>keys_to_insert_one_character()<Return> | |
| 1581 | nnoremap [Space]i i<C-r>=<SID>keys_to_insert_one_character()<Return> | ||||
| cc915f0d » | kana | 2007-10-10 | 1582 | ||
| f3f7e023 » | kana | 2008-11-14 | 1583 | " Open a fold. | |
| 1584 | nnoremap [Space]l zo | ||||
| 1585 | |||||
| b34ae810 » | kana | 2008-05-05 | 1586 | Fnmap <silent> [Space]J <SID>join_here(1) | |
| 1587 | Fnmap <silent> [Space]gJ <SID>join_here(0) | ||||
| cc915f0d » | kana | 2007-10-10 | 1588 | ||
| 05d3a3da » | kana | 2008-01-12 | 1589 | " unjoin " BUGS: side effect - destroy the last inserted text (".). | |
| ab470bba » | kana | 2008-05-04 | 1590 | nnoremap [Space]j i<Return><Esc> | |
| cc915f0d » | kana | 2007-10-10 | 1591 | ||
| 4b200539 » | kana | 2008-05-05 | 1592 | Cnmap <silent> [Space]m marks | |
| 1ebd5ad7 » | kana | 2008-01-13 | 1593 | ||
| ab470bba » | kana | 2008-05-04 | 1594 | nnoremap [Space]o <Nop> | |
| b34ae810 » | kana | 2008-05-05 | 1595 | Fnmap <silent> [Space]ob <SID>toggle_bell() | |
| 03a19ef8 » | kana | 2009-04-26 | 1596 | Fnmap <silent> [Space]og <SID>toggle_grepprg() | |
| b34ae810 » | kana | 2008-05-05 | 1597 | Fnmap <silent> [Space]ow <SID>toggle_option('wrap') | |
| cc915f0d » | kana | 2007-10-10 | 1598 | ||
| 4b200539 » | kana | 2008-05-05 | 1599 | Cnmap <silent> [Space]q help quickref | |
| cc915f0d » | kana | 2007-10-10 | 1600 | ||
| 4b200539 » | kana | 2008-05-05 | 1601 | Cnmap <silent> [Space]r registers | |
| cc915f0d » | kana | 2007-10-10 | 1602 | ||
| 803df8b8 » | kana | 2008-12-12 | 1603 | " FIXME: ambiguous mappings - fix or not. | |
| 668bc915 » | kana | 2009-09-04 | 1604 | Operatormap [Space]s <Plug>(operator-my-sort) | |
| 45603539 » | kana | 2009-05-22 | 1605 | omap [Space]s g@ | |
| 4b200539 » | kana | 2008-05-05 | 1606 | Cnmap <silent> [Space]s. Source $MYVIMRC | |
| 1607 | Cnmap <silent> [Space]ss Source % | ||||
| cc915f0d » | kana | 2007-10-10 | 1608 | ||
| 3b7fb7da » | kana | 2008-12-30 | 1609 | " Close all folds but including the cursor. | |
| 1610 | nnoremap [Space]v zMzv | ||||
| 1611 | |||||
| 05d3a3da » | kana | 2008-01-12 | 1612 | " for backward compatibility | |
| ab470bba » | kana | 2008-05-04 | 1613 | nmap [Space]w [Space]ow | |
| 05d3a3da » | kana | 2008-01-12 | 1614 | ||
| 1615 | " for other use. | ||||
| ab470bba » | kana | 2008-05-04 | 1616 | noremap [Space]x <Nop> | |
| 35338586 » | kana | 2007-12-27 | 1617 | ||
| 948ec41d » | kana | 2008-05-10 | 1618 | Cmap [Space]xI UsualDays | |
| 1619 | |||||
| 57d0ad0f » | kana | 2007-10-10 | 1620 | ||
| cc915f0d » | kana | 2007-10-10 | 1621 | ||
| 1622 | |||||
| 2b2b6d8d » | kana | 2007-10-17 | 1623 | " Windows "{{{2 | |
| 1624 | |||||
| f74349c0 » | kana | 2007-10-26 | 1625 | " Synonyms for the default mappings, with single key strokes. | |
| ab470bba » | kana | 2008-05-04 | 1626 | nmap <Tab> <C-i> | |
| 1627 | nmap <S-Tab> <Esc>i | ||||
| 1628 | nnoremap <C-i> <C-w>w | ||||
| 1629 | nnoremap <Esc>i <C-w>W | ||||
| fdb133d3 » | kana | 2007-11-17 | 1630 | " For other mappings (<Esc>{x} to <C-w>{x}). | |
| ab470bba » | kana | 2008-05-04 | 1631 | nmap <Esc> <C-w> | |
| fdb133d3 » | kana | 2007-11-17 | 1632 | ||
| 2b2b6d8d » | kana | 2007-10-17 | 1633 | ||
| 451b030a » | kana | 2008-01-12 | 1634 | for i in ['H', 'J', 'K', 'L'] | |
| 3f489e49 » | kana | 2008-08-24 | 1635 | execute 'Fnmap <silent> <C-w>'.i | |
| b34ae810 » | kana | 2008-05-05 | 1636 | \ '<SID>move_window_then_equalize_if_necessary("'.i.'")' | |
| 451b030a » | kana | 2008-01-12 | 1637 | endfor | |
| 1638 | unlet i | ||||
| 1639 | |||||
| fdb133d3 » | kana | 2007-11-17 | 1640 | ||
| 451b030a » | kana | 2008-01-12 | 1641 | " This {lhs} overrides the default action (Move cursor to top-left window). | |
| 1642 | " But I rarely use its {lhs}s, so this mapping is not problematic. | ||||
| b34ae810 » | kana | 2008-05-05 | 1643 | Fnmap <silent> <C-w><C-t> | |
| 26dcd217 » | kana | 2008-12-11 | 1644 | \ <SID>move_window_into_tabpage(<SID>ask_tabpage_number()) | |
| 1645 | function! s:ask_tabpage_number() | ||||
| 55bd4e49 » | kana | 2008-02-11 | 1646 | echon 'Which tabpage to move this window into? ' | |
| 1647 | |||||
| 1648 | let c = nr2char(getchar()) | ||||
| 1649 | if c =~# '[0-9]' | ||||
| 1650 | " Convert 0-origin number (typed by user) into 1-origin number (used by | ||||
| 1651 | " Vim's internal functions). See also 'tabline'. | ||||
| 1652 | return 1 + char2nr(c) - char2nr('0') | ||||
| 1653 | elseif c =~# "[\<C-c>\<Esc>]" | ||||
| 1654 | return -1 | ||||
| 1655 | else | ||||
| 1656 | return 0 | ||||
| 1657 | endif | ||||
| 1658 | endfunction | ||||
| fdb133d3 » | kana | 2007-11-17 | 1659 | ||
| f74349c0 » | kana | 2007-10-26 | 1660 | ||
| 451b030a » | kana | 2008-01-12 | 1661 | " like GNU Emacs' (scroll-other-window), | |
| 1662 | " but the target to scroll is the previous window. | ||||
| 75cd3f25 » | kana | 2007-12-29 | 1663 | for i in ['f', 'b', 'd', 'u', 'e', 'y'] | |
| 3f489e49 » | kana | 2008-08-24 | 1664 | execute 'Fnmap <silent> <C-w><C-'.i.'>' | |
| b34ae810 » | kana | 2008-05-05 | 1665 | \ '<SID>scroll_other_window("<Bslash><LT>C-'.i.'>")' | |
| 75cd3f25 » | kana | 2007-12-29 | 1666 | endfor | |
| 1667 | unlet i | ||||
| 1668 | |||||
| f74349c0 » | kana | 2007-10-26 | 1669 | ||
| f7ffdc65 » | kana | 2008-04-24 | 1670 | " Like "<C-w>q", but does ":quit!". | |
| 4b200539 » | kana | 2008-05-05 | 1671 | Cnmap <C-w>Q quit! | |
| f7ffdc65 » | kana | 2008-04-24 | 1672 | ||
| 1673 | |||||
| 6c0a7401 » | kana | 2008-09-28 | 1674 | Cnmap <C-w>y SplitNicely | |
| 1675 | |||||
| 1676 | |||||
| 35f6ce64 » | kana | 2008-10-24 | 1677 | " Search the word nearest to the cursor in new window. | |
| 1678 | nnoremap <C-w>* <C-w>s* | ||||
| 1679 | nnoremap <C-w># <C-w>s# | ||||
| 1680 | |||||
| 1681 | |||||
| 2b2b6d8d » | kana | 2007-10-17 | 1682 | ||
| 1683 | |||||
| 92089606 » | kana | 2008-09-09 | 1684 | " Text objects "{{{2 | |
| 1685 | |||||
| 1686 | " Synonyms for <> and [], same as plugin surround. | ||||
| 1687 | Objnoremap aa a> | ||||
| 1688 | Objnoremap ia i> | ||||
| 1689 | Objnoremap ar a] | ||||
| 1690 | Objnoremap ir i] | ||||
| 1691 | |||||
| 1692 | |||||
| 678b24d2 » | kana | 2008-10-24 | 1693 | " Select the last chaged text - "c" stands for "C"hanged. | |
| 1694 | " like gv | ||||
| 3865d6e5 » | kana | 2009-09-26 | 1695 | nnoremap <expr> gc <SID>keys_to_select_the_last_changed_text() | |
| 678b24d2 » | kana | 2008-10-24 | 1696 | " as a text object | |
| 1697 | Objnoremap gc :<C-u>normal gc<CR> | ||||
| 1698 | " synonyms for gc - "m" stands for "M"odified. | ||||
| 1699 | " built-in motion "gm" is overridden, but I'll never use it. | ||||
| 1700 | map gm gc | ||||
| 1701 | |||||
| 1702 | |||||
| 92089606 » | kana | 2008-09-09 | 1703 | ||
| 1704 | |||||
| edb668cb » | kana | 2008-10-24 | 1705 | " Operators "{{{2 | |
| 1706 | |||||
| 1707 | " Adjust the height of the current window as same as the selected range. | ||||
| 668bc915 » | kana | 2009-09-04 | 1708 | call operator#user#define('my-adjust-window-height', | |
| 1709 | \ s:SID_PREFIX() . 'operator_adjust_window_height') | ||||
| 1710 | map _ <Plug>(operator-my-adjust-window-height) | ||||
| 74268bbf » | kana | 2008-11-09 | 1711 | ||
| 45603539 » | kana | 2009-05-22 | 1712 | ||
| 668bc915 » | kana | 2009-09-04 | 1713 | call operator#user#define_ex_command('my-left', 'left') | |
| 1714 | call operator#user#define_ex_command('my-right', 'right') | ||||
| 1715 | call operator#user#define_ex_command('my-center', 'center') | ||||
| 1716 | Arpeggio map oh <Plug>(operator-my-left) | ||||
| 1717 | Arpeggio map ol <Plug>(operator-my-right) | ||||
| 1718 | Arpeggio map om <Plug>(operator-my-center) | ||||
| 45603539 » | kana | 2009-05-22 | 1719 | ||
| 1720 | |||||
| 668bc915 » | kana | 2009-09-04 | 1721 | call operator#user#define_ex_command('my-join', 'join') | |
| 1722 | Arpeggio map oj <Plug>(operator-my-join) | ||||
| 74268bbf » | kana | 2008-11-09 | 1723 | ||
| 1724 | |||||
| 668bc915 » | kana | 2009-09-04 | 1725 | call operator#user#define_ex_command('my-sort', 'sort') | |
| 1726 | " User key mappings will be defined later - see [Space]. | ||||
| ca18ff9f » | kana | 2008-12-12 | 1727 | ||
| 1728 | |||||
| edb668cb » | kana | 2008-10-24 | 1729 | ||
| 1730 | |||||
| cc915f0d » | kana | 2007-10-10 | 1731 | " Misc. "{{{2 | |
| 1732 | |||||
| c8124ea6 » | kana | 2008-05-05 | 1733 | Cnmap <noexec> <C-h> help<Space> | |
| 1734 | Cnmap <noexec> <C-o> edit<Space> | ||||
| 1735 | Cnmap <C-w>. edit . | ||||
| cc915f0d » | kana | 2007-10-10 | 1736 | ||
| 1737 | |||||
| 57d0ad0f » | kana | 2007-10-10 | 1738 | " Jump list | |
| 1739 | nnoremap <C-j> <C-i> | ||||
| 1740 | nnoremap <C-k> <C-o> | ||||
| 1741 | |||||
| 1742 | |||||
| 1743 | " Switch to the previously edited file (like Vz) | ||||
| 68ea6d1a » | kana | 2008-08-26 | 1744 | nnoremap <Esc>2 <C-^> | |
| 57d0ad0f » | kana | 2007-10-10 | 1745 | nmap <F2> <Esc>2 | |
| 1746 | |||||
| 1747 | |||||
| 1748 | " Disable some dangerous key. | ||||
| 1749 | nnoremap ZZ <Nop> | ||||
| 1750 | nnoremap ZQ <Nop> | ||||
| 1751 | |||||
| 1752 | |||||
| 1753 | " Use a backslash (\) to repeat last change. | ||||
| 1754 | " Since a dot (.) is used as <LocalLeader>. | ||||
| 7f37223b » | kana | 2008-12-30 | 1755 | nmap \ <Plug>(repeat-.) | |
| 57d0ad0f » | kana | 2007-10-10 | 1756 | ||
| 1757 | |||||
| 1758 | " Complete or indent. | ||||
| 414cc3df » | kana | 2008-05-04 | 1759 | inoremap <expr> <C-i> (<SID>should_indent_rather_than_complete_p() | |
| 57d0ad0f » | kana | 2007-10-10 | 1760 | \ ? '<C-i>' | |
| 414cc3df » | kana | 2008-05-04 | 1761 | \ : <SID>keys_to_complete()) | |
| 57d0ad0f » | kana | 2007-10-10 | 1762 | ||
| 414cc3df » | kana | 2008-05-04 | 1763 | function! s:should_indent_rather_than_complete_p() | |
| 57d0ad0f » | kana | 2007-10-10 | 1764 | let m = match(getline('.'), '\S') | |
| 1765 | return m == -1 || col('.')-1 <= m | ||||
| 1766 | endfunction | ||||
| 1767 | |||||
| 1768 | |||||
| 1769 | " Swap ` and ' -- I prefer ` to ' and ` is not easy to type. | ||||
| 21ddb279 » | kana | 2008-05-05 | 1770 | noremap ' ` | |
| 1771 | noremap ` ' | ||||
| 57d0ad0f » | kana | 2007-10-10 | 1772 | ||
| 1773 | |||||
| 1774 | " To be able to undo these types of deletion in Insert mode. | ||||
| 1775 | inoremap <C-w> <C-g>u<C-w> | ||||
| 1776 | inoremap <C-u> <C-g>u<C-u> | ||||
| 1777 | |||||
| 1778 | |||||
| 29ed691a » | kana | 2007-10-26 | 1779 | " Delete the content of the current line (not the line itself). | |
| 32a11004 » | kana | 2007-11-16 | 1780 | " BUGS: not repeatable. | |
| 1781 | " BUGS: the default behavior is overridden, but it's still available via "x". | ||||
| 1782 | nnoremap dl 0d$ | ||||
| 29ed691a » | kana | 2007-10-26 | 1783 | ||
| 1784 | |||||
| 073d86a2 » | kana | 2007-11-13 | 1785 | " Make I/A available in characterwise-visual and linewise-visual. | |
| b34ae810 » | kana | 2008-05-05 | 1786 | Fvmap <silent> I <SID>force_blockwise_visual('I') | |
| 1787 | Fvmap <silent> A <SID>force_blockwise_visual('A') | ||||
| 7b8df1e9 » | kana | 2007-11-30 | 1788 | ||
| 414cc3df » | kana | 2008-05-04 | 1789 | function! s:force_blockwise_visual(next_key) | |
| 26824f81 » | kana | 2007-12-26 | 1790 | if visualmode() ==# 'V' | |
| 1791 | execute "normal! `<0\<C-v>`>$" | ||||
| 1792 | else | ||||
| 1793 | execute "normal! `<\<C-v>`>" | ||||
| 7b8df1e9 » | kana | 2007-11-30 | 1794 | endif | |
| 1795 | call feedkeys(a:next_key, 'n') | ||||
| 1796 | endfunction | ||||
| 073d86a2 » | kana | 2007-11-13 | 1797 | ||
| 1798 | |||||
| 16e8c01f » | kana | 2008-11-08 | 1799 | " Like o/O, but insert additional [count] blank lines. | |
| 1800 | " The default [count] is 0, so that they do the same as the default o/O. | ||||
| 1801 | " I prefer this behavior to the default behavior of [count]o/O which repeats | ||||
| 1802 | " the next insertion [count] times, because I've never felt that it is useful. | ||||
| 2f77d419 » | kana | 2008-11-09 | 1803 | nnoremap <expr> <Plug>(arpeggio-default:o) | |
| 1804 | \ <SID>start_insert_mode_with_blank_lines('o') | ||||
| 7498824f » | kana | 2008-12-13 | 1805 | nnoremap <expr> O | |
| 2f77d419 » | kana | 2008-11-09 | 1806 | \ <SID>start_insert_mode_with_blank_lines('O') | |
| 414cc3df » | kana | 2008-05-04 | 1807 | function! s:start_insert_mode_with_blank_lines(command) | |
| 16e8c01f » | kana | 2008-11-08 | 1808 | if v:count != v:count1 | |
| 1809 | return a:command " Behave the same as the default commands. | ||||
| e164498e » | kana | 2007-11-16 | 1810 | endif | |
| ada646b8 » | kana | 2007-12-15 | 1811 | ||
| 16e8c01f » | kana | 2008-11-08 | 1812 | if a:command ==# 'o' | |
| 1813 | return "\<Esc>o" . repeat("\<Return>", v:count) | ||||
| 1814 | else " a:command ==# 'O' | ||||
| 1815 | " BUGS: Not repeatable - nothing hapens. It's possible to fix but it's | ||||
| 1816 | " too troublesome to implement and it's not so useful. | ||||
| 1817 | return "\<Esc>OX\<Esc>m'o" . repeat("\<Return>", v:count-1) . "\<Esc>''S" | ||||
| ada646b8 » | kana | 2007-12-15 | 1818 | endif | |
| e164498e » | kana | 2007-11-16 | 1819 | endfunction | |
| 1820 | |||||
| 1821 | |||||
| a6d6a75d » | kana | 2007-11-17 | 1822 | " Search for the selected text. | |
| 8af092b2 » | kana | 2009-01-12 | 1823 | Fvmap * <SID>search_the_selected_text_literaly('n') | |
| 1824 | Fvmap # <SID>search_the_selected_text_literaly('N') | ||||
| a6d6a75d » | kana | 2007-11-17 | 1825 | ||
| 8af092b2 » | kana | 2009-01-12 | 1826 | function! s:search_the_selected_text_literaly(search_command) | |
| 4f058502 » | kana | 2008-10-23 | 1827 | let reg_0 = [@0, getregtype('0')] | |
| 1828 | let reg_u = [@", getregtype('"')] | ||||
| a6d6a75d » | kana | 2007-11-17 | 1829 | ||
| 1830 | normal! gvy | ||||
| 1831 | let @/ = @0 | ||||
| e39f3bcd » | kana | 2008-10-23 | 1832 | call histadd('/', '\V' . escape(@0, '\')) | |
| 8af092b2 » | kana | 2009-01-12 | 1833 | execute 'normal!' a:search_command | |
| 1834 | let v:searchforward = a:search_command ==# 'n' | ||||
| a6d6a75d » | kana | 2007-11-17 | 1835 | ||
| 4f058502 » | kana | 2008-10-23 | 1836 | call setreg('0', reg_0[0], reg_0[1]) | |
| 1837 | call setreg('"', reg_u[0], reg_u[1]) | ||||
| a6d6a75d » | kana | 2007-11-17 | 1838 | endfunction | |
| 1839 | |||||
| e164498e » | kana | 2007-11-16 | 1840 | ||
| 9d585281 » | kana | 2008-10-25 | 1841 | Cnmap <C-z> SuspendWithAutomticCD | |
| 1842 | vnoremap <C-z> <Nop> | ||||
| 1843 | onoremap <C-z> <Nop> | ||||
| 76d636b0 » | kana | 2008-01-19 | 1844 | ||
| 1845 | |||||
| e0a9c52d » | kana | 2008-01-31 | 1846 | " Show the lines which match to the last search pattern. | |
| 4b200539 » | kana | 2008-05-05 | 1847 | Cnmap <count> g/ global//print | |
| 1848 | Cvmap <count> g/ global//print | ||||
| e0a9c52d » | kana | 2008-01-31 | 1849 | ||
| 1850 | |||||
| f76f8e06 » | kana | 2008-05-21 | 1851 | " Experimental: alternative <Esc> | |
| af7dbeb3 » | kana | 2008-08-24 | 1852 | Allnoremap <C-@> <Esc> | |
| f76f8e06 » | kana | 2008-05-21 | 1853 | ||
| e41077ec » | kana | 2008-11-14 | 1854 | " c_<Esc> mapped from something doesn't work the same as | |
| 1855 | " c_<Esc> directly typed by user. | ||||
| 1856 | cnoremap <C-@> <C-c> | ||||
| 1857 | |||||
| f76f8e06 » | kana | 2008-05-21 | 1858 | ||
| 638b65f9 » | kana | 2008-08-26 | 1859 | " Experimental: Additional keys to increment/decrement | |
| 1860 | nnoremap + <C-a> | ||||
| 1861 | nnoremap - <C-x> | ||||
| 1862 | |||||
| 1863 | |||||
| f56882e2 » | kana | 2008-12-30 | 1864 | " Disable solely typed <Leader>/<LocalLeader> to avoid unexpected behavior. | |
| 1865 | noremap <Leader> <Nop> | ||||
| 1866 | noremap <LocalLeader> <Nop> | ||||
| 1867 | |||||
| 1868 | |||||
| 71fcb943 » | kana | 2009-01-12 | 1869 | " Make searching directions consistent | |
| 97b38e1b » | kana | 2009-09-22 | 1870 | " 'zv' is harmful for Operator-pending mode and it should not be included. | |
| 1871 | " For example, 'cn' is expanded into 'cnzv' so 'zv' will be inserted. | ||||
| 1872 | nnoremap <expr> n <SID>search_forward_p() ? 'nzv' : 'Nzv' | ||||
| 1873 | nnoremap <expr> N <SID>search_forward_p() ? 'Nzv' : 'nzv' | ||||
| 1874 | vnoremap <expr> n <SID>search_forward_p() ? 'nzv' : 'Nzv' | ||||
| 1875 | vnoremap <expr> N <SID>search_forward_p() ? 'Nzv' : 'nzv' | ||||
| 1876 | onoremap <expr> n <SID>search_forward_p() ? 'n' : 'N' | ||||
| 1877 | onoremap <expr> N <SID>search_forward_p() ? 'N' : 'n' | ||||
| dfab3bc4 » | kana | 2009-09-22 | 1878 | ||
| 1879 | function! s:search_forward_p() | ||||
| 1880 | return exists('v:searchforward') ? v:searchforward : s:TRUE | ||||
| 1881 | endfunction | ||||
| 71fcb943 » | kana | 2009-01-12 | 1882 | ||
| 1883 | |||||
| 57d0ad0f » | kana | 2007-10-10 | 1884 | ||
| 1885 | |||||
| 195a83f9 » | kana | 2007-02-16 | 1886 | ||
| 1887 | |||||
| 1888 | |||||
| 1889 | |||||
| 933b1512 » | kana | 2007-10-10 | 1890 | " Filetypes "{{{1 | |
| 184db961 » | kana | 2008-03-11 | 1891 | " All filetypes "{{{2 | |
| 1892 | " Here also contains misc. autocommands. | ||||
| 0846ad45 » | kana | 2007-02-16 | 1893 | ||
| 933b1512 » | kana | 2007-10-10 | 1894 | autocmd MyAutoCmd FileType * | |
| f6ad0c11 » | kana | 2008-06-29 | 1895 | \ call s:on_FileType_any() | |
| 414cc3df » | kana | 2008-05-04 | 1896 | function! s:on_FileType_any() | |
| 195a83f9 » | kana | 2007-02-16 | 1897 | " To use my global mappings for section jumping, | |
| 933b1512 » | kana | 2007-10-10 | 1898 | " remove buffer local mappings defined by ftplugin. | |
| 788e1f41 » | kana | 2008-09-09 | 1899 | silent! Objunmap <buffer> ]] | |
| 1900 | silent! Objunmap <buffer> ][ | ||||
| 1901 | silent! Objunmap <buffer> [] | ||||
| 1902 | silent! Objunmap <buffer> [[ | ||||
| da61c319 » | kana | 2008-01-10 | 1903 | ||
| 1904 | " Make omni completion available for all filetypes. | ||||
| 1905 | if &l:omnifunc == '' | ||||
| 1906 | setlocal omnifunc=syntaxcomplete#Complete | ||||
| 1907 | endif | ||||
| b3e2b9b0 » | kana | 2007-01-15 | 1908 | endfunction | |
| 1909 | |||||
| 195a83f9 » | kana | 2007-02-16 | 1910 | ||
| 00dbed8e » | kana | 2007-10-26 | 1911 | " Fix 'fileencoding' to use 'encoding' | |
| 1912 | " if the buffer only contains 7-bit characters. | ||||
| 4c3debc3 » | kana | 2007-10-26 | 1913 | " Note that if the buffer is not 'modifiable', | |
| 1914 | " its 'fileencoding' cannot be changed, so that such buffers are skipped. | ||||
| 00dbed8e » | kana | 2007-10-26 | 1915 | autocmd MyAutoCmd BufReadPost * | |
| eaf21d90 » | kana | 2008-05-04 | 1916 | \ if &modifiable && !search('[^\x00-\x7F]', 'cnw') | |
| 1917 | \ | setlocal fileencoding= | ||||
| 1918 | \ | endif | ||||
| 00dbed8e » | kana | 2007-10-26 | 1919 | ||
| 1920 | |||||
| 184db961 » | kana | 2008-03-11 | 1921 | " Adjust highlight settings according to the current colorscheme. | |
| 933b1512 » | kana | 2007-10-10 | 1922 | autocmd MyAutoCmd ColorScheme * | |
| f6ad0c11 » | kana | 2008-06-29 | 1923 | \ call s:extend_highlight('Pmenu', 'Normal', 'cterm=underline') | |
| 1924 | \ | call s:extend_highlight('PmenuSel', 'Search', 'cterm=underline') | ||||
| 1925 | \ | call s:extend_highlight('PmenuSbar', 'Normal', 'cterm=reverse') | ||||
| 1926 | \ | call s:extend_highlight('PmenuThumb', 'Search', '') | ||||
| eaf21d90 » | kana | 2008-05-04 | 1927 | \ | |
| 1928 | \ | highlight TabLineSel | ||||
| 1929 | \ term=bold,reverse | ||||
| 1930 | \ cterm=bold,underline ctermfg=lightgray ctermbg=darkgray | ||||
| 1931 | \ | highlight TabLine | ||||
| 1932 | \ term=reverse | ||||
| ab470bba » | kana | 2008-05-04 | 1933 | \ cterm=NONE ctermfg=lightgray ctermbg=darkgray | |
| eaf21d90 » | kana | 2008-05-04 | 1934 | \ | highlight TabLineFill | |
| 1935 | \ term=reverse | ||||
| ab470bba » | kana | 2008-05-04 | 1936 | \ cterm=NONE ctermfg=lightgray ctermbg=darkgray | |
| 933b1512 » | kana | 2007-10-10 | 1937 | doautocmd MyAutoCmd ColorScheme because-colorscheme-has-been-set-above. | |
| 1938 | |||||
| 1939 | |||||
| ae41016e » | kana | 2008-03-10 | 1940 | " Automatically shift to the Insert mode | |
| 1941 | " when a multibyte character is typed in Normal mode. | ||||
| 1942 | " Note: To use nonstandard event NCmdUndefined, use the following version: | ||||
| 1943 | " http://repo.or.cz/w/vim-kana.git?a=shortlog;h=hack/ncmdundefined | ||||
| 1944 | silent! autocmd MyAutoCmd NCmdUndefined * | ||||
| f6ad0c11 » | kana | 2008-06-29 | 1945 | \ call s:shift_to_insert_mode(expand('<amatch>')) | |
| 414cc3df » | kana | 2008-05-04 | 1946 | function! s:shift_to_insert_mode(not_a_command_character) | |
| ae41016e » | kana | 2008-03-10 | 1947 | if char2nr(a:not_a_command_character) <= 0xFF " not a multibyte character? | |
| 2a42d1c9 » | kana | 2008-10-12 | 1948 | " should beep as same as the default behavior, but how? | |
| 1949 | return | ||||
| ae41016e » | kana | 2008-03-10 | 1950 | endif | |
| 1951 | |||||
| 1952 | " Take all keys in the typeahead buffer. | ||||
| 1953 | let keys = a:not_a_command_character | ||||
| 1954 | while !0 | ||||
| 1955 | let c = getchar(0) | ||||
| 1956 | if c == 0 | ||||
| 1957 | break | ||||
| 1958 | endif | ||||
| 1959 | let keys .= nr2char(c) | ||||
| 1960 | endwhile | ||||
| 1961 | |||||
| 1962 | " Shfit to Insert mode, then emulate typing the keys. | ||||
| 1963 | " Note: If :startinsert is used to shifting to Insert mode, | ||||
| 1964 | " instead of keys[0], unexpected string '<t_<fd>_>' will be inserted. | ||||
| 1965 | call feedkeys('i', 'n') | ||||
| 1966 | call feedkeys(keys, 't') | ||||
| 1967 | endfunction | ||||
| 1968 | |||||
| 1969 | |||||
| 912565d2 » | kana | 2008-03-11 | 1970 | " Unset 'paste' automatically. It's often hard to do so because of most | |
| 1971 | " mappings are disabled in Paste mode. | ||||
| 1972 | autocmd MyAutoCmd InsertLeave * set nopaste | ||||
| 20b02461 » | kana | 2009-09-26 | 1973 | " Experimental: Turn off 'paste' if idle. Because it's hard to manually | |
| 1974 | " leave Insert mode while 'paste' is turned on - custom | ||||
| 1975 | " {lhs}es to <Esc> aren't available. | ||||
| 1976 | " | ||||
| 1977 | " It's necessary to :redraw to update 'showmode' message. | ||||
| 1978 | autocmd MyAutoCmd CursorHoldI * set nopaste | redraw | ||||
| 912565d2 » | kana | 2008-03-11 | 1979 | ||
| 1980 | |||||
| 195a83f9 » | kana | 2007-02-16 | 1981 | ||
| 1982 | |||||
| 3c0add31 » | kana | 2007-10-20 | 1983 | " css "{{{2 | |
| 1984 | |||||
| 1985 | autocmd MyAutoCmd FileType css | ||||
| f6ad0c11 » | kana | 2008-06-29 | 1986 | \ call s:set_short_indent() | |
| 3c0add31 » | kana | 2007-10-20 | 1987 | ||
| 1988 | |||||
| 1989 | |||||
| 1990 | |||||
| 933b1512 » | kana | 2007-10-10 | 1991 | " dosini (.ini) "{{{2 | |
| 1992 | |||||
| 1993 | autocmd MyAutoCmd FileType dosini | ||||
| f6ad0c11 » | kana | 2008-06-29 | 1994 | \ call s:on_FileType_dosini() | |
| 0846ad45 » | kana | 2007-02-16 | 1995 | ||
| 414cc3df » | kana | 2008-05-04 | 1996 | function! s:on_FileType_dosini() | |
| c803a310 » | kana | 2008-05-17 | 1997 | " Jumping around sections. | |
| b34ae810 » | kana | 2008-05-05 | 1998 | Fnmap <buffer> <silent> ]] <SID>jump_section_n('/^\[') | |
| 1999 | Fnmap <buffer> <silent> ][ <SID>jump_section_n('/\n\[\@=') | ||||
| 2000 | Fnmap <buffer> <silent> [[ <SID>jump_section_n('?^\[') | ||||
| 2001 | Fnmap <buffer> <silent> [] <SID>jump_section_n('?\n\[\@=') | ||||
| c803a310 » | kana | 2008-05-17 | 2002 | ||
| 2003 | " Folding sections. | ||||
| 2004 | setlocal foldmethod=expr | ||||
| 2005 | let &l:foldexpr = '(getline(v:lnum)[0] == "[") ? ">1" :' | ||||
| 15f5330d » | kana | 2008-10-12 | 2006 | \ . '(getline(v:lnum) =~# ''^;.*\(__END__\|\*\*\*\)'' ? 0 : "=")' | |
| b3e2b9b0 » | kana | 2007-01-15 | 2007 | endfunction | |
| 2008 | |||||
| 2009 | |||||
| 195a83f9 » | kana | 2007-02-16 | 2010 | ||
| 2011 | |||||
| 337fc5b9 » | kana | 2009-08-22 | 2012 | " gtd "{{{2 | |
| 2013 | |||||
| 2014 | autocmd MyAutoCmd FileType gtd | ||||
| 2015 | \ nmap <buffer> <Plug>(physical-key-<Return>) <Plug>(gtd-jump-to-issue) | ||||
| 2016 | \ | let b:undo_ftplugin .= ' | silent! nunmap <buffer> <Plug>(physical-key-<Return>)' | ||||
| 2017 | |||||
| 2018 | |||||
| 2019 | |||||
| 2020 | |||||
| e453bfd6 » | kana | 2007-11-16 | 2021 | " help "{{{2 | |
| 2022 | |||||
| 5ca7c496 » | kana | 2008-07-01 | 2023 | " Removed - not so useful. | |
| 2024 | " let s:filetype_help_pattern_special = '<[^ <>]\+>' | ||||
| 2025 | |||||
| 2026 | let s:filetype_help_pattern_link = '|[^ |]\+|' | ||||
| 35a223f9 » | kana | 2008-12-12 | 2027 | let s:filetype_help_pattern_option = '''[A-Za-z0-9_-]\{2,}''' | |
| 5ca7c496 » | kana | 2008-07-01 | 2028 | let s:filetype_help_pattern_any = join([s:filetype_help_pattern_link, | |
| 2029 | \ s:filetype_help_pattern_option], | ||||
| 2030 | \ '\|') | ||||
| 2031 | |||||
| 2032 | " J/K are experimental keys. | ||||
| e453bfd6 » | kana | 2007-11-16 | 2033 | autocmd MyAutoCmd FileType help | |
| a58d11af » | kana | 2008-07-05 | 2034 | \ call s:on_FileType_help() | |
| 2035 | |||||
| 2036 | function! s:on_FileType_help() | ||||
| 2037 | call textobj#user#plugin('help', { | ||||
| 2038 | \ 'any': { | ||||
| 2039 | \ '*pattern*': s:filetype_help_pattern_any, | ||||
| 2040 | \ 'move-n': '<buffer> <LocalLeader>j', | ||||
| 2041 | \ 'move-p': '<buffer> <LocalLeader>k', | ||||
| 2042 | \ 'move-N': '<buffer> <LocalLeader>J', | ||||
| 2043 | \ 'move-P': '<buffer> <LocalLeader>K', | ||||
| 2044 | \ }, | ||||
| 2045 | \ 'link': { | ||||
| 2046 | \ '*pattern*': s:filetype_help_pattern_link, | ||||
| 2047 | \ 'move-n': '<buffer> <LocalLeader>f', | ||||
| 2048 | \ 'move-p': '<buffer> <LocalLeader>r', | ||||
| 2049 | \ 'move-N': '<buffer> <LocalLeader>F', | ||||
| 2050 | \ 'move-P': '<buffer> <LocalLeader>R', | ||||
| 2051 | \ }, | ||||
| 2052 | \ 'option': { | ||||
| 2053 | \ '*pattern*': s:filetype_help_pattern_option, | ||||
| 2054 | \ 'move-n': '<buffer> <LocalLeader>d', | ||||
| 2055 | \ 'move-p': '<buffer> <LocalLeader>e', | ||||
| 2056 | \ 'move-N': '<buffer> <LocalLeader>D', | ||||
| 2057 | \ 'move-P': '<buffer> <LocalLeader>E', | ||||
| 2058 | \ }, | ||||
| 2059 | \ }) | ||||
| 2060 | if &l:readonly | ||||
| 2061 | map <buffer> J <Plug>(textobj-help-any-n) | ||||
| 2062 | map <buffer> K <Plug>(textobj-help-any-p) | ||||
| 2063 | endif | ||||
| 2064 | endfunction | ||||
| e453bfd6 » | kana | 2007-11-16 | 2065 | ||
| 2066 | |||||
| 2067 | |||||
| 2068 | |||||
| ff088dcd » | kana | 2009-08-22 | 2069 | " issue "{{{2 | |
| 2070 | |||||
| 2071 | autocmd MyAutoCmd FileType issue | ||||
| 2072 | \ nmap <buffer> <Plug>(physical-key-<Return>) <Plug>(issue-jump-to-issue) | ||||
| 2073 | \ | let b:undo_ftplugin .= ' | silent! nunmap <buffer> <Plug>(physical-key-<Return>)' | ||||
| 2074 | |||||
| 2075 | |||||
| 2076 | |||||
| 2077 | |||||
| 933b1512 » | kana | 2007-10-10 | 2078 | " lua "{{{2 | |
| 2079 | |||||
| 2080 | autocmd MyAutoCmd FileType lua | ||||
| f6ad0c11 » | kana | 2008-06-29 | 2081 | \ call s:set_short_indent() | |
| 933b1512 » | kana | 2007-10-10 | 2082 | ||
| 2083 | |||||
| 2084 | |||||
| 2085 | |||||
| 2086 | " netrw "{{{2 | ||||
| 2087 | " | ||||
| 2088 | " Consider these buffers have "another" filetype=netrw. | ||||
| 2089 | |||||
| 2090 | autocmd MyAutoCmd BufReadPost {dav,file,ftp,http,rcp,rsync,scp,sftp}://* | ||||
| eaf21d90 » | kana | 2008-05-04 | 2091 | \ setlocal bufhidden=hide | |
| 933b1512 » | kana | 2007-10-10 | 2092 | ||
| 2093 | |||||
| 2094 | |||||
| 2095 | |||||
| 2096 | " python "{{{2 | ||||
| 2097 | |||||
| 2098 | autocmd MyAutoCmd FileType python | ||||
| f6ad0c11 » | kana | 2008-06-29 | 2099 | \ call s:set_short_indent() | |
| 50c990ef » | kana | 2008-06-29 | 2100 | \ | let python_highlight_numbers = 1 | |
| 2101 | \ | let python_highlight_builtins = 1 | ||||
| 2102 | \ | let python_highlight_space_errors = 1 | ||||
| 933b1512 » | kana | 2007-10-10 | 2103 | ||
| 2104 | |||||
| 2105 | |||||
| 2106 | |||||
| 711dabd4 » | kana | 2008-01-10 | 2107 | " ruby "{{{2 | |
| 2108 | |||||
| 2109 | autocmd MyAutoCmd FileType ruby | ||||
| f6ad0c11 » | kana | 2008-06-29 | 2110 | \ call s:set_short_indent() | |
| 711dabd4 » | kana | 2008-01-10 | 2111 | ||
| 2112 | |||||
| 2113 | |||||
| 2114 | |||||
| 6e2f04d7 » | kana | 2009-01-10 | 2115 | " scheme "{{{2 | |
| 2116 | |||||
| 2117 | let g:is_gauche = 1 | ||||
| 2118 | |||||
| 2119 | |||||
| 2120 | |||||
| 2121 | |||||
| f20823d1 » | kana | 2008-05-18 | 2122 | " sh, zsh "{{{2 | |
| 0846ad45 » | kana | 2007-02-16 | 2123 | ||
| f20823d1 » | kana | 2008-05-18 | 2124 | autocmd MyAutoCmd FileType sh,zsh | |
| f6ad0c11 » | kana | 2008-06-29 | 2125 | \ call s:set_short_indent() | |
| 933b1512 » | kana | 2007-10-10 | 2126 | ||
| 2127 | " FIXME: use $SHELL. | ||||
| b3e2b9b0 » | kana | 2007-01-15 | 2128 | let g:is_bash = 1 | |
| 2129 | |||||
| 2130 | |||||
| 2131 | |||||
| 2132 | |||||
| 933b1512 » | kana | 2007-10-10 | 2133 | " tex "{{{2 | |
| 2134 | |||||
| 2135 | autocmd MyAutoCmd FileType tex | ||||
| f6ad0c11 » | kana | 2008-06-29 | 2136 | \ call s:set_short_indent() | |
| 933b1512 » | kana | 2007-10-10 | 2137 | ||
| 2138 | |||||
| 2139 | |||||
| 2140 | |||||
| 2141 | " vim "{{{2 | ||||
| 2142 | |||||
| 2143 | autocmd MyAutoCmd FileType vim | ||||
| f6ad0c11 » | kana | 2008-06-29 | 2144 | \ call s:on_FileType_vim() | |
| 0846ad45 » | kana | 2007-02-16 | 2145 | ||
| 414cc3df » | kana | 2008-05-04 | 2146 | function! s:on_FileType_vim() | |
| f6ad0c11 » | kana | 2008-06-29 | 2147 | call s:set_short_indent() | |
| c1683ca2 » | kana | 2007-02-16 | 2148 | let vim_indent_cont = &shiftwidth | |
| f5168657 » | kana | 2007-11-13 | 2149 | ||
| 6466c3f8 » | kana | 2009-09-26 | 2150 | iabbr <buffer> je if<Return> | |
| 2151 | \else<Return> | ||||
| 2152 | \endif | ||||
| 2153 | \<Up><Up><End> | ||||
| f5168657 » | kana | 2007-11-13 | 2154 | iabbr <buffer> jf function!()<Return> | |
| ac307123 » | kana | 2009-09-26 | 2155 | \endfunction | |
| 2156 | \<Up><End><Left><Left> | ||||
| f5168657 » | kana | 2007-11-13 | 2157 | iabbr <buffer> ji if<Return> | |
| ac307123 » | kana | 2009-09-26 | 2158 | \endif | |
| 2159 | \<Up><End> | ||||
| 4d37b98a » | kana | 2009-09-26 | 2160 | iabbr <buffer> jr for<Return> | |
| 2161 | \endfor | ||||
| 2162 | \<Up><End> | ||||
| 2163 | iabbr <buffer> jt try<Return> | ||||
| 2164 | \catch /.../<Return> | ||||
| 2165 | \finally<Return> | ||||
| 2166 | \endtry | ||||
| 2167 | \<Up><Up><Up><End> | ||||
| 6466c3f8 » | kana | 2009-09-26 | 2168 | iabbr <buffer> jw while<Return> | |
| 2169 | \endwhile | ||||
| 2170 | \<Up><End> | ||||
| 4679e2f7 » | kana | 2007-11-16 | 2171 | ||
| 2172 | " Fix the default syntax to properly highlight | ||||
| 2173 | " autoload#function() and dictionary.function(). | ||||
| 2174 | syntax clear vimFunc | ||||
| 2175 | syntax match vimFunc | ||||
| eaf21d90 » | kana | 2008-05-04 | 2176 | \ "\%([sS]:\|<[sS][iI][dD]>\|\<\%(\I\i*[#.]\)\+\)\=\I\i*\ze\s*(" | |
| 2177 | \ contains=vimFuncName,vimUserFunc,vimCommand,vimNotFunc,vimExecute | ||||
| 4679e2f7 » | kana | 2007-11-16 | 2178 | syntax clear vimUserFunc | |
| 2179 | syntax match vimUserFunc contained | ||||
| eaf21d90 » | kana | 2008-05-04 | 2180 | \ "\%([sS]:\|<[sS][iI][dD]>\|\<\%(\I\i*[#.]\)\+\)\i\+\|\<\u\i*\>\|\<if\>" | |
| 2181 | \ contains=vimNotation,vimCommand | ||||
| c1683ca2 » | kana | 2007-02-16 | 2182 | endfunction | |
| 2183 | |||||
| 2184 | |||||
| 2185 | |||||
| 2186 | |||||
| d8163626 » | kana | 2007-05-26 | 2187 | " XML/SGML and other applications "{{{2 | |
| 2188 | |||||
| 933b1512 » | kana | 2007-10-10 | 2189 | autocmd MyAutoCmd FileType html,xhtml,xml,xslt | |
| f6ad0c11 » | kana | 2008-06-29 | 2190 | \ call s:on_FileType_xml() | |
| 933b1512 » | kana | 2007-10-10 | 2191 | ||
| 414cc3df » | kana | 2008-05-04 | 2192 | function! s:on_FileType_xml() | |
| f6ad0c11 » | kana | 2008-06-29 | 2193 | call s:set_short_indent() | |
| d8163626 » | kana | 2007-05-26 | 2194 | ||
| 1bb39e13 » | kana | 2007-05-26 | 2195 | " To deal with namespace prefixes and tag-name-including-hyphens. | |
| 2196 | setlocal iskeyword+=45 " hyphen (-) | ||||
| 2197 | setlocal iskeyword+=58 " colon (:) | ||||
| 2198 | |||||
| 351ac437 » | kana | 2007-06-05 | 2199 | " Support to input some parts of tags. | |
| d8163626 » | kana | 2007-05-26 | 2200 | inoremap <buffer> <LT>? </ | |
| ab470bba » | kana | 2008-05-04 | 2201 | imap <buffer> ?<LT> <LT>? | |
| d8163626 » | kana | 2007-05-26 | 2202 | inoremap <buffer> ?> /> | |
| ab470bba » | kana | 2008-05-04 | 2203 | imap <buffer> >? ?> | |
| d8163626 » | kana | 2007-05-26 | 2204 | ||
| 351ac437 » | kana | 2007-06-05 | 2205 | " Support to input some blocks. | |
| 2206 | inoremap <buffer> <LT>!C <LT>![CDATA[]]><Left><Left><Left> | ||||
| 2207 | inoremap <buffer> <LT># <LT>!----><Left><Left><Left><C-r>= | ||||
| 414cc3df » | kana | 2008-05-04 | 2208 | \<SID>on_FileType_xml_comment_dispatch() | |
| 692abb34 » | kana | 2008-01-12 | 2209 | \<Return> | |
| 351ac437 » | kana | 2007-06-05 | 2210 | ||
| 67122dc3 » | kana | 2007-07-05 | 2211 | " Complete proper end-tags. | |
| 2212 | " In the following description, {|} means the cursor position. | ||||
| d8163626 » | kana | 2007-05-26 | 2213 | ||
| 67122dc3 » | kana | 2007-07-05 | 2214 | " Insert the end tag after the cursor. | |
| d8163626 » | kana | 2007-05-26 | 2215 | " Before: <code{|} | |
| 2216 | " After: <code>{|}</code> | ||||
| 67122dc3 » | kana | 2007-07-05 | 2217 | inoremap <buffer> <LT><LT> ><LT>/<C-x><C-o><C-r>= | |
| 414cc3df » | kana | 2008-05-04 | 2218 | \<SID>keys_to_stop_insert_mode_completion() | |
| 692abb34 » | kana | 2008-01-12 | 2219 | \<Return><C-o>F<LT> | |
| d8163626 » | kana | 2007-05-26 | 2220 | ||
| 67122dc3 » | kana | 2007-07-05 | 2221 | " Wrap the cursor with the tag. | |
| d8163626 » | kana | 2007-05-26 | 2222 | " Before: <code{|} | |
| 2223 | " After: <code> | ||||
| 2224 | " {|} | ||||
| 2225 | " </code> | ||||
| 67122dc3 » | kana | 2007-07-05 | 2226 | inoremap <buffer> >> ><Return>X<Return><LT>/<C-x><C-o><C-r>= | |
| 414cc3df » | kana | 2008-05-04 | 2227 | \<SID>keys_to_stop_insert_mode_completion() | |
| 692abb34 » | kana | 2008-01-12 | 2228 | \<Return><C-o><Up><BS> | |
| 6637ac14 » | kana | 2009-02-28 | 2229 | ||
| 2230 | if search('\V\<xmlns:n="http://nicht.s8.xrea.com/"', 'cnw') != 0 | ||||
| 2231 | call s:on_FileType_nicht() | ||||
| 2232 | endif | ||||
| f90a3cd6 » | kana | 2007-05-26 | 2233 | endfunction | |
| 2234 | |||||
| d8163626 » | kana | 2007-05-26 | 2235 | ||
| 414cc3df » | kana | 2008-05-04 | 2236 | function! s:on_FileType_xml_comment_dispatch() | |
| 351ac437 » | kana | 2007-06-05 | 2237 | let c = nr2char(getchar()) | |
| 414cc3df » | kana | 2008-05-04 | 2238 | return get(s:on_FileType_xml_comment_dispatch_data, c, c) | |
| 351ac437 » | kana | 2007-06-05 | 2239 | endfunction | |
| 414cc3df » | kana | 2008-05-04 | 2240 | let s:on_FileType_xml_comment_dispatch_data = { | |
| eaf21d90 » | kana | 2008-05-04 | 2241 | \ "\<Space>": "\<Space>\<Space>\<Left>", | |
| 2242 | \ "\<Return>": "\<Return>X\<Return>\<Up>\<End>\<BS>", | ||||
| 2243 | \ '_': '', | ||||
| 2244 | \ '-': '', | ||||
| 2245 | \ '{': '{{'. "{\<Esc>", | ||||
| 2246 | \ '}': '}}'. "}\<Esc>", | ||||
| 2247 | \ '1': '{{'."{1\<Esc>", | ||||
| 2248 | \ '2': '{{'."{2\<Esc>", | ||||
| 2249 | \ '3': '{{'."{3\<Esc>", | ||||
| 2250 | \ '4': '{{'."{4\<Esc>", | ||||
| 2251 | \ '5': '{{'."{5\<Esc>", | ||||
| 2252 | \ '6': '{{'."{6\<Esc>", | ||||
| 2253 | \ '7': '{{'."{7\<Esc>", | ||||
| 2254 | \ '8': '{{'."{8\<Esc>", | ||||
| 2255 | \ '9': '{{'."{9\<Esc>", | ||||
| 2256 | \ '!': '{{'."{1\<Esc>", | ||||
| 2257 | \ '@': '{{'."{2\<Esc>", | ||||
| 2258 | \ '#': '{{'."{3\<Esc>", | ||||
| 2259 | \ '$': '{{'."{4\<Esc>", | ||||
| 2260 | \ '%': '{{'."{5\<Esc>", | ||||
| 2261 | \ '^': '{{'."{6\<Esc>", | ||||
| 2262 | \ '&': '{{'."{7\<Esc>", | ||||
| 2263 | \ '*': '{{'."{8\<Esc>", | ||||
| 2264 | \ '(': '{{'."{9\<Esc>", | ||||
| 2265 | \ } | ||||
| 351ac437 » | kana | 2007-06-05 | 2266 | ||
| 2267 | |||||
| 6637ac14 » | kana | 2009-02-28 | 2268 | function! s:on_FileType_nicht() | |
| e5c1cd97 » | kana | 2009-02-28 | 2269 | Fnmap <buffer> <silent> <LocalLeader>n <SID>nicht_add_new_topic() | |
| 6637ac14 » | kana | 2009-02-28 | 2270 | endfunction | |
| 2271 | |||||
| e5c1cd97 » | kana | 2009-02-28 | 2272 | function! s:nicht_add_new_topic() | |
| 2273 | let reg_pattern = @/ | ||||
| 2274 | |||||
| 2275 | execute 'normal!' "gg/<n:body>\<Return>" | ||||
| 2276 | put ='' | ||||
| 2277 | put ='' | ||||
| 2278 | put ='' | ||||
| 2279 | put ='' | ||||
| 2280 | put ='<n:topic datetime=\"'.strftime('%Y-%m-%dT%H:%M:%S').'\" tags=\"\">' | ||||
| 2281 | put =' <n:title></n:title>' | ||||
| 2282 | put ='' | ||||
| 2283 | put =' <p></p>' | ||||
| 2284 | put ='</n:topic>' | ||||
| 2285 | execute 'normal!' "?datetime\<Return>Wf\"" | ||||
| 2286 | |||||
| 2287 | let @/ = reg_pattern | ||||
| 2288 | endfunction | ||||
| 2289 | |||||
| 2290 | |||||
| 6637ac14 » | kana | 2009-02-28 | 2291 | ||
| d8163626 » | kana | 2007-05-26 | 2292 | ||
| 2293 | |||||
| 195a83f9 » | kana | 2007-02-16 | 2294 | ||
| 2295 | |||||
| 2296 | |||||
| 2297 | |||||
| b6850cdf » | kana | 2007-10-10 | 2298 | " Plugins "{{{1 | |
| 436029f2 » | kana | 2008-08-09 | 2299 | " bundle "{{{2 | |
| 2300 | |||||
| 2301 | autocmd MyAutoCmd User BundleAvailability | ||||
| 6f4832af » | kana | 2009-11-10 | 2302 | \ call bundle#return(s:available_bundles()) | |
| 436029f2 » | kana | 2008-08-09 | 2303 | ||
| dc25d0fd » | kana | 2009-01-09 | 2304 | autocmd MyAutoCmd User BundleUndefined!:* | |
| 6f4832af » | kana | 2009-11-10 | 2305 | \ call bundle#return(s:files_in_a_bundle(bundle#name())) | |
| 436029f2 » | kana | 2008-08-09 | 2306 | ||
| 2307 | |||||
| dc25d0fd » | kana | 2009-01-09 | 2308 | let s:CONFIG_DIR = '~/working/config' | |
| 2309 | let s:CONFIG_MAKEFILE = s:CONFIG_DIR . '/Makefile' | ||||
| 436029f2 » | kana | 2008-08-09 | 2310 | ||
| 6f4832af » | kana | 2009-11-10 | 2311 | function! s:available_bundles() | |
| 641acdd1 » | kana | 2009-11-10 | 2312 | return split(s:system('make' | |
| 2313 | \ . ' -f ' . shellescape(s:CONFIG_MAKEFILE) | ||||
| 6f4832af » | kana | 2009-11-10 | 2314 | \ . ' list-available-bundles')) | |
| 436029f2 » | kana | 2008-08-09 | 2315 | endfunction | |
| 2316 | |||||
| 6f4832af » | kana | 2009-11-10 | 2317 | function! s:files_in_a_bundle(name) | |
| 641acdd1 » | kana | 2009-11-10 | 2318 | return map(split(s:system('make' | |
| 2319 | \ . ' -f ' . shellescape(s:CONFIG_MAKEFILE) | ||||
| f52a7ba5 » | kana | 2009-05-06 | 2320 | \ . ' PACKAGE_NAME=' . a:name | |
| 6f4832af » | kana | 2009-11-10 | 2321 | \ . ' list-files-in-a-bundle')), | |
| dc25d0fd » | kana | 2009-01-09 | 2322 | \ 'fnamemodify(s:CONFIG_DIR . "/" . v:val, ":~:.")') | |
| 1979f73e » | kana | 2008-08-12 | 2323 | endfunction | |
| 2324 | |||||
| 2325 | function! s:system(command) | ||||
| 2326 | let _ = system(a:command) | ||||
| 07c635ec » | kana | 2008-08-12 | 2327 | if v:shell_error != 0 | |
| 47cf55e1 » | kana | 2009-01-09 | 2328 | echoerr 'Command failed:' string(a:command) | |
| 07c635ec » | kana | 2008-08-12 | 2329 | let _ = '' | |
| 2330 | endif | ||||
| 2331 | return _ | ||||
| 436029f2 » | kana | 2008-08-09 | 2332 | endfunction | |
| 2333 | |||||
| 2334 | |||||
| 2335 | |||||
| 2336 | |||||
| f4e694a3 » | kana | 2009-11-19 | 2337 | " exjumplist "{{{2 | |
| 2338 | |||||
| 2339 | " <C-j>/<C-k> for consistency with my UI key mappings on jumplist. | ||||
| 2340 | " BUGS: Inconsistency - <Esc>{x} is usually used for window-related operation. | ||||
| 2341 | nmap <Esc><C-j> <Plug>(exjumplist-next-buffer) | ||||
| 2342 | nmap <Esc><C-k> <Plug>(exjumplist-previous-buffer) | ||||
| 2343 | |||||
| 2344 | |||||
| 2345 | |||||
| 2346 | |||||
| 8f3af724 » | kana | 2009-09-12 | 2347 | " grex "{{{2 | |
| 2348 | |||||
| 2349 | Arpeggio map od <Plug>(operator-grex-delete) | ||||
| 2350 | Arpeggio map oy <Plug>(operator-grex-yank) | ||||
| 2351 | |||||
| 2352 | " Compatibility for oldie | ||||
| 2353 | nmap gy <Plug>(operator-grex-yank)<Plug>(textobj-entire-a) | ||||
| 2354 | vmap gy <Plug>(operator-grex-yank) | ||||
| 2355 | omap gy <Plug>(operator-grex-yank) | ||||
| 2356 | |||||
| 2357 | |||||
| 2358 | |||||
| 2359 | |||||
| f9532b38 » | kana | 2008-02-08 | 2360 | " ku "{{{2 | |
| 2361 | |||||
| 83667656 » | kana | 2009-01-17 | 2362 | autocmd MyAutoCmd FileType ku call ku#default_key_mappings(s:TRUE) | |
| 2363 | |||||
| f9bff9f7 » | kana | 2009-02-27 | 2364 | ||
| 44d49065 » | kana | 2009-02-27 | 2365 | call ku#custom_action('common', 'Yank', s:SID_PREFIX().'ku_common_action_Yank') | |
| 83667656 » | kana | 2009-01-17 | 2366 | call ku#custom_action('common', 'cd', s:SID_PREFIX().'ku_common_action_my_cd') | |
| 44d49065 » | kana | 2009-02-27 | 2367 | call ku#custom_action('common', 'yank', s:SID_PREFIX().'ku_common_action_yank') | |
| 83667656 » | kana | 2009-01-17 | 2368 | call ku#custom_action('myproject', 'default', 'common', 'tab-Right') | |
| d2814491 » | kana | 2009-05-12 | 2369 | call ku#custom_action('metarw/git', 'checkout', | |
| 2370 | \ s:SID_PREFIX().'ku_metarw_git_action_checkout') | ||||
| 83667656 » | kana | 2009-01-17 | 2371 | ||
| 02a717f2 » | kana | 2008-10-13 | 2372 | function! s:ku_common_action_my_cd(item) | |
| 2373 | if isdirectory(a:item.word) | ||||
| 2374 | execute 'CD' a:item.word | ||||
| 2375 | else " treat a:item as a file name | ||||
| 2376 | execute 'CD' fnamemodify(a:item.word, ':h') | ||||
| 2377 | endif | ||||
| 82a90f3d » | kana | 2008-02-11 | 2378 | endfunction | |
| 2379 | |||||
| 44d49065 » | kana | 2009-02-27 | 2380 | function! s:ku_common_action_yank(item) | |
| 2381 | call setreg('"', a:item.word, 'c') | ||||
| 2382 | endfunction | ||||
| 2383 | function! s:ku_common_action_Yank(item) | ||||
| 2384 | call setreg('"', a:item.word, 'l') | ||||
| 2385 | endfunction | ||||
| 2386 | |||||
| d2814491 » | kana | 2009-05-12 | 2387 | function! s:ku_metarw_git_action_checkout(item) | |
| 2388 | if a:item.ku__completed_p | ||||
| 2389 | let branch_name = matchstr(a:item.word, '^git:\zs[^:]\+\ze:') | ||||
| 2390 | let message = system('git checkout ' . shellescape(branch_name)) | ||||
| 2391 | if v:shell_error == 0 | ||||
| 2392 | echomsg 'git checkout' branch_name | ||||
| 2393 | return 0 | ||||
| 2394 | else | ||||
| 2395 | return message | ||||
| 2396 | endif | ||||
| 2397 | else | ||||
| 2398 | return 'No such branch: ' . string(a:item.word) | ||||
| 2399 | endif | ||||
| 2400 | endfunction | ||||
| 2401 | |||||
| 2402 | |||||
| 44d49065 » | kana | 2009-02-27 | 2403 | ||
| 2404 | call ku#custom_key('common', 'y', 'yank') | ||||
| 2405 | call ku#custom_key('common', 'Y', 'Yank') | ||||
| d2814491 » | kana | 2009-05-12 | 2406 | call ku#custom_key('metarw/git', '/', 'checkout') | |
| 2407 | call ku#custom_key('metarw/git', '?', 'checkout') | ||||
| 44d49065 » | kana | 2009-02-27 | 2408 | ||
| 82a90f3d » | kana | 2008-02-11 | 2409 | ||
| f9bff9f7 » | kana | 2009-02-27 | 2410 | call ku#custom_prefix('common', '.vim', $HOME.'/.vim') | |
| 2411 | call ku#custom_prefix('common', 'DL', $HOME.'/Downloads') | ||||
| 2412 | call ku#custom_prefix('common', 'HOME', $HOME) | ||||
| 2413 | call ku#custom_prefix('common', 'LA', $HOME.'/Downloads') | ||||
| 2414 | call ku#custom_prefix('common', 'VIM', $VIMRUNTIME) | ||||
| 2415 | call ku#custom_prefix('common', '~', $HOME) | ||||
| 2416 | |||||
| 2417 | |||||
| 10d5831e » | kana | 2008-10-19 | 2418 | Cnmap <silent> [Space]ka Ku args | |
| 211b614a » | kana | 2008-10-13 | 2419 | Cnmap <silent> [Space]kb Ku buffer | |
| 2420 | Cnmap <silent> [Space]kf Ku file | ||||
| e37fc61f » | kana | 2009-04-27 | 2421 | Cnmap <silent> [Space]kg Ku metarw/git | |
| a2b7e685 » | kana | 2008-12-29 | 2422 | Cnmap <silent> [Space]kh Ku history | |
| 46e26bd7 » | kana | 2008-10-13 | 2423 | Cnmap <silent> [Space]kk call ku#restart() | |
| f3089ea0 » | kana | 2008-10-13 | 2424 | " p is for packages. | |
| 2425 | Cnmap <silent> [Space]kp Ku bundle | ||||
| fd87b0c4 » | kana | 2008-10-27 | 2426 | Cnmap <silent> [Space]kq Ku quickfix | |
| a2b7e685 » | kana | 2008-12-29 | 2427 | Cnmap <silent> [Space]ks Ku source | |
| f3089ea0 » | kana | 2008-10-13 | 2428 | " w is for ~/working. | |
| 2429 | Cnmap <silent> [Space]kw Ku myproject | ||||
| f9532b38 » | kana | 2008-02-08 | 2430 | ||
| 2431 | |||||
| 2432 | |||||
| 2433 | |||||
| 35338586 » | kana | 2007-12-27 | 2434 | " narrow "{{{2 | |
| 2435 | |||||
| 4b200539 » | kana | 2008-05-05 | 2436 | Cmap <count> [Space]xn Narrow | |
| 2437 | Cmap [Space]xw Widen | ||||
| 35338586 » | kana | 2007-12-27 | 2438 | ||
| 2439 | |||||
| 2440 | |||||
| 2441 | |||||
| 8f3af724 » | kana | 2009-09-12 | 2442 | " operator-replace "{{{2 | |
| 2443 | |||||
| 2444 | Arpeggio map or <Plug>(operator-replace) | ||||
| 2445 | |||||
| 2446 | |||||
| 2447 | |||||
| 2448 | |||||
| b69d2ab4 » | kana | ||||







