# HG changeset patch # User Steve Losh # Date 1337882950 14400 # Node ID 7a8bd0b938e3290fae030be2f0d12fe47b4874e9 # Parent a67883aeab6b0d99e68158b08b841b455c7b3cf9 Update Vim plugins. diff -r a67883aeab6b -r 7a8bd0b938e3 .hgsubstate --- a/.hgsubstate Thu May 24 14:00:02 2012 -0400 +++ b/.hgsubstate Thu May 24 14:09:10 2012 -0400 @@ -5,30 +5,30 @@ 9895285042a2fd5691b2f6582aa979e4d1bdffea vim/bundle/ack 0256648073658469f219c4f739da528d5325e215 vim/bundle/badwolf b528cf3de72884dd6cf5fdbeda375d7437ea811f vim/bundle/clam -c4fe3045653877518ddbe776a9cb7cbd4fdd0bc8 vim/bundle/ctrlp +b1035a2c6d29a80ea7fd44077814d0bbfc9cdba7 vim/bundle/ctrlp 667a668e114e9ec0e5d4cbcb0962d835b23614c4 vim/bundle/easymotion -4f7af188fec24330e7dff99c8758588ae9780347 vim/bundle/fugitive +6515bd43acc28c86fcf3bea64ce8a6b3d7db19ff vim/bundle/fugitive 43ea418b11f7f78aae0e60229548f68400fc89b8 vim/bundle/gundo -9b71f09cb0665560ef23b0c5a7d158b572fb8118 vim/bundle/html5 +9822fac5329dcd3100dbda89b58ba9160937060a vim/bundle/html5 78fffa609b3e6b84ef01ee4c9aba6d7435d7b18e vim/bundle/indent-object 9543eec44e5cb75b67f0e5eaf1377ca82ced7b90 vim/bundle/linediff fdc0f091c78cd9a474ac3e3cf40ba7d6933ef9da vim/bundle/markdown -678bb2816874d92bca4eea46e0f5f40a15ddab68 vim/bundle/nerdtree +2cb0fc78fb4c7a1db5f51c042a447cc50f09983d vim/bundle/nerdtree b7889db57c90824ff5092da4fdde9e05689f24fa vim/bundle/nosecompiler -99277d9eed97a59cacc1db8c1dece2bcfd96d877 vim/bundle/powerline -1d60548ce9543c462a1fc36830c5e7ec33a57b78 vim/bundle/python-mode +b31111e14ceac0160a1703030fbbaae5656bee4c vim/bundle/powerline +a4b655398f878469bbbeec1b02f5b3bdc126414b vim/bundle/python-mode 3a307dc6b725ebb053e75bad5968ca34366102ad vim/bundle/slimv -c01d81a697de5e28452f32762a9c8fbe3eac0496 vim/bundle/smartinput +78ab4b3df24fa2753d3dfc1be75ed5a3df1565b8 vim/bundle/smartinput c6197a10ace82e0fe0c08e5cf5c017b7069a978e vim/bundle/sparkup 3a2ab096c039516a8f43e6acd0264d8a81cd0544 vim/bundle/splice 6eec2c131213850ed65fd6da494dfd1a0d620a4e vim/bundle/strftimedammit -5a38ce8b600e11941f695523363fe04e6478549a vim/bundle/supertab +8302775fc2dee4935c35f3436e59486940dba3b8 vim/bundle/supertab 489a1e8c676ad47dd358dbf883bfaf492148d38b vim/bundle/surround -b4e85a87629c3db9900fed82f507c43d634fe7c0 vim/bundle/syntastic +025fa81d981c48096d6157f939f007263dc3fab0 vim/bundle/syntastic 2dee007ddae8156735cbae7f0cd4e0a24ba7287b vim/bundle/tslime 50b055633580c65c381ebb310bc1786ff14e3340 vim/bundle/vim-commentary -a8ce721701fdd015695406f7df315f48bb447ebb vim/bundle/vim-javascript +a599ac8ecede3a30f5a89e6f9f704d97a04f982e vim/bundle/vim-javascript f21fbd8759d7fa6c3cb1bbb9fe05eae90422f01a vim/bundle/vim-makegreen -1c039193c59357dd09ddda28aefc6809bd0f90dc vim/bundle/vim-orgmode +f45b4529dd282393f2e08306ae161d77de0051a0 vim/bundle/vim-orgmode 6f31bf82bbcc528eb47c8c1a851a43c36233f6c1 vim/bundle/vitality -e42cac0d8d84be5602109f4e614caa0854470fc1 vim/bundle/yankring +8ebc225b364887c0557ab47ab2ca752a70123bee vim/bundle/yankring diff -r a67883aeab6b -r 7a8bd0b938e3 vim/bundle/yankring/doc/yankring.txt --- a/vim/bundle/yankring/doc/yankring.txt Thu May 24 14:00:02 2012 -0400 +++ b/vim/bundle/yankring/doc/yankring.txt Thu May 24 14:09:10 2012 -0400 @@ -1,7 +1,7 @@ *yankring.txt* For Vim version 7.0. -Author: David Fishburn February 5, 2011 -Version: 13.0 +Author: David Fishburn April 1, 2011 +Version: 14.0 For instructions on installing this file, type :help add-local-help |add-local-help| inside Vim. @@ -21,23 +21,23 @@ 3.4 Customizing Menus..................: |yankring-custom-menus| 4. Using the YankRing Window..............: |yankring-window| 5. Commands...............................: |yankring-commands| - 5.1 YRToggle..........................: |YRToggle| - 5.2 YRClear...........................: |YRClear| - 5.3 YRShow............................: |YRShow| - 5.5 YRGetElem.........................: |YRGetElem| - 5.6 YRGetMultiple.....................: |YRGetMultiple| - 5.7 YRPush............................: |YRPush| - 5.8 YRPop.............................: |YRPop| - 5.9 YRYankCount.......................: |YRYankCount| - 5.10 YRYankRange.......................: |YRYankRange| - 5.11 YRDeleteRange.....................: |YRDeleteRange| - 5.12 YRPaste...........................: |YRPaste| - 5.13 YRReplace.........................: |YRReplace| - 5.14 YRMapsCreate......................: |YRMapsCreate| - 5.15 YRMapsDelete......................: |YRMapsDelete| - 5.16 YRSearch..........................: |YRSearch| - 5.17 YRCheckClipboard..................: |YRCheckClipboard| - 5.18 YRRunAfterMaps....................: |YRRunAfterMaps| + 5.1 YRToggle..........................: |:YRToggle| + 5.2 YRClear...........................: |:YRClear| + 5.3 YRShow............................: |:YRShow| + 5.5 YRGetElem.........................: |:YRGetElem| + 5.6 YRGetMultiple.....................: |:YRGetMultiple| + 5.7 YRPush............................: |:YRPush| + 5.8 YRPop.............................: |:YRPop| + 5.9 YRYankCount.......................: |:YRYankCount| + 5.10 YRYankRange.......................: |:YRYankRange| + 5.11 YRDeleteRange.....................: |:YRDeleteRange| + 5.12 YRPaste...........................: |:YRPaste| + 5.13 YRReplace.........................: |:YRReplace| + 5.14 YRMapsCreate......................: |:YRMapsCreate| + 5.15 YRMapsDelete......................: |:YRMapsDelete| + 5.16 YRSearch..........................: |:YRSearch| + 5.17 YRCheckClipboard..................: |:YRCheckClipboard| + 5.18 YRRunAfterMaps....................: |:YRRunAfterMaps| 6. Tutorial...............................: |yankring-tutorial| 6.1 YRShow............................: |YRShow-example| 6.2 YRReplace.........................: |YRReplace-example| @@ -540,7 +540,7 @@ Status line~ The first line in the YankRing window is the status line. > - AutoClose=1;ClipboardMonitor=1;Cmds:p,P,d,r,s,a,c,u,q,,;Help=? + AutoClose=1;ClipboardMonitor=1;Cmds:[g]p,[g]P,1-9,d,r,s,a,c,u,q,,;Help=? < Help=?, pressing [?] will toggle the display of available commands the yankring window supports. Pressing [?] again will remove the additional @@ -572,10 +572,11 @@ Just like "p". Just like "p". <2-LeftMouse> Just like "p". Normal mode only. + 1-9 Short cut to paste the n'th number from the YankRing. d Removes the element from the yankring. In visual mode all elements selected will be removed. r Just like "p", but in visual mode if many lines are selected - it will paste these in reverse order. + it will paste these items in reverse order. s Prompts you for a regex to search the YankRing and display only matching items. a Toggles the g:yankring_window_auto_close setting. @@ -597,7 +598,7 @@ to use. -5.1 YRToggle *YRToggle* +5.1 YRToggle :*YRToggle* Allows you to enable and disable the YankRing quickly. This command will remove the default maps and recreate them. @@ -607,12 +608,12 @@ :YRToggle 0 " Disables it < -5.2 YRClear *YRClear* +5.2 YRClear :*YRClear* Clears all elements from the yankring. See also |YRClear-example|. -5.3 YRShow *YRShow* +5.3 YRShow :*YRShow* Similar to |:register|, will display all the entries in the yankring. The element at the top will be the next element pasted from the yankring. @@ -629,7 +630,7 @@ 5 one^@ < -5.5 YRGetElem *YRGetElem* +5.5 YRGetElem :*YRGetElem* This command has two modes. If no parameters are provided, it becomes interactive. It uses YRShow to display the list and allows you to choose which element to paste. If a parameter @@ -649,7 +650,7 @@ :YRGetElem 0 " Error, invalid choice is reported -5.6 YRGetMultiple *YRGetMultiple* +5.6 YRGetMultiple :*YRGetMultiple* Will paste many elements from the YankRing in one command. If the number specified is 1 or less, it is assumed you want just the current element pasted. If the number specified is @@ -668,7 +669,7 @@ :YRGetMultiple 0 " Will paste element 1 -5.7 YRPush *YRPush* +5.7 YRPush :*YRPush* Allows the user to "push" additional entries into the yankring. If you yanked text via a key mapping which does not use the YankRing (or there is text on the clipboard) you can use this @@ -682,7 +683,7 @@ < See also |YRPush-example|. -5.8 YRPop *YRPop* +5.8 YRPop :*YRPop* Allows you to pop any elements from the yankring. If no parameters are provided, the 1st element is removed from the yankring. The command optionally takes a second parameter to specify how many @@ -697,7 +698,7 @@ < See also |YRPop-example|. -5.9 YRYankCount *YRYankCount* +5.9 YRYankCount :*YRYankCount* This command has the most mappings created for it. If you are in normal mode and you are not specifying a range, this command will add the text to the yankring. @@ -739,7 +740,7 @@ See also |yankring-tutorial|. -5.10 YRYankRange *YRYankRange* +5.10 YRYankRange :*YRYankRange* This command by default is only called in visual mode. All visual modes (|characterwise-visual|, |linewise-visual|, |blockwise-visual|) are supported. Any visually selected text @@ -761,12 +762,12 @@ < See also |YRYankRange-example|. -5.11 YRDeleteRange *YRDeleteRange* +5.11 YRDeleteRange :*YRDeleteRange* This command is identical to YRYankRange, except the range is also deleted. -5.12 YRPaste *YRPaste* +5.12 YRPaste :*YRPaste* This command will paste elements from the yankring. By default it has been mapped to p and P to match Vim's native key strokes. The text pasted is exactly what was yanked, including newline characters and @@ -783,7 +784,7 @@ See also |yankring-tutorial|. -5.13 YRReplace *YRReplace* +5.13 YRReplace :*YRReplace* The purpose of the YankRing is to gain access to previously yanked (or deleted) elements. This command will replace the previous paste with a different entry from the yankring. @@ -812,18 +813,18 @@ let g:yankring_replace_n_nkey = '' endif -5.14 YRMapsCreate *YRMapsCreate* +5.14 YRMapsCreate :*YRMapsCreate* This public function is responsible for creating the maps which enable the yankring. This function is called by the YRToggle command. -5.15 YRMapsDelete *YRMapsDelete* +5.15 YRMapsDelete :*YRMapsDelete* This public function removes the YankRing maps and disables the yankring. This function is called by the YRToggle command. -5.16 YRSearch *YRSearch* +5.16 YRSearch :*YRSearch* This command is similar to |YRGetElem|. The command takes one parameter which is a regular expression. Similar to YRGetElem, it will display all items in the YankRing that match @@ -831,14 +832,14 @@ prompt you to enter which match you wish pasted. See also |YRSearch-example|. -5.17 YRCheckClipboard *YRCheckClipboard* +5.17 YRCheckClipboard :*YRCheckClipboard* Normally the GUI Vims will automatically (via autocmds) check for changes to the system clipboard and add any new changes to the YankRing. Most console Vim's do not fire the required autocmds. This command will perform the check manually. -5.18 YRRunAfterMaps *YRRunAfterMaps* +5.18 YRRunAfterMaps :*YRRunAfterMaps* See the following section |yankring-custom-maps|. @@ -1055,6 +1056,10 @@ Using the YankRing window can be much faster if you do not want to cycle through the YankRing using and to find the element. + As a short cut, when using the YankRing window, you can press the numbers + 1-9 to paste that item directly and close the YankRing window. This can + be faster than navigating to the correct line number and pressing 'p'. + *multiple-items-example* There are times when you need to move through a buffer capturing many different lines (or snippets of code) and eventually want to switch @@ -1215,6 +1220,24 @@ ============================================================================== 7. History *yankring-history* + 14.0: April 1, 2012 + NF: The YankRing window supports 1-9 to choose to paste those + items for quicker access to the top 9 items. + NF: The YankRing now maps the @ key to run macros. Not all actions + performed during the macro are recorded by the YankRing + as a number of items had to be unmapped to support the replay + of actions which can prompt the user for input (i.e. t and f) + (Asis Hallab). + BF: When flipping between applications the system clipboard + was not added to the YankRing in all cases. + BF: The YankRing could report E121: Undefined variable: + g:yankring_manual_clipboard_check (Thilo Six). + BF: The YankRing could report: E132: Function call depth is higher + than 'maxfuncdepth'. When executing a YRClear or YRPop or + when flipping between applications (Marcin Szamotulski). + BF: Strange behaviour when opening the YankRing with + :e [YankRing] instead of :YRShow (Marcin Szamotulski). + 13.0: February 5, 2012 NF: [p, ]p, [P, ]P are now supported within the YankRing window (Alexandre Provencio). diff -r a67883aeab6b -r 7a8bd0b938e3 vim/bundle/yankring/plugin/yankring.vim --- a/vim/bundle/yankring/plugin/yankring.vim Thu May 24 14:00:02 2012 -0400 +++ b/vim/bundle/yankring/plugin/yankring.vim Thu May 24 14:09:10 2012 -0400 @@ -1,9 +1,9 @@ " yankring.vim - Yank / Delete Ring for Vim " --------------------------------------------------------------- -" Version: 13.0 +" Version: 14.0 " Author: David Fishburn " Maintainer: David Fishburn -" Last Modified: 2012 Feb 24 +" Last Modified: 2012 Mar 23 " Script: http://www.vim.org/scripts/script.php?script_id=1234 " Based On: Mocked up version by Yegappan Lakshmanan " http://groups.yahoo.com/group/vim/post?act=reply&messageNum=34406 @@ -19,7 +19,7 @@ finish endif -let loaded_yankring = 130 +let loaded_yankring = 140 " Turn on support for line continuations when creating the script let s:cpo_save = &cpo @@ -47,7 +47,7 @@ let g:yankring_max_history = 100 endif -" Specify the minimum length of 1 entry +" Specify the minimum length of 1 entry if !exists('g:yankring_min_element_length') let g:yankring_min_element_length = 1 endif @@ -99,7 +99,7 @@ let g:yankring_window_height = 8 endif -" When displaying the buffer, how many lines should it be +" When displaying the buffer, how many columns should it be if !exists('g:yankring_window_width') let g:yankring_window_width = 30 endif @@ -128,7 +128,7 @@ " The default is based on cpoptions: |cpo-y| " y A yank command can be redone with ".". if !exists('g:yankring_dot_repeat_yank') - let g:yankring_dot_repeat_yank = (&cpoptions=~'y'?1:0) + let g:yankring_dot_repeat_yank = (s:cpo_save=~'y'?1:0) endif " Only adds unique items to the yankring. @@ -141,7 +141,7 @@ " Vim automatically manages the numbered registers: " 0 - last yanked text " 1-9 - last deleted items -" If this option is turned on, the yankring will manage the +" If this option is turned on, the yankring will manage the " values in them. if !exists('g:yankring_manage_numbered_reg') let g:yankring_manage_numbered_reg = 0 @@ -168,7 +168,7 @@ endif if !exists('g:yankring_zap_keys') - let g:yankring_zap_keys = 'f F t T / ? @' + let g:yankring_zap_keys = 'f F t T / ?' endif " Allow the user to specify what operator pending motions to map @@ -228,12 +228,13 @@ endif if !exists('g:yankring_manual_clipboard_check') - if g:yankring_clipboard_monitor == 1 - if has("gui_running") - " FocusGained event will take care of + let g:yankring_manual_clipboard_check = 0 + if g:yankring_clipboard_monitor == 1 + if has("gui_running") + " FocusGained event will take care of " monitoring the clipboard. let g:yankring_manual_clipboard_check = 0 - else + else " If the GUI is not running and the user wants to monitor the " clipboard, we need to manually check for clipboard entries as " the FocusGained event does not fire in console mode. @@ -259,12 +260,12 @@ let s:yr_history_v2_nl = "\2" " Use double quotes for a special character let s:yr_history_v2_nl_pat = "\2" let s:yr_history_last_upd = 0 -let s:yr_history_file_v1 = +let s:yr_history_file_v1 = \ g:yankring_history_dir.'/'. \ g:yankring_history_file. \ (g:yankring_share_between_instances==1?'':'_'.v:servername). \ '.txt' -let s:yr_history_file_v2 = +let s:yr_history_file_v2 = \ g:yankring_history_dir.'/'. \ g:yankring_history_file. \ (g:yankring_share_between_instances==1?'':'_'.v:servername). @@ -277,7 +278,7 @@ let s:yr_maps_created_zap = 0 let s:yr_last_motion = '' -" Enables or disables the yankring +" Enables or disables the yankring function! s:YRToggle(...) " Default the current state to toggle let new_state = ((g:yankring_enabled == 1) ? 0 : 1) @@ -286,9 +287,9 @@ if a:0 > 0 let new_state = ((a:1 == 1) ? 1 : 0) endif - + " YRToggle accepts an integer value to specify the state - if new_state == g:yankring_enabled + if new_state == g:yankring_enabled return elseif new_state == 1 call s:YRMapsCreate() @@ -298,16 +299,15 @@ call s:YRWarningMsg('YR: The YankRing is now disabled') endif endfunction - - -" Enables or disables the yankring -function! s:YRDisplayElem(disp_nbr, script_var) + +" Enables or disables the yankring +function! s:YRDisplayElem(disp_nbr, script_var) if g:yankring_max_display == 0 if g:yankring_window_use_separate == 1 let max_display = 500 else - let max_display = g:yankring_window_width + - \ g:yankring_window_increment - + let max_display = g:yankring_window_width + + \ g:yankring_window_increment - \ 12 endif else @@ -340,22 +340,30 @@ return "" endfunction - - -" Enables or disables the yankring -function! s:YRShow(...) + +" Enables or disables the yankring +function! s:YRShow(...) + " Prevent recursion + if exists('s:yankring_showing') && s:yankring_showing == 1 + " call s:YRWarningMsg('YR: YRShow aborting for recursion') + return + endif + if g:yankring_enabled == 0 call s:YRWarningMsg('YR: The YankRing is disabled, use YRToggle to re-enable') return endif - " If the GUI is not running, we need to manually check for clipboard + " Prevent recursion + let s:yankring_showing = 1 + + " If the GUI is not running, we need to manually check for clipboard " entries as the FocusGained event does not fire in console mode. if g:yankring_manual_clipboard_check == 1 call s:YRCheckClipboard() endif - " If no parameter was provided assume the user wants to + " If no parameter was provided assume the user wants to " toggle the display. let toggle = 1 if a:0 > 0 @@ -380,6 +388,9 @@ exec s:yr_buffer_last_winnr . "wincmd w" endif + " Prevent recursion + let s:yankring_showing = 0 + return endif endif @@ -390,17 +401,17 @@ " always run the search again. let s:yr_search = "" - " It is possible for registers to be changed outside of the + " It is possible for registers to be changed outside of the " maps of the YankRing. Perform this quick check when we " show the contents (or when it is refreshed). - if g:yankring_paste_check_default_buffer == 1 + if g:yankring_paste_check_default_buffer == 1 let save_reg = 0 let register = ((&clipboard=~'\')?'*':((&clipboard=~'\' && has('unnamedplus'))?'+':'"')) - if &clipboard =~ '\' && getreg('*') != s:yr_prev_clipboard + if &clipboard =~ '\' && getreg('*') != s:yr_prev_clipboard_star let save_reg = 1 endif - if has('unnamedplus') && &clipboard =~ '\' && getreg('+') != s:yr_prev_clipboard + if has('unnamedplus') && &clipboard =~ '\' && getreg('+') != s:yr_prev_clipboard_plus let save_reg = 1 endif if register == '"' && getreg('"') != s:yr_prev_reg_unnamed @@ -409,7 +420,7 @@ if save_reg == 1 " The user has performed a yank / delete operation - " outside of the yankring maps. Add this + " outside of the yankring maps. Add this " value to the yankring. call YRRecord(register) endif @@ -423,7 +434,7 @@ if show_registers == 1 for reg_name in map( range(char2nr('0'), char2nr('9')) + \ (range(char2nr('a'), char2nr('z'))) - \, 'nr2char(v:val)' + \, 'nr2char(v:val)' \ ) let output = output . s:YRDisplayElem(reg_name, getreg(reg_name).',') . "\n" endfor @@ -438,13 +449,16 @@ if g:yankring_window_use_separate == 1 call s:YRWindowOpen(output) - else + else echo output endif + + " Prevent recursion + let s:yankring_showing = 0 endfunction -" Used in omaps if a following character is required +" Used in omaps if a following character is required " like with motions (f,t) function! s:YRGetChar() let msg = "YR:Enter character:" @@ -458,7 +472,7 @@ endfunction -" Used in omaps if a following string is required +" Used in omaps if a following string is required " like with motions (/,?) " function! s:YRGetSearch() " " let msg = "YR:Enter string:" @@ -483,12 +497,12 @@ " " endwhile " return str " endfunction - + " Paste a certain item from the yankring " If no parameter is provided, this function becomes interactive. It will " display the list (using YRShow) and allow the user to choose an element. -function! s:YRGetElem(...) +function! s:YRGetElem(...) if g:yankring_manual_clipboard_check == 1 call s:YRCheckClipboard() endif @@ -555,10 +569,10 @@ call s:YRSetPrevOP('p', '', default_buffer, 'n') endfunction - + " Starting the top of the ring it will paste x items from it -function! s:YRGetMultiple(reverse_order, ...) +function! s:YRGetMultiple(reverse_order, ...) if g:yankring_manual_clipboard_check == 1 call s:YRCheckClipboard() endif @@ -605,12 +619,12 @@ endwhile endif endfunction - + " Given a regular expression, check each element within " the yankring, display only the matching items and prompt " the user for which item to paste -function! s:YRSearch(...) +function! s:YRSearch(...) if s:yr_count == 0 call s:YRWarningMsg('YR: yankring is empty') return @@ -689,7 +703,7 @@ endif endfunction - + " Resets the common script variables for managing the ring. function! s:YRReset() @@ -697,7 +711,7 @@ " Update the history file call s:YRHistorySave() endfunction - + " Clears the yankring by simply setting the # of items in it to 0. " There is no need physically unlet each variable. @@ -714,11 +728,12 @@ let s:yr_prev_op_mode = 'n' let s:yr_prev_count = '' let s:yr_prev_reg = '' - let s:yr_prev_reg_unnamed = '' + let s:yr_prev_reg_unnamed = getreg('"') let s:yr_prev_reg_small = '' let s:yr_prev_reg_insert = '' let s:yr_prev_reg_expres = '' - let s:yr_prev_clipboard = '' + let s:yr_prev_clipboard_star = '' + let s:yr_prev_clipboard_plus = '' let s:yr_prev_vis_lstart = 0 let s:yr_prev_vis_lend = 0 let s:yr_prev_vis_cstart = 0 @@ -737,7 +752,7 @@ call s:YRHistoryRead() endfunction - + " Clears the yankring by simply setting the # of items in it to 0. function! s:YRClear() @@ -747,13 +762,13 @@ " If the yankring window is open, refresh it call s:YRWindowUpdate() endfunction - + " Determine which register the user wants to use " For example the 'a' register: "ayy function! s:YRRegister() " v:register can be blank in some (unknown) cases - " so test for this condition and return the + " so test for this condition and return the " default register let user_register = ((v:register=='')?('"'):(v:register)) if &clipboard =~ '\' && user_register == '"' @@ -769,7 +784,7 @@ " Allows you to push a new item on the yankring. Useful if something " is in the clipboard and you want to add it to the yankring. " Or if you yank something that is not mapped. -function! s:YRPush(...) +function! s:YRPush(...) let user_register = s:YRRegister() if a:0 > 0 @@ -782,7 +797,7 @@ " the default buffer as well so the next item pasted will " be the item pushed let default_buffer = ((&clipboard=~'\')?'*':((&clipboard=~'\' && has('unnamedplus'))?'+':'"')) - call setreg(default_buffer, getreg(user_register), + call setreg(default_buffer, getreg(user_register), \ getregtype(user_register)) call s:YRSetPrevOP('', '', '', 'n') @@ -792,7 +807,7 @@ " Allows you to pop off any element from the yankring. " If no parameters are provided the first element is removed. -" If a vcount is provided, that many elements are removed +" If a vcount is provided, that many elements are removed " from the top. function! s:YRPop(...) if s:yr_count == 0 @@ -801,12 +816,12 @@ endif let v_count = 1 - if a:0 > 1 + if a:0 > 1 let v_count = a:2 endif - " If the user provided a parameter, remove that element - " from the yankring. + " If the user provided a parameter, remove that element + " from the yankring. " If no parameter was provided assume the first element. let elem_index = 0 if a:0 > 0 @@ -814,10 +829,10 @@ let elem_index = matchstr(a:1, '\d\+') let elem_index = elem_index - 1 endif - + " If the user entered a count, then remove that many " elements from the ring. - while v_count > 0 + while v_count > 0 call s:YRMRUDel('s:yr_history_list', elem_index) let v_count = v_count - 1 endwhile @@ -828,7 +843,7 @@ " Adds this value to the yankring. -function! YRRecord(...) +function! YRRecord(...) let register = '"' if a:0 > 0 @@ -850,7 +865,7 @@ if register == '"' " If the change has occurred via an omap, we must delay " the capture of the default register until this event - " since register updates are not reflected until the + " since register updates are not reflected until the " omap function completes let s:yr_prev_reg_unnamed = getreg('"') let s:yr_prev_reg_small = getreg('-') @@ -860,16 +875,12 @@ " This will also account for duplicates. call s:YRMRUAdd( 's:yr_history_list' \ , getreg(register) - \ , getregtype(register) + \ , getregtype(register) \ ) if g:yankring_clipboard_monitor == 1 - if register == '+' - let s:yr_prev_clipboard = getreg('+') - endif - if register == '*' - let s:yr_prev_clipboard = getreg('*') - endif + let s:yr_prev_clipboard_plus = getreg('+') + let s:yr_prev_clipboard_star = getreg('*') endif " Manage the numbered registers @@ -884,7 +895,7 @@ " Reset the past paste entry to the top of the ring. " When the user hits replace last entry it should - " start from the top (not from the last previous + " start from the top (not from the last previous " replace) after capturing a new value in the YankRing. let s:yr_last_paste_idx = 1 @@ -893,69 +904,66 @@ " Adds this value to the yankring. -function! YRRecord3(...) +function! YRRecord3(...) let register = '"' - " if a:0 > 0 - " " If no yank command has been supplied, assume it is - " " a full line yank - " let motion = ((a:1 == '') ? motion : a:1) - " echomsg "YRRecord3 motion:".motion - " endif - - " v:register can be blank in some (unknown) cases - " if v:register == '' || v:register == '_' - if v:register == '_' - " Black hole register, ignore recording the operation - return "" - endif - - let register = s:YRRegister() - - if &clipboard =~ '\' && register == '*' - " unnamed A variant of "unnamed" flag which uses the clipboard - " register '*' (|quote|) for all operations except yank. - " Yank shall copy the text into register '*' when "unnamed" - " is included. - " - let register = '*' - - " The + and * registers are not modified by yank operations. - " We do not know what operation triggered this event so do a - " simple check if the register values have changed. - " If not, check it against the " register. Use which ever - " one has changed. - if s:yr_prev_clipboard == '' || getreg(register) == s:yr_prev_clipboard - if getreg('"') != getreg(register) - let register = '"' - endif - endif - endif - - if has('unnamedplus') && &clipboard =~ '\' && register == '+' - " unnamedplus A variant of "unnamed" flag which uses the clipboard - " register '+' (|quoteplus|) instead of register '*' for all - " operations except yank. Yank shall copy the text into - " register '+' and also into '*' when "unnamed" is included. - " - let register = '+' - - " The + and * registers are not modified by yank operations. - " We do not know what operation triggered this event so do a - " simple check if the register values have changed. - " If not, check it against the " register. Use which ever - " one has changed. - if s:yr_prev_clipboard == '' || getreg(register) == s:yr_prev_clipboard - if getreg('"') != getreg(register) - let register = '"' - endif - endif + if a:0 > 0 && a:1 != '' + let register = a:1 + else + " v:register can be blank in some (unknown) cases + " if v:register == '' || v:register == '_' + if v:register == '_' + " Black hole register, ignore recording the operation + return "" + endif + + let register = s:YRRegister() + + if &clipboard =~ '\' && register == '*' + " unnamed A variant of "unnamed" flag which uses the clipboard + " register '*' (|quote|) for all operations except yank. + " Yank shall copy the text into register '*' when "unnamed" + " is included. + " + let register = '*' + + " The + and * registers are not modified by yank operations. + " We do not know what operation triggered this event so do a + " simple check if the register values have changed. + " If not, check it against the " register. Use which ever + " one has changed. + if s:yr_prev_clipboard_star == '' || getreg(register) == s:yr_prev_clipboard_star + if getreg('"') != getreg(register) + let register = '"' + endif + endif + endif + + if has('unnamedplus') && &clipboard =~ '\' && register == '+' + " unnamedplus A variant of "unnamed" flag which uses the clipboard + " register '+' (|quoteplus|) instead of register '*' for all + " operations except yank. Yank shall copy the text into + " register '+' and also into '*' when "unnamed" is included. + " + let register = '+' + + " The + and * registers are not modified by yank operations. + " We do not know what operation triggered this event so do a + " simple check if the register values have changed. + " If not, check it against the " register. Use which ever + " one has changed. + if s:yr_prev_clipboard_plus == '' || getreg(register) == s:yr_prev_clipboard_plus + if getreg('"') != getreg(register) + let register = '"' + endif + endif + endif endif if register == '"' " If the change has occurred via an omap, we must delay " the capture of the default register until this event - " since register updates are not reflected until the + " since register updates are not reflected until the " omap function completes let s:yr_prev_reg_unnamed = getreg('"') let s:yr_prev_reg_small = getreg('-') @@ -969,16 +977,12 @@ " This will also account for duplicates. call s:YRMRUAdd( 's:yr_history_list' \ , getreg(register) - \ , getregtype(register) + \ , getregtype(register) \ ) if g:yankring_clipboard_monitor == 1 - if register == '+' - let s:yr_prev_clipboard = getreg('+') - endif - if register == '*' - let s:yr_prev_clipboard = getreg('*') - endif + let s:yr_prev_clipboard_plus = getreg('+') + let s:yr_prev_clipboard_star = getreg('*') endif " Manage the numbered registers @@ -993,7 +997,7 @@ " Reset the past paste entry to the top of the ring. " When the user hits replace last entry it should - " start from the top (not from the last previous + " start from the top (not from the last previous " replace) after capturing a new value in the YankRing. let s:yr_last_paste_idx = 1 @@ -1002,7 +1006,7 @@ " Record the operation for the dot operator -function! s:YRSetPrevOP(op_code, count, reg, mode) +function! s:YRSetPrevOP(op_code, count, reg, mode) let s:yr_prev_op_code = a:op_code let s:yr_prev_op_mode = a:mode let s:yr_prev_count = a:count @@ -1045,7 +1049,7 @@ " Adds this value to the yankring. -function! s:YRDoRepeat() +function! s:YRDoRepeat() let dorepeat = 0 if s:yr_has_voperator == 1 @@ -1075,7 +1079,7 @@ \ s:yr_prev_chg_lstart == line("'[") && \ s:yr_prev_chg_lend == line("']") && \ s:yr_prev_chg_cstart == col("'[") && - \ s:yr_prev_chg_cend == col("']") + \ s:yr_prev_chg_cend == col("']") let dorepeat = 1 endif else @@ -1102,7 +1106,7 @@ " if s:yr_prev_chg_lstart == line("'[") && " \ s:yr_prev_chg_lend == line("']") && " \ s:yr_prev_chg_cstart == col("'[") && - " \ s:yr_prev_chg_cend == col("']") + " \ s:yr_prev_chg_cend == col("']") " let dorepeat = 1 " endif elseif dorepeat == 1 && s:yr_prev_op_mode == 'o' @@ -1112,7 +1116,7 @@ " if s:yr_prev_chg_lstart == line("'[") && " \ s:yr_prev_chg_lend == line("']") && " \ s:yr_prev_chg_cstart == col("'[") && - " \ s:yr_prev_chg_cend == col("']") + " \ s:yr_prev_chg_cend == col("']") " let dorepeat = 1 " endif endif @@ -1124,7 +1128,7 @@ " " If the previous op was a change, do not use the yankring " " to repeat it. " " changenr() is buffer specific, so anytime you move to - " " a different buffer you will definitely perform a + " " a different buffer you will definitely perform a " " standard "." " " Any previous op that was a change, must be replaced using "." " " since we do not want the user prompted to enter text again. @@ -1146,7 +1150,7 @@ " Manages the Vim's numbered registers -function! s:YRSetNumberedReg() +function! s:YRSetNumberedReg() let i = 0 @@ -1175,7 +1179,7 @@ " This internal function will add and subtract values from a starting " point and return the correct element number. It takes into account " the circular nature of the yankring. -function! s:YRGetNextElem(start, iter) +function! s:YRGetNextElem(start, iter) let needed_elem = a:start + a:iter @@ -1211,7 +1215,7 @@ " Supports this for example - 5"ayy " " This is a legacy function now since the release of Vim 7.2 -" and the use of omaps with YankRing 5.0 and above. +" and the use of omaps with YankRing 5.0 and above. " If Vim 7.1 has patch205, then the new omaps and the v:operator " variable is used instead. function! s:YRYankCount(...) range @@ -1257,12 +1261,12 @@ " Black hole register, ignore recording the operation return endif - + call s:YRSetPrevOP(op_code, v_count, user_register, 'n') call YRRecord(user_register) endfunction - + " Handles ranges. There are visual ranges and command line ranges. " Visual ranges are easy, since we pass through and let Vim deal @@ -1282,8 +1286,8 @@ let cmd_mode = ((a:1 == 'v') ? 'v' : 'n') endif - if cmd_mode == 'v' - " We are yanking either an entire line, or a range + if cmd_mode == 'v' + " We are yanking either an entire line, or a range exec "normal! gv". \ (user_register==default_buffer?'':'"'.user_register). \ 'y' @@ -1307,21 +1311,21 @@ " Black hole register, ignore return endif - + call s:YRSetPrevOP('', '', user_register, 'n') call YRRecord(user_register) endfunction - + " Paste from either the yankring or from a specified register -" Optionally a count can be provided, so paste the same value 10 times -function! s:YRPaste(replace_last_paste_selection, nextvalue, direction, ...) +" Optionally a count can be provided, so paste the same value 10 times +function! s:YRPaste(replace_last_paste_selection, nextvalue, direction, ...) if g:yankring_manual_clipboard_check == 1 call s:YRCheckClipboard() endif " Disabling the yankring removes the default maps. - " But there are some maps the user can create on their own, and + " But there are some maps the user can create on their own, and " these would most likely call this function. So place an extra " check and display a message. if g:yankring_enabled == 0 @@ -1330,7 +1334,7 @@ \ ) return endif - + let user_register = s:YRRegister() let default_buffer = ((&clipboard=~'\')?'*':((&clipboard=~'\' && has('unnamedplus'))?'+':'"')) let v_count = v:count @@ -1343,7 +1347,7 @@ let cmd_mode = ((a:1 == 'v') ? 'v' : 'n') endif - " User has decided to bypass the yankring and specify a specific + " User has decided to bypass the yankring and specify a specific " register if user_register != default_buffer if a:replace_last_paste_selection == 1 @@ -1386,15 +1390,15 @@ " The user could have: " let @" = 'test string' " would not be in the yankring as no mapping triggered this action. - if a:replace_last_paste_selection != 1 + if a:replace_last_paste_selection != 1 " Only check the default buffer is the user wants us to. - " This was necessary prior to version 4.0 since we did not + " This was necessary prior to version 4.0 since we did not " capture as many items as 4.0 and above does. (A. Budden) - if g:yankring_paste_check_default_buffer == 1 + if g:yankring_paste_check_default_buffer == 1 if ( default_buffer == '"' && getreg(default_buffer) != s:yr_prev_reg_unnamed ) " There are only a couple of scenarios where this would happen " 1. set clipboard = unnamed[plus] - " The user performs an action which changes the + " The user performs an action which changes the " unnamed register (i.e. x - delete character) " 2. Any type of direct manipulation of the registers " let @" = 'something' @@ -1404,21 +1408,30 @@ endif " The user has performed a yank / delete operation - " outside of the yankring maps. First, add this + " outside of the yankring maps. First, add this " value to the yankring. call YRRecord(default_buffer) - elseif ( default_buffer != '"' && + elseif ( default_buffer == '+' && \ len(getreg(default_buffer)) != 0 && - \ getreg(default_buffer) != s:yr_prev_clipboard + \ getreg(default_buffer) != s:yr_prev_clipboard_plus \ ) " The user has performed a yank / delete operation - " outside of the yankring maps. First, add this + " outside of the yankring maps. First, add this + " value to the yankring. + call YRRecord(default_buffer) + elseif ( default_buffer == '*' && + \ len(getreg(default_buffer)) != 0 && + \ getreg(default_buffer) != s:yr_prev_clipboard_star + \ ) + + " The user has performed a yank / delete operation + " outside of the yankring maps. First, add this " value to the yankring. call YRRecord(default_buffer) endif endif - + exec "normal! ". \ ((cmd_mode=='n') ? "" : "gv"). \ ((v_count > 0)?(v_count):''). @@ -1430,8 +1443,8 @@ endif " if s:yr_count > 0 || ( - " \ default_buffer != '"' && - " \ len(getreg(default_buffer)) == 0 + " \ default_buffer != '"' && + " \ len(getreg(default_buffer)) == 0 " \ ) " " Nothing to paste " return @@ -1451,7 +1464,7 @@ return endif - " If a count was provided (ie 5), multiply the + " If a count was provided (ie 5), multiply the " nextvalue accordingly and position the next paste index " let which_elem = a:nextvalue * ((v_count > 0)?(v_count):1) * -1 let which_elem = matchstr(a:nextvalue, '-\?\d\+') * ((v_count > 0)?(v_count):1) * -1 @@ -1470,7 +1483,7 @@ exec "normal! u" " Check if the visual selection should be reselected " Next paste the correct item from the ring - " This is done as separate statements since it appeared that if + " This is done as separate statements since it appeared that if " there was nothing to undo, the paste never happened. exec "normal! ". \ ((s:yr_prev_vis_mode==0) ? "" : "gv"). @@ -1505,7 +1518,7 @@ let s:yr_prev_vis_mode = ((cmd_mode=='n') ? 0 : 1) endif endfunction - + " Handle any omaps function! YRMapsExpression(sid, motion, ...) @@ -1547,9 +1560,9 @@ " There are a variety of commands which do not change the " registers, so these operators should be ignored when " determining which operations to record - " Simple example is '=' which simply formats the + " Simple example is '=' which simply formats the " the selected text. - if ' \('.escape(join(split(g:yankring_ignore_operator), '\|'), '/.*~$^[]' ).'\) ' !~ escape(v:operator, '/.*~$^[]') + if ' \('.escape(join(split(g:yankring_ignore_operator), '\|'), '/.*~$^[]' ).'\) ' !~ escape(v:operator, '/.*~$^[]') " Check if we are performing an action that will " take us into insert mode if '[cCsS]' !~ escape(v:operator, '/.*~$^[]') && a:motion !~ '@' @@ -1565,64 +1578,65 @@ let cmds .= a:sid. "yrrecord" endif endif - + " This will not work since we are already executing an expression " if a:motion =~ '@' " let cmds = 'normal! ' . cmds " endif - " YRRecord3() will use this value to determine what operation - " the user just initiated. + " YRRecord3() will use this value to determine what operation + " the user just initiated. let s:yr_last_motion = cmds " echomsg "YRMapsE 5:".a:motion.":'".cmds."':".s:yr_maps_created_zap return cmds - + endfunction - + " Handle macros (@). " This routine is not used, YRMapsExpression is used to " handle the @ symbol. -" function! s:YRMapsMacro(bang, ...) range -" " If we are repeating a series of commands we must -" " unmap the _zap_ keys so that the user is not -" " prompted when a command is replayed. -" " These maps must be re-instated in YRRecord3() -" " after the action of the replay is completed. -" call s:YRMapsDelete('remove_only_zap_keys') -" -" " let zapto = (a:0==0 ? "" : s:YRGetChar()) -" let zapto = s:YRGetChar() -" -" if zapto == "\" -" " Abort if the user hits Control C -" call s:YRWarningMsg( "YR:Aborting command:".v:operator.a:motion ) -" return "" -" endif -" -" let v_count = v:count -" " If no count was specified it will have a value of 0 -" " so set it to at least 1 -" let v_count = ((v_count > 0)?(v_count):'') -" -" let range = '' -" if a:firstline != a:lastline -" let rannge = a:firstline.','.a:lastline -" endif -" -" let cmd = range."normal! ".v_count.'@'.zapto -" " DEBUG -" " echomsg cmd -" exec cmd -" -" call s:YRMapsCreate('add_only_zap_keys') -" endfunction - +function! s:YRMapsMacro(bang, ...) + " If we are repeating a series of commands we must + " unmap the _zap_ keys so that the user is not + " prompted when a command is replayed. + " These maps must be re-instated in YRRecord3() + " after the action of the replay is completed. + call s:YRMapsDelete('remove_only_zap_keys') + + " let zapto = (a:0==0 ? "" : s:YRGetChar()) + let zapto = s:YRGetChar() + + if zapto == "\" + " Abort if the user hits Control C + call s:YRWarningMsg( "YR:Aborting macro" ) + return "" + endif + + let v_count = v:count + " If no count was specified it will have a value of 0 + " so set it to at least 1 + let v_count = ((v_count > 0)?(v_count):'') + + " let range = '' + " if a:firstline != a:lastline + " let rannge = a:firstline.','.a:lastline + " endif + + " let cmd = range."normal! ".v_count.'@'.zapto + let cmd = "normal! ".v_count.'@'.zapto + " DEBUG + " echomsg cmd + exec cmd + + call s:YRMapsCreate('add_only_zap_keys') +endfunction + " Create the default maps function! s:YRMapsCreate(...) - " 7.1.patch205 introduces the v:operator function which was + " 7.1.patch205 introduces the v:operator function which was " essential to gain the omap support. if s:yr_has_voperator == 1 let s:yr_remove_omap_dot = 1 @@ -1636,7 +1650,8 @@ endfor endif - silent! nmap @ YRMapsExpression("", "@", "1") + " silent! nmap @ YRMapsExpression("", "@", "1") + silent! nmap @ :YRMapsMacro let s:yr_maps_created_zap = 1 @@ -1719,12 +1734,12 @@ let g:yankring_enabled = 1 let s:yr_maps_created = 1 - if exists('*YRRunAfterMaps') + if exists('*YRRunAfterMaps') " This will allow you to override the default maps if necessary call YRRunAfterMaps() endif endfunction - + " Create the default maps function! s:YRMapsDelete(...) @@ -1732,6 +1747,7 @@ let o_maps = split(g:yankring_zap_keys) for key in o_maps try + " Why not remove the @ map? if key != '@' silent! exec 'ounmap' key endif @@ -1766,7 +1782,7 @@ endtry endfor - if g:yankring_map_dot == 1 + if g:yankring_map_dot == 1 silent! exec "nunmap ." endif if g:yankring_v_key != '' @@ -1807,7 +1823,7 @@ silent! exec 'nunmap '.g:yankring_replace_n_nkey endif - silent! exec 'nunmap @' + " silent! exec 'nunmap @' let g:yankring_enabled = 0 let s:yr_maps_created = 0 @@ -1826,7 +1842,7 @@ let elem = matchstr(elem, '^.*\ze,.*$') if s:yr_history_version == 'v1' " Match three @@@ in a row as long as it is not - " preceeded by a @@@ + " preceeded by a @@@ " v1 let elem = substitute(elem, s:yr_history_v1_nl_pat, "\n", 'g') let elem = substitute(elem, '\\@', '@', 'g') @@ -1918,7 +1934,7 @@ let found = s:YRMRUHas(a:mru_list, elem) - " Special case for efficiency, if it is first item in the + " Special case for efficiency, if it is first item in the " List, do nothing if found != 0 if found != -1 @@ -1933,7 +1949,7 @@ endfunction function! s:YRMRUDel( mru_list, elem_nbr ) - if a:elem_nbr >= 0 && a:elem_nbr < s:yr_count + if a:elem_nbr >= 0 && a:elem_nbr < s:yr_count call remove({a:mru_list}, a:elem_nbr) call s:YRHistorySave() endif @@ -1956,7 +1972,7 @@ endif return 0 -endfunction +endfunction function! s:YRHistoryRead() let refresh_needed = 1 @@ -1993,7 +2009,7 @@ let s:yr_history_list = yr_history_list call s:YRHistorySave() -endfunction +endfunction function! s:YRHistorySave() let yr_filename = s:yr_history_file_{s:yr_history_version} @@ -2014,7 +2030,7 @@ \ yr_filename \ ) endif -endfunction +endfunction function! s:YRHistoryUpgrade(version) if a:version == 'v1' @@ -2038,7 +2054,7 @@ \ ) endif endif -endfunction +endfunction " YRWindowUpdate " Checks if the yankring window is already open. @@ -2069,14 +2085,14 @@ return "" endif " Switch to the yankring buffer - if orig_win_bufnr != yr_win_bufnr + if orig_win_bufnr != yr_win_bufnr " If the buffer is visible, switch to it exec yr_win_bufnr . "wincmd w" endif let msg = 'AutoClose='.g:yankring_window_auto_close. \ ';ClipboardMonitor='.g:yankring_clipboard_monitor. - \ ';Cmds:,[g]p,[g]P,d,r,s,a,c,u,R,q,;Help=?'. + \ ';Cmds:,[g]p,[g]P,1-9,d,r,s,a,c,u,R,q,;Help=?'. \ (s:yr_search==""?"":';SearchRegEx='.s:yr_search) if s:yr_has_voperator == 0 @@ -2086,11 +2102,13 @@ " Toggle help by checking the first line of the buffer if a:show_help == 1 && getline(1) !~ 'selection' let full_help = 1 - let msg = + let msg = \ '" : [p]aste selection'."\n". \ '" double-click : [p]aste selection'."\n". \ '" [g]p : [g][p]aste selection'."\n". \ '" [g]P : [g][P]aste selection'."\n". + \ '" 1-9 : Paste # entry from the YankRing (shortcut for speed)'."\n". + \ '" d : [d]elete item from the YankRing'."\n". \ '" r : [p]aste selection in reverse order'."\n". \ '" s : [s]earch the yankring for text'."\n". \ '" u : [u]pdate display show YankRing'."\n". @@ -2101,8 +2119,9 @@ \ '" ? : Remove help text'."\n". \ '" : toggles the width of the window'."\n". \ '" Visual mode is supported for above commands'."\n". + \ '" YankRing Version: '.g:loaded_yankring."\n". \ msg - endif + endif let saveMod = &modifiable @@ -2126,7 +2145,7 @@ let &modifiable = saveMod - if orig_win_bufnr != s:yr_buffer_id + if orig_win_bufnr != s:yr_buffer_id exec orig_win_bufnr . "wincmd w" endif endfunction @@ -2136,9 +2155,11 @@ function! s:YRWindowOpen(results) " Setup the cpoptions properly for the maps to work + " and to not set the alternate buffer let old_cpoptions = &cpoptions set cpoptions&vim - setlocal cpoptions-=a,A + set cpoptions-=a + set cpoptions-=A " Save the current buffer number. The yankring will switch back to " this buffer when an action is taken. @@ -2184,19 +2205,19 @@ endif " Special consideration was involved with these sequence - " of commands. + " of commands. " First, split the current buffer. " Second, edit a new file. " Third record the buffer number. " If a different sequence is followed when the yankring " buffer is closed, Vim's alternate buffer is the yanking - " instead of the original buffer before the yankring + " instead of the original buffer before the yankring " was shown. let cmd_mod = '' if v:version >= 700 let cmd_mod = 'keepalt ' endif - exec 'silent! ' . cmd_mod . location . ' ' . win_size . 'split ' + exec 'silent! ' . cmd_mod . location . ' ' . win_size . 'split ' " Using :e and hide prevents the alternate buffer " from being changed. @@ -2227,6 +2248,7 @@ setlocal nonumber setlocal nobuflisted setlocal noreadonly + setlocal nospell setlocal modifiable " set up syntax highlighting @@ -2291,6 +2313,15 @@ nnoremap u :call YRWindowAction ('u' , 'n') nnoremap q :call YRWindowAction ('q' , 'n') nnoremap R :call YRWindowAction ('R' , 'n') + nnoremap 1 :call YRWindowAction ('q' ,'n'):call YRGetElem(1) + nnoremap 2 :call YRWindowAction ('q' ,'n'):call YRGetElem(2) + nnoremap 3 :call YRWindowAction ('q' ,'n'):call YRGetElem(3) + nnoremap 4 :call YRWindowAction ('q' ,'n'):call YRGetElem(4) + nnoremap 5 :call YRWindowAction ('q' ,'n'):call YRGetElem(5) + nnoremap 6 :call YRWindowAction ('q' ,'n'):call YRGetElem(6) + nnoremap 7 :call YRWindowAction ('q' ,'n'):call YRGetElem(7) + nnoremap 8 :call YRWindowAction ('q' ,'n'):call YRGetElem(8) + nnoremap 9 :call YRWindowAction ('q' ,'n'):call YRGetElem(9) nnoremap \|:silent exec 'vertical resize '. \ ( \ g:yankring_window_use_horiz!=1 && winwidth('.') > g:yankring_window_width @@ -2301,7 +2332,7 @@ " Erase it's contents to the blackhole silent! exec '%delete _' - " Display the status line / help + " Display the status line / help call s:YRWindowStatus(0) exec 'normal! G' @@ -2315,7 +2346,7 @@ " Move the cursor to the first line with an element exec 0 - call search('^\d','W') + call search('^\d','W') setlocal nomodifiable " @@ -2324,7 +2355,7 @@ endfunction -function! s:YRWindowActionN(op, cmd_mode) +function! s:YRWindowActionN(op, cmd_mode) let v_count = v:count " If no count was specified it will have a value of 0 " so set it to at least 1 @@ -2343,18 +2374,18 @@ endif return endif - + call s:YRWindowAction(a:op, a:cmd_mode) let v_count = v_count - 1 if g:yankring_window_auto_close == 1 && v_count == 0 && a:op != 'd' - " If autoclose is set close the window unless + " If autoclose is set close the window unless " you are removing items from the YankRing exec 'bdelete '.s:yr_buffer_id - return "" + return "" endif - return "" + return "" endfunction function! s:YRWindowAction(op, cmd_mode) range @@ -2382,17 +2413,17 @@ " so set it to at least 1 let v_count = ((v_count > 0)?(v_count):1) - if '[dr]' =~ opcode + if '[dr]' =~ opcode " Reverse the order of the lines to act on let begin = lastline - while begin >= firstline + while begin >= firstline call add(lines, getline(begin)) let begin = begin - 1 endwhile else " Process the selected items in order let begin = firstline - while begin <= lastline + while begin <= lastline call add(lines, getline(begin)) let begin = begin + 1 endwhile @@ -2418,48 +2449,48 @@ elseif opcode ==# 's' " Switch back to the original buffer exec s:yr_buffer_last_winnr . "wincmd w" - + call s:YRSearch() return elseif opcode ==# 'u' " Switch back to the original buffer exec s:yr_buffer_last_winnr . "wincmd w" - + call s:YRShow(0) return elseif opcode ==# 'R' " Switch back to the original buffer exec s:yr_buffer_last_winnr . "wincmd w" - + call s:YRShow(0, 'R') return elseif opcode ==# 'a' let l:curr_line = line(".") " Toggle the auto close setting - let g:yankring_window_auto_close = + let g:yankring_window_auto_close = \ (g:yankring_window_auto_close == 1?0:1) - " Display the status line / help + " Display the status line / help call s:YRWindowStatus(0) call cursor(l:curr_line,0) return elseif opcode ==# 'c' let l:curr_line = line(".") " Toggle the clipboard monitor setting - let g:yankring_clipboard_monitor = + let g:yankring_clipboard_monitor = \ (g:yankring_clipboard_monitor == 1?0:1) - " Display the status line / help + " Display the status line / help call s:YRWindowStatus(0) call cursor(l:curr_line,0) return elseif opcode ==# '?' - " Display the status line / help + " Display the status line / help call s:YRWindowStatus(1) return endif " Switch back to the original buffer exec s:yr_buffer_last_winnr . "wincmd w" - + " Intentional case insensitive comparision if opcode =~? 'p' let cmd = 'YRGetElem ' @@ -2475,7 +2506,7 @@ " Only execute this code if we are operating on elements " within the yankring - if '[auq?]' !~# opcode + if '[auq?]' !~# opcode while v_count > 0 " let iter = 0 " let index = 0 @@ -2499,37 +2530,44 @@ if opcode ==# 'd' call s:YRShow(0) + " Return the user to their last known position, assuming + " it is still available after the delete + if firstline < line("$") + call cursor(firstline,0) + else + call cursor(line("$"),0) + endif return "" endif if g:yankring_window_auto_close == 1 && cmd_mode == 'v' exec 'bdelete '.s:yr_buffer_id - return "" + return "" endif endif - return "" + return "" endfunction - + function! s:YRWarningMsg(msg) echohl WarningMsg - echomsg a:msg + echomsg a:msg echohl None endfunction - + function! s:YRErrorMsg(msg) echohl ErrorMsg - echomsg a:msg + echomsg a:msg echohl None endfunction - + function! s:YRWinLeave() " Track which window we are last in. We will use this information - " to determine where we need to paste any contents, or which + " to determine where we need to paste any contents, or which " buffer to return to. - + if s:yr_buffer_id < 0 " The yankring window has never been activated return @@ -2549,7 +2587,7 @@ " let s:yr_buffer_last = -1 endif endfunction - + function! s:YRFocusGained() " FocusGained is not available in general by console vim. " There are some terminal windows which support it though. @@ -2563,23 +2601,23 @@ " " Simple test, create the following autocmd and gain and loose focus in " the terminal: - " autocmd FocusLost * echomsg "focus lost" - " autocmd FocusGained * echomsg "focus gained" + " autocmd FocusLost * echomsg "focus lost" + " autocmd FocusGained * echomsg "focus gained" call s:YRCheckClipboard() " If the yankring window is open, refresh it call s:YRWindowUpdate() endfunction - + function! s:YRCheckClipboard() if g:yankring_clipboard_monitor == 1 " If the clipboard has changed record it inside the yankring - " echomsg "YRCheckClipboard[".len(@*)."][".@*.']['.s:yr_prev_clipboard.']' + " echomsg "YRCheckClipboard[".len(@*)."][".@*.']['.s:yr_prev_clipboard_star.']' if has('unnamedplus') && &clipboard =~ '\' - if len(@+) > 0 && @+ != s:yr_prev_clipboard - let elem = s:YRMRUElemFormat( + if len(@+) > 0 && @+ != s:yr_prev_clipboard_plus + let elem = s:YRMRUElemFormat( \ getreg('+') - \ , getregtype('+') + \ , getregtype('+') \ ) let found = s:YRMRUHas('s:yr_history_list', elem) @@ -2588,13 +2626,13 @@ if found == -1 call YRRecord3("+") endif - let s:yr_prev_clipboard = @+ + let s:yr_prev_clipboard_plus = @+ endif else - if len(@*) > 0 && @* != s:yr_prev_clipboard - let elem = s:YRMRUElemFormat( + if len(@*) > 0 && @* != s:yr_prev_clipboard_star + let elem = s:YRMRUElemFormat( \ getreg('*') - \ , getregtype('*') + \ , getregtype('*') \ ) let found = s:YRMRUHas('s:yr_history_list', elem) @@ -2603,7 +2641,7 @@ if found == -1 call YRRecord3("*") endif - let s:yr_prev_clipboard = @* + let s:yr_prev_clipboard_star = @* endif endif endif @@ -2611,33 +2649,33 @@ function! s:YRInsertLeave() " The YankRing uses omaps to execute the prescribed motion - " and then appends to the motion a call to a YankRing + " and then appends to the motion a call to a YankRing " function to record the contents of the changed register. " " We cannot append a function call to the end of a motion " that results in Insert mode. For example, any command " like 'cw' enters insert mode. Appending a function call - " after the w, simply writes out the call as if the user + " after the w, simply writes out the call as if the user " typed it. " - " Using the InsertLeave event, allows us to capture the + " Using the InsertLeave event, allows us to capture the " contents of any changed register after it completes. - + call YRRecord(s:YRRegister()) " When performing a change (not a yank or delete) " it is not possible to call yrrecord at the end - " of the command (or it's contents will be inserted + " of the command (or it's contents will be inserted " into the buffer instead of executed). " So, when using ".", we have to remove the _zap_ - " keys and then re-add them back again after we + " keys and then re-add them back again after we " record the updates. if s:yr_remove_omap_dot == 1 call s:YRMapsCreate('add_only_zap_keys') endif endfunction - + " Deleting autocommands first is a good idea especially if we want to reload " the script without restarting vim. " Call YRFocusGained to check if the clipboard has been updated @@ -2676,9 +2714,9 @@ command! -nargs=? YRCheckClipboard call s:YRCheckClipboard() command! -count -register -nargs=* YRYankCount call s:YRYankCount() command! -range -bang -nargs=? YRYankRange ,call s:YRYankRange(0, ) -" command! -range -bang -nargs=0 YRMapsMacro ,call s:YRMapsMacro(0, ) - -" Menus +command! -count=1 -bang -nargs=0 YRMapsMacro call s:YRMapsMacro(0, ) + +" Menus " 0: Turns the menu off. if has("menu") && g:yankring_default_menu_mode != 0 if g:yankring_default_menu_mode == 1 @@ -2689,7 +2727,7 @@ " 2: Turns the 'Yankring 'menu on with -y as the shortcut. let menuRoot = '&YankRing' let menuPriority = '' - elseif g:yankring_default_menu_mode == 3 + elseif g:yankring_default_menu_mode == 3 " 3: Turns the 'Plugin -> YankRing' menu on with -y as the shortcut. let menuRoot = exists("g:yankring_menu_root") ? g:yankring_menu_root : '&Plugin.&YankRing' let menuPriority = exists("g:yankring_menu_priority") ? yankring_menu_priority : ''