Permalink
Browse files

Version 17.0

NF: The yankring_history_dir option can now take a comma separated list.  First valid directory found will be used (Alex Bel).

NF: YankRing can now monitor inserted text and place it in the ring. This is disabled by default, but can be enabled either through the YankRing window or via your .vimrc using the new option:
    g:yankring_record_insert = 1 (Alexandre Viau).

BF: When g:yankring_persist = 0, the YankRing was still reading and writing to the yankring file (Vladimir Marek).

BF: The YankRing menu entry, "Replace with Next", was performing the "Replace with Previous" action (Thilo Six).
  • Loading branch information...
1 parent 0c74d5b commit a884f3a161fa3cd8c996eb53a3d1c68631f60c21 @dfishburn dfishburn committed with Apr 28, 2013
Showing with 111 additions and 32 deletions.
  1. +34 −11 doc/yankring.txt
  2. +77 −21 plugin/yankring.vim
View
@@ -1,7 +1,7 @@
*yankring.txt* For Vim version 7.0.
Author: David Fishburn Jnauary 20, 2013
-Version: 16.0
+Version: 17.0
For instructions on installing this file, type
:help add-local-help |add-local-help| inside Vim.
@@ -183,12 +183,20 @@ your |.vimrc|.
action is performed and the buffer window is closed, returning you to
the original buffer. This option can be toggled from within the
YankRing buffer by pressing [a]. The YankRing buffer status line
- visually indicates where auto close is enabled or disabled. There are
+ visually indicates when auto close is enabled or disabled. There are
many times where you need to paste (or delete) many items from the
yankring. Pressing [a], disables auto close, allows you to paste many
items, and finally you can press [a] to re-enable auto close, followed
by [q] to quit the buffer window. >
let g:yankring_window_auto_close = 1
+ yankring_record_insert
+< Default: 0
+ If you want text you insert to be recorded in the YankRing you can
+ enable this feature two ways. From within the YankRing window you can
+ press [i]. The YankRing buffer status line visually indicates when
+ recording inserts is enabled or disabled. To enable this option
+ at Vim startup, put the following in your .vimrc: >
+ let g:yankring_record_insert = 1
yankring_window_use_horiz
< Default: 1
When the YankRing window is opened, it uses a horizontal split at the
@@ -246,6 +254,9 @@ your |.vimrc|.
< Default: $HOME
The YankRing stores the text in a file. This global variable
allows you to customize where the file(s) will be stored.
+ This can be a comma separated list, which is useful if your
+ .vimrc is shared across different machines. If multipe directories
+ are specified, the first valid directory will be used.
You can put the following in your |vimrc| >
let g:yankring_history_dir = '$VIM'
yankring_history_file
@@ -306,7 +317,7 @@ your |.vimrc|.
"3": Turns the 'Plugin -> YankRing' menu on with <alt>-y as
the shortcut.
This option defaults to a value of 3 and can be changed
- by adding the following to your vimrc: >
+ by adding the following to your .vimrc: >
:let g:yankring_default_menu_mode = 3
yankring_menu_root
< - Can be used in conjuction with g:yankring_default_menu_mode = 3 but
@@ -518,7 +529,7 @@ YRYankCount tells Vim to execute y$ instead.
3.4 Customizing Menus *yankring-custom-menus*
-There are several global variables which can be created in your vimrc to
+There are several global variables which can be created in your .vimrc to
allow you to customize where and what is displayed for the YankRing menu.
Simply look up the following global variables: >
yankring_default_menu_mode
@@ -1220,6 +1231,18 @@ mapping: >
==============================================================================
7. History *yankring-history*
+ 17.0: April 28, 2013
+ NF: The yankring_history_dir option can now take a comma separated
+ list. First valid directory found will be used (Alex Bel).
+ NF: YankRing can now monitor inserted text and place it in the ring.
+ This is disabled by default, but can be enabled either through
+ the YankRing window or via your .vimrc using the new option:
+ g:yankring_record_insert = 1 (Alexandre Viau).
+ BF: When g:yankring_persist = 0, the YankRing was still reading
+ and writing to the yankring file (Vladimir Marek).
+ BF: The YankRing menu entry, "Replace with Next", was performing
+ the "Replace with Previous" action (Thilo Six).
+
16.0: January 20, 2013
BF: YankRing could report "YR: A register cannot be specified in
replace mode" when using clipboard = unnamed or unnamedplus.
@@ -1444,7 +1467,7 @@ mapping: >
NF: The global variables which allow you to customize the behaviour
are now space separated instead of comma separated. This
provides greater flexibility but will require you to modify
- your vimrc (if you have customized it). (Andy Wokula)
+ your .vimrc (if you have customized it). (Andy Wokula)
BF: If using <C-O> from within insert mode, the YankRing inserted
characters into the buffer instead of capturing the changes,
this was fixed by Andy Wokula (Agathoklis Hatzimanikas).
@@ -1483,11 +1506,11 @@ mapping: >
NF: The YankRing window always opened bottom horizontal. Now it
can be opened top or bottom and horizontal or vertically.
This can be controlled via variables in your .vimrc.
- BF: The YankRing has an option to persist between instances
- of Vim by storing the values in global variables within
- the viminfo. This has led to some unusual ordering of
- items in the ring from conflicts between instances.
- This option has been turned off by default.
+ BF: The YankRing has an option to persist between instances of Vim by
+ storing the values in global variables within the viminfo. This
+ has led to some unusual ordering of items in the ring from
+ conflicts between instances. This option has been turned off by
+ default.
BF: Their was an issue with yanking using y$.
3.1: September 10, 2007:
@@ -1532,7 +1555,7 @@ mapping: >
are a number of maps that allow you to interact with the
contents. The window can be positioned vertically or
horizontally as well as being sized all through options
- specified in your vimrc.
+ specified in your .vimrc.
NF: YRPop can now delete any items from the yankring, rather
that just from the top.
NF: YRSetTop has been removed, it is no longer required as the
View
@@ -1,9 +1,9 @@
" yankring.vim - Yank / Delete Ring for Vim
" ---------------------------------------------------------------
-" Version: 16.0
+" Version: 17.0
" Author: David Fishburn <dfishburn dot vim at gmail dot com>
" Maintainer: David Fishburn <dfishburn dot vim at gmail dot com>
-" Last Modified: 2013 Jan 20
+" Last Modified: 2013 Apr 28
" 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 @@ if v:version < 700
finish
endif
-let loaded_yankring = 160
+let loaded_yankring = 170
" Turn on support for line continuations when creating the script
let s:cpo_save = &cpo
@@ -33,7 +33,13 @@ endif
if !exists('g:yankring_history_dir')
let g:yankring_history_dir = expand('$HOME')
else
- let g:yankring_history_dir = expand(g:yankring_history_dir)
+ " let g:yankring_history_dir = expand(g:yankring_history_dir)
+ for dir in split(g:yankring_history_dir, ",")
+ if isdirectory(expand(dir))
+ let g:yankring_history_dir = expand(dir)
+ break
+ endif
+ endfor
endif
if !exists('g:yankring_history_file')
@@ -138,6 +144,11 @@ if !exists('g:yankring_ignore_duplicate')
let g:yankring_ignore_duplicate = 1
endif
+" Determine whether to record inserted data
+if !exists('g:yankring_record_insert')
+ let g:yankring_record_insert = 0
+endif
+
" Vim automatically manages the numbered registers:
" 0 - last yanked text
" 1-9 - last deleted items
@@ -264,16 +275,18 @@ let s:yr_history_v1_nl_pat = '\%(\\\)\@<!@@@'
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 =
- \ g:yankring_history_dir.'/'.
- \ g:yankring_history_file.
- \ (g:yankring_share_between_instances==1?'':'_'.v:servername).
- \ '.txt'
-let s:yr_history_file_v2 =
- \ g:yankring_history_dir.'/'.
- \ g:yankring_history_file.
- \ (g:yankring_share_between_instances==1?'':'_'.v:servername).
- \ '_v2.txt'
+if g:yankring_persist == 1
+ 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 =
+ \ g:yankring_history_dir.'/'.
+ \ g:yankring_history_file.
+ \ (g:yankring_share_between_instances==1?'':'_'.v:servername).
+ \ '_v2.txt'
+endif
" Vim window size is changed by the yankring plugin or not
@@ -752,7 +765,7 @@ function! s:YRInit(...)
" reset prior to issuing the YRReplace
let s:yr_prev_vis_mode = 0
- if a:0 == 0 && g:yankring_persist == 0
+ if a:0 == 0 && g:yankring_persist != 1
" The user wants the yankring reset each time Vim is started
call s:YRClear()
endif
@@ -1994,6 +2007,7 @@ function! s:YRMRUAdd( mru_list, element, element_type )
call remove({a:mru_list}, found)
endif
call insert({a:mru_list}, elem, 0)
+ let s:yr_count = len({a:mru_list})
call s:YRHistorySave()
endif
@@ -2003,6 +2017,7 @@ endfunction
function! s:YRMRUDel( mru_list, elem_nbr )
if a:elem_nbr >= 0 && a:elem_nbr < s:yr_count
call remove({a:mru_list}, a:elem_nbr)
+ let s:yr_count = len({a:mru_list})
call s:YRHistorySave()
endif
@@ -2011,6 +2026,11 @@ endfunction
function! s:YRHistoryDelete()
let s:yr_history_list = []
+ let s:yr_count = 0
+
+ if g:yankring_persist != 1
+ return
+ endif
let yr_filename = s:yr_history_file_{s:yr_history_version}
if filereadable(yr_filename)
@@ -2027,6 +2047,9 @@ function! s:YRHistoryDelete()
endfunction
function! s:YRHistoryRead()
+ if g:yankring_persist != 1
+ return
+ endif
let refresh_needed = 1
let yr_history_list = []
let yr_filename = s:yr_history_file_{s:yr_history_version}
@@ -2060,22 +2083,25 @@ function! s:YRHistoryRead()
let s:yr_history_list = yr_history_list
call s:YRHistorySave()
-
endfunction
function! s:YRHistorySave()
- let yr_filename = s:yr_history_file_{s:yr_history_version}
if len(s:yr_history_list) > g:yankring_max_history
" Remove items which exceed the max # specified
- call remove(s:yr_history_list, g:yankring_max_history)
+ call remove(s:yr_history_list, g:yankring_max_history, (len(s:yr_history_list)-1))
+ let s:yr_count = len(s:yr_history_list)
+ endif
+
+ if g:yankring_persist != 1
+ return
endif
+ let yr_filename = s:yr_history_file_{s:yr_history_version}
let rc = writefile(s:yr_history_list, yr_filename)
if rc == 0
let s:yr_history_last_upd = getftime(yr_filename)
- let s:yr_count = len(s:yr_history_list)
else
call s:YRErrorMsg(
\ 'YRHistorySave: Unable to save yankring history file: '.
@@ -2144,7 +2170,8 @@ function! s:YRWindowStatus(show_help)
let msg = 'AutoClose='.g:yankring_window_auto_close.
\ ';ClipboardMonitor='.g:yankring_clipboard_monitor.
- \ ';Cmds:<enter>,[g]p,[g]P,1-9,d,r,s,a,c,u,R,q,<space>;Help=?'.
+ \ ';Inserts='.g:yankring_record_insert.
+ \ ';Cmds:<enter>,[g]p,[g]P,1-9,d,r,s,a,c,i,u,R,q,<space>;Help=?'.
\ (s:yr_search==""?"":';SearchRegEx='.s:yr_search)
if s:yr_has_voperator == 0
@@ -2167,6 +2194,7 @@ function! s:YRWindowStatus(show_help)
\ '" R : [R]egisters display'."\n".
\ '" a : toggle [a]utoclose setting'."\n".
\ '" c : toggle [c]lipboard monitor setting'."\n".
+ \ '" i : toggle [i]nsert recording'."\n".
\ '" q : [q]uit / close the yankring window'."\n".
\ '" ? : Remove help text'."\n".
\ '" <space> : toggles the width of the window'."\n".
@@ -2365,6 +2393,7 @@ function! s:YRWindowOpen(results)
nnoremap <buffer> <silent> s :call <SID>YRWindowAction ('s' , 'n')<CR>
nnoremap <buffer> <silent> a :call <SID>YRWindowAction ('a' , 'n')<CR>
nnoremap <buffer> <silent> c :call <SID>YRWindowAction ('c' , 'n')<CR>
+ nnoremap <buffer> <silent> i :call <SID>YRWindowAction ('i' , 'n')<CR>
nnoremap <buffer> <silent> ? :call <SID>YRWindowAction ('?' , 'n')<CR>
nnoremap <buffer> <silent> u :call <SID>YRWindowAction ('u' , 'n')<CR>
nnoremap <buffer> <silent> q :call <SID>YRWindowAction ('q' , 'n')<CR>
@@ -2540,6 +2569,15 @@ function! s:YRWindowAction(op, cmd_mode) range
call s:YRWindowStatus(0)
call cursor(l:curr_line,0)
return
+ elseif opcode ==# 'i'
+ let l:curr_line = line(".")
+ " Toggle the auto close setting
+ let g:yankring_record_insert =
+ \ (g:yankring_record_insert == 1?0:1)
+ " Display the status line / help
+ call s:YRWindowStatus(0)
+ call cursor(l:curr_line,0)
+ return
elseif opcode ==# '?'
" Display the status line / help
call s:YRWindowStatus(1)
@@ -2732,6 +2770,24 @@ function! s:YRInsertLeave()
call s:YRMapsCreate('add_only_zap_keys')
endif
+ " Check if we should record inserted text
+ if g:yankring_record_insert == 1
+ if !empty(@.) && @. != s:yr_prev_reg_insert
+ let elem = s:YRMRUElemFormat(
+ \ getreg('.')
+ \ , getregtype('.')
+ \ )
+ let found = s:YRMRUHas('s:yr_history_list', elem)
+
+ " Only add the item to the "top" of the ring if it is
+ " not in the ring already.
+ if found == -1
+ call YRRecord3(".")
+ endif
+ let s:yr_prev_reg_insert = @.
+ endif
+ endif
+
endfunction
" Deleting autocommands first is a good idea especially if we want to reload
@@ -2804,7 +2860,7 @@ if has("menu") && g:yankring_default_menu_mode != 0
exec 'noremenu <script> '.menuPriority.' '.menuRoot.'.YankRing\ Window :YRShow<CR>'
exec 'noremenu <script> '.menuPriority.' '.menuRoot.'.YankRing\ Search :YRSearch<CR>'
exec 'noremenu <script> '.menuPriority.' '.menuRoot.'.Replace\ with\ Previous<TAB>'.leader.g:yankring_replace_n_pkey.' :YRReplace -1, ''P''<CR>'
- exec 'noremenu <script> '.menuPriority.' '.menuRoot.'.Replace\ with\ Next<TAB>'.leader.g:yankring_replace_n_pkey.' :YRReplace 1, ''P''<CR>'
+ exec 'noremenu <script> '.menuPriority.' '.menuRoot.'.Replace\ with\ Next<TAB>'.leader.g:yankring_replace_n_nkey.' :YRReplace 1, ''P''<CR>'
exec 'noremenu <script> '.menuPriority.' '.menuRoot.'.Clear :YRClear<CR>'
exec 'noremenu <script> '.menuPriority.' '.menuRoot.'.Toggle :YRToggle<CR>'
exec 'noremenu <script> '.menuPriority.' '.menuRoot.'.Check\ Clipboard :YRCheckClipboard<CR>'

0 comments on commit a884f3a

Please sign in to comment.