mirror of
https://github.com/amix/vimrc
synced 2025-06-23 06:35:01 +08:00
Added vim-commentary and updarted the plugins.
commentary: Comment stuff out. Use `gcc` to comment out a line (takes a count), `gc` to comment out the target of a motion (for example, `gcap` to comment out a paragraph), and `gc` in visual mode to comment out the selection. That's it.
This commit is contained in:
53
sources_non_forked/vim-repeat/README.markdown
Normal file
53
sources_non_forked/vim-repeat/README.markdown
Normal file
@ -0,0 +1,53 @@
|
||||
repeat.vim
|
||||
==========
|
||||
|
||||
If you've ever tried using the `.` command after a plugin map, you were
|
||||
likely disappointed to discover it only repeated the last native command
|
||||
inside that map, rather than the map as a whole. That disappointment
|
||||
ends today. Repeat.vim remaps `.` in a way that plugins can tap into
|
||||
it.
|
||||
|
||||
The following plugins support repeat.vim:
|
||||
|
||||
* [surround.vim](https://github.com/tpope/vim-surround)
|
||||
* [speeddating.vim](https://github.com/tpope/vim-speeddating)
|
||||
* [abolish.vim](https://github.com/tpope/vim-abolish)
|
||||
* [unimpaired.vim](https://github.com/tpope/vim-unimpaired)
|
||||
* [commentary.vim](https://github.com/tpope/vim-commentary)
|
||||
|
||||
Adding support to a plugin is generally as simple as the following
|
||||
command at the end of your map functions.
|
||||
|
||||
silent! call repeat#set("\<Plug>MyWonderfulMap", v:count)
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
If you don't have a preferred installation method, I recommend
|
||||
installing [pathogen.vim](https://github.com/tpope/vim-pathogen), and
|
||||
then simply copy and paste:
|
||||
|
||||
cd ~/.vim/bundle
|
||||
git clone git://github.com/tpope/vim-repeat.git
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
See the contribution guidelines for
|
||||
[pathogen.vim](https://github.com/tpope/vim-pathogen#readme).
|
||||
|
||||
Self-Promotion
|
||||
--------------
|
||||
|
||||
Like repeat.vim? Follow the repository on
|
||||
[GitHub](https://github.com/tpope/vim-repeat) and vote for it on
|
||||
[vim.org](http://www.vim.org/scripts/script.php?script_id=2136). And if
|
||||
you're feeling especially charitable, follow [tpope](http://tpo.pe/) on
|
||||
[Twitter](http://twitter.com/tpope) and
|
||||
[GitHub](https://github.com/tpope).
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Copyright (c) Tim Pope. Distributed under the same terms as Vim itself.
|
||||
See `:help license`.
|
119
sources_non_forked/vim-repeat/autoload/repeat.vim
Normal file
119
sources_non_forked/vim-repeat/autoload/repeat.vim
Normal file
@ -0,0 +1,119 @@
|
||||
" repeat.vim - Let the repeat command repeat plugin maps
|
||||
" Maintainer: Tim Pope
|
||||
" Version: 1.1
|
||||
" GetLatestVimScripts: 2136 1 :AutoInstall: repeat.vim
|
||||
|
||||
" Installation:
|
||||
" Place in either ~/.vim/plugin/repeat.vim (to load at start up) or
|
||||
" ~/.vim/autoload/repeat.vim (to load automatically as needed).
|
||||
"
|
||||
" License:
|
||||
" Copyright (c) Tim Pope. Distributed under the same terms as Vim itself.
|
||||
" See :help license
|
||||
"
|
||||
" Developers:
|
||||
" Basic usage is as follows:
|
||||
"
|
||||
" silent! call repeat#set("\<Plug>MappingToRepeatCommand",3)
|
||||
"
|
||||
" The first argument is the mapping that will be invoked when the |.| key is
|
||||
" pressed. Typically, it will be the same as the mapping the user invoked.
|
||||
" This sequence will be stuffed into the input queue literally. Thus you must
|
||||
" encode special keys by prefixing them with a backslash inside double quotes.
|
||||
"
|
||||
" The second argument is the default count. This is the number that will be
|
||||
" prefixed to the mapping if no explicit numeric argument was given. The
|
||||
" value of the v:count variable is usually correct and it will be used if the
|
||||
" second parameter is omitted. If your mapping doesn't accept a numeric
|
||||
" argument and you never want to receive one, pass a value of -1.
|
||||
"
|
||||
" Make sure to call the repeat#set function _after_ making changes to the
|
||||
" file.
|
||||
"
|
||||
" For mappings that use a register and want the same register used on
|
||||
" repetition, use:
|
||||
"
|
||||
" silent! call repeat#setreg("\<Plug>MappingToRepeatCommand", v:register)
|
||||
"
|
||||
" This function can (and probably needs to be) called before making changes to
|
||||
" the file (as those typically clear v:register). Therefore, the call sequence
|
||||
" in your mapping will look like this:
|
||||
"
|
||||
" nnoremap <silent> <Plug>MyMap
|
||||
" \ :<C-U>execute 'silent! call repeat#setreg("\<lt>Plug>MyMap", v:register)'<Bar>
|
||||
" \ call <SID>MyFunction(v:register, ...)<Bar>
|
||||
" \ silent! call repeat#set("\<lt>Plug>MyMap")<CR>
|
||||
|
||||
if exists("g:loaded_repeat") || &cp || v:version < 700
|
||||
finish
|
||||
endif
|
||||
let g:loaded_repeat = 1
|
||||
|
||||
let g:repeat_tick = -1
|
||||
let g:repeat_reg = ['', '']
|
||||
|
||||
" Special function to avoid spurious repeats in a related, naturally repeating
|
||||
" mapping when your repeatable mapping doesn't increase b:changedtick.
|
||||
function! repeat#invalidate()
|
||||
let g:repeat_tick = -1
|
||||
endfunction
|
||||
|
||||
function! repeat#set(sequence,...)
|
||||
let g:repeat_sequence = a:sequence
|
||||
let g:repeat_count = a:0 ? a:1 : v:count
|
||||
let g:repeat_tick = b:changedtick
|
||||
augroup repeat_custom_motion
|
||||
autocmd!
|
||||
autocmd CursorMoved <buffer> let g:repeat_tick = b:changedtick | autocmd! repeat_custom_motion
|
||||
augroup END
|
||||
endfunction
|
||||
|
||||
function! repeat#setreg(sequence,register)
|
||||
let g:repeat_reg = [a:sequence, a:register]
|
||||
endfunction
|
||||
|
||||
function! repeat#run(count)
|
||||
if g:repeat_tick == b:changedtick
|
||||
let r = ''
|
||||
if g:repeat_reg[0] ==# g:repeat_sequence && !empty(g:repeat_reg[1])
|
||||
if g:repeat_reg[1] ==# '='
|
||||
" This causes a re-evaluation of the expression on repeat, which
|
||||
" is what we want.
|
||||
let r = '"=' . getreg('=', 1) . "\<CR>"
|
||||
else
|
||||
let r = '"' . g:repeat_reg[1]
|
||||
endif
|
||||
endif
|
||||
|
||||
let c = g:repeat_count
|
||||
let s = g:repeat_sequence
|
||||
let cnt = c == -1 ? "" : (a:count ? a:count : (c ? c : ''))
|
||||
call feedkeys(r . cnt, 'n')
|
||||
call feedkeys(s)
|
||||
else
|
||||
call feedkeys((a:count ? a:count : '') . '.', 'n')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! repeat#wrap(command,count)
|
||||
let preserve = (g:repeat_tick == b:changedtick)
|
||||
exe 'norm! '.(a:count ? a:count : '').a:command . (&foldopen =~# 'undo' ? 'zv' : '')
|
||||
if preserve
|
||||
let g:repeat_tick = b:changedtick
|
||||
endif
|
||||
endfunction
|
||||
|
||||
nnoremap <silent> . :<C-U>call repeat#run(v:count)<CR>
|
||||
nnoremap <silent> u :<C-U>call repeat#wrap('u',v:count)<CR>
|
||||
if maparg('U','n') ==# ''
|
||||
nnoremap <silent> U :<C-U>call repeat#wrap('U',v:count)<CR>
|
||||
endif
|
||||
nnoremap <silent> <C-R> :<C-U>call repeat#wrap("\<Lt>C-R>",v:count)<CR>
|
||||
|
||||
augroup repeatPlugin
|
||||
autocmd!
|
||||
autocmd BufLeave,BufWritePre,BufReadPre * let g:repeat_tick = (g:repeat_tick == b:changedtick || g:repeat_tick == 0) ? 0 : -1
|
||||
autocmd BufEnter,BufWritePost * if g:repeat_tick == 0|let g:repeat_tick = b:changedtick|endif
|
||||
augroup END
|
||||
|
||||
" vim:set ft=vim et sw=4 sts=4:
|
Reference in New Issue
Block a user