Changeset 3577
- Timestamp:
- 12/26/07 02:52:57 (5 years ago)
- Location:
- dotfiles/vim/kana
- Files:
-
- 4 modified
-
dot.vim/autoload/scratch.vim (modified) (3 diffs)
-
dot.vim/doc/scratch.txt (modified) (4 diffs)
-
dot.vim/plugin/scratch.vim (modified) (1 diff)
-
dot.vimrc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dotfiles/vim/kana/dot.vim/autoload/scratch.vim
r3550 r3577 85 85 86 86 87 function! scratch#evaluate_linewise(line1, line2 ) "{{{287 function! scratch#evaluate_linewise(line1, line2, adjust_cursorp) "{{{2 88 88 let bufnr = bufnr('') 89 89 call scratch#evaluate([bufnr, a:line1, 1, 0], 90 \ [bufnr, a:line2, len(getline(a:line2)), 0]) 90 \ [bufnr, a:line2, len(getline(a:line2)), 0], 91 \ a:adjust_cursorp) 91 92 endfunction 92 93 … … 94 95 95 96 96 function! scratch#evaluate(range_head, range_tail) "{{{2 97 function! scratch#evaluate(range_head, range_tail, adjust_cursorp) "{{{2 98 " Yank the script. 99 let original_pos = getpos('.') 97 100 let original_reg_a = @a 98 let original_pos = getpos('.')99 101 call setpos('.', a:range_head) 100 102 normal! v … … 102 104 silent normal! "ay 103 105 let script = @a 104 call setpos('.', original_pos)105 106 let @a = original_reg_a 106 107 108 " Evaluate it. 107 109 execute script 110 111 if a:adjust_cursorp 112 " Move to the next line of the script (add new line if necessary). 113 call setpos('.', a:range_tail) 114 if line('.') == line('$') 115 put ='' 116 else 117 normal! + 118 endif 119 else 120 call setpos('.', original_pos) 121 endif 108 122 endfunction 109 123 -
dotfiles/vim/kana/dot.vim/doc/scratch.txt
r3550 r3577 54 54 Close a window that shows the scratch buffer if able. 55 55 56 :[range]ScratchEvaluate *:ScratchEvaluate*57 Evaluate /Executethe [range] as a Vim script.56 :[range]ScratchEvaluate[!] *:ScratchEvaluate* 57 Evaluate the [range] as a Vim script. 58 58 The default [range] is the current line. 59 Without [!], the cursor will be moved to the next line of the script 60 after evaluating. If there is no line to move, new blank line will be 61 appended then the cursor will be moved to the new line. 62 With [!], such adjustment will not be done. 59 63 60 64 … … 70 74 The return value is not defined. 71 75 72 scratch#evaluate_linewise({line1}, {line2}) *scratch#evaluate_linewise()* 76 *scratch#evaluate_linewise()* 77 scratch#evaluate_linewise({line1}, {line2}, {adjust-cursorp}) 73 78 Function version of |:ScratchEvaluate|. 79 If {adjust-cursorp} is true, the cursor position will be adjusted as 80 same as |:ScratchEvaluate|. If {adjust-cursorp} is false, such 81 adjustment will not be done. 74 82 The return value is not defined. 75 83 76 scratch#evaluate({pos1}, {pos2} )*scratch#evaluate()*84 scratch#evaluate({pos1}, {pos2}, {adjust-cursorp}) *scratch#evaluate()* 77 85 Same as |scratch#evaluate_linewise()|, but this takes the range of the 78 86 script to be evaluated as {pos1} and {pos2}, which are same as the … … 86 94 GLOBAL MAPPINGS ~ 87 95 88 <Plug> scratch-open *<Plug>scratch-open*96 <Plug>(scratch-open) *<Plug>(scratch-open)* 89 97 Do |:ScratchOpen|. 90 98 91 <Plug> scratch-close *<Plug>scratch-close*99 <Plug>(scratch-close) *<Plug>(scratch-close)* 92 100 Do |:ScratchClose|. 93 101 94 <Plug>scratch-evaluate *<Plug>scratch-evaluate* 95 Do |:ScratchEvaluate|. 102 <Plug>(scratch-evaluate) *<Plug>(scratch-evaluate)* 103 Do |:ScratchEvaluate| without [!]. 104 105 <Plug>(scratch-evaluate!) *<Plug>(scratch-evaluate!)* 106 Do |:ScratchEvaluate| with [!]. 96 107 97 108 SCRATCH BUFFER-LOCAL MAPPINGS ~ … … 158 169 BUGS *scratch-bugs* 159 170 160 - When |:edit| is executed on the scratch buffer, the content of the scratch 161 buffer will be cleared. 171 - Don't do |:edit|, |:bunload| or |:bdelete| on the scratch buffer. The 172 content of the scratch buffer and/or other information (e.g., mappings) will 173 be cleared. 174 If you did it accidentally, do |:bwipeout| then |:ScratchOpen| to recreate 175 the scratch buffer. 162 176 163 177 - |:ScratchOpen| - To create the scratch buffer, the current buffer will be 164 hidden temporary. 178 hidden temporary. This behavior may cause some problems. 165 179 166 - |:ScratchEvaluate| - Cursor adjustment is not good. 167 168 - |:ScratchEvaluate| - Should this be able to evaluate any programming 169 language other than Vim script? 180 - |:ScratchEvaluate| - Is it useful to evaluate any programming language other 181 than Vim script? 170 182 171 183 -
dotfiles/vim/kana/dot.vim/plugin/scratch.vim
r3550 r3577 20 20 command! -bar -nargs=0 ScratchOpen call scratch#open() 21 21 command! -bar -nargs=0 ScratchClose call scratch#close() 22 command! -ba r -nargs=0 -range ScratchEvaluate23 \ call scratch#evaluate_linewise(<line1>, <line2> )22 command! -bang -bar -nargs=0 -range ScratchEvaluate 23 \ call scratch#evaluate_linewise(<line1>, <line2>, '<bang>' != '!') 24 24 25 25 26 noremap <silent> <Plug>scratch-open :<C-u>ScratchOpen<Return> 27 noremap <silent> <Plug>scratch-close :<C-u>ScratchClose<Return> 28 noremap <silent> <Plug>scratch-evaluate :ScratchEvaluate<Return> 26 noremap <silent> <Plug>(scratch-open) :<C-u>ScratchOpen<Return> 27 noremap <silent> <Plug>(scratch-close) :<C-u>ScratchClose<Return> 28 noremap <silent> <Plug>(scratch-evaluate) :ScratchEvaluate<Return> 29 noremap <silent> <Plug>(scratch-evaluate!) :ScratchEvaluate!<Return> 29 30 30 31 -
dotfiles/vim/kana/dot.vimrc
r3550 r3577 400 400 echohl ModeMsg 401 401 echo '-- INSERT (one char) --' 402 echohl None 402 403 return nr2char(getchar()) . "\<Esc>" 403 404 endfunction … … 1481 1482 " scratch "{{{2 1482 1483 1483 n noremap <Leader>s :<C-u>ScratchOpen<Return>1484 nmap <Leader>s <Plug>(scratch-open) 1484 1485 1485 1486 … … 1487 1488 " But I don't use it in the scratch buffer, so it should be overridden. 1488 1489 autocmd MyAutoCmd User PluginScratchInitializeAfter 1489 \ map <buffer> <C-m> <Plug> scratch-evaluate1490 \ map <buffer> <C-m> <Plug>(scratch-evaluate) 1490 1491 1491 1492
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)