Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Version 3.10

- Add g,'p and g,"p variants of g,p.
- ENH: Allow to specify prefix and suffix when querying for the separator string in gqp and i_CTRL-R_CTRL-Q.
  • Loading branch information...
commit 1ace5e3aae521499679f254950d4a06d176d7ba2 1 parent d786600
Ingo Karkat authored committed
View
11 README
@@ -104,8 +104,17 @@ USAGE
["x]g,p, ["x]g,P Paste characterwise, with each line delimited by ", "
instead of the newline (and indent).
+["x]g,'p, ["x]g,'P Paste characterwise, with each line surrounded by
+["x]g,"p, ["x]g,"P single / double quotes and delimited by ", " instead
+ of the newline (and indent).
+
["x]gqp, ["x]gqP Query for a separator string, then paste
characterwise, with each line delimited by it.
+ You can also additionally input a prefix and suffix
+ (as {prefix}^M{separator}^M{suffix}, with ^M entered
+ as <C-V><Enter>). Examples:
+ "^M, ^M" -> "foo, bar, baz"
+ "^M", "^M" -> "foo", "bar", "baz"
["x]gQp, ["x]gQP Paste characterwise, with each line delimited by the
previously queried (gqp) separator string.
@@ -148,7 +157,7 @@ CTRL-R , {0-9a-z"%#*+/:.-}
CTRL-R CTRL-Q {0-9a-z"%#*+/:.-}
Query for a separator string, then insert the contents
of a register characterwise, with each line delimited
- by it.
+ by it. Like gqp, but in insert mode.
CTRL-R CTRL-Q CTRL-Q {0-9a-z"%#*+/:.-}
Insert the contents of a register characterwise, with
View
31 autoload/UnconditionalPaste.vim
@@ -14,6 +14,10 @@
" http://vim.wikia.com/wiki/Unconditional_linewise_or_characterwise_paste
"
" REVISION DATE REMARKS
+" 3.10.031 03-Dec-2014 Add g,'p and g,"p variants of g,p.
+" ENH: Allow to specify prefix and suffix when
+" querying for the separator string in gqp and
+" i_CTRL-R_CTRL-Q.
" 3.02.030 17-Jun-2014 CHG: Change default mappings of gdp and gDp to
" gqbp and gQBp, respectively.
" 3.01.029 05-May-2014 For gsp, remove surrounding whitespace
@@ -212,8 +216,9 @@ function! UnconditionalPaste#Paste( regName, how, ... )
if a:how ==# 'b'
let l:pasteType = 'b'
- elseif a:how =~# '^[c,qQ]$'
+ elseif a:how =~# '^[c,qQ]$\|^,[''"]$'
let l:pasteType = 'c'
+ let [l:prefix, l:suffix, l:linePrefix, l:lineSuffix] = ['', '', '', '']
if l:regType[0] ==# "\<C-v>"
let l:pasteContent = s:StripTrailingWhitespace(l:regContent)
@@ -221,17 +226,31 @@ function! UnconditionalPaste#Paste( regName, how, ... )
if a:how ==# 'c'
let l:separator = ' '
- elseif a:how ==# ','
+ elseif a:how[0] ==# ','
let l:separator = ', '
+ if ! empty(a:how[1])
+ let [l:prefix, l:suffix, l:linePrefix, l:lineSuffix] = repeat([a:how[1:]], 4)
+ endif
elseif a:how ==# 'q'
- let l:separator = input('Enter separator string: ')
+ let l:separator = input('Enter separator string (or prefix^Mseparator^Msuffix): ')
if empty(l:separator)
execute "normal! \<C-\>\<C-n>\<Esc>" | " Beep.
return ''
endif
- let g:UnconditionalPaste_JoinSeparator = l:separator
+
+ unlet! g:UnconditionalPaste_JoinSeparator
+ if l:separator =~# '^\%(\r\@!.\)*\r\%(\r\@!.\)*\r\%(\r\@!.\)*$'
+ let g:UnconditionalPaste_JoinSeparator = split(l:separator, '\r', 1)
+ let [l:prefix, l:separator, l:suffix] = g:UnconditionalPaste_JoinSeparator
+ else
+ let g:UnconditionalPaste_JoinSeparator = l:separator
+ endif
elseif a:how ==# 'Q'
- let l:separator = g:UnconditionalPaste_JoinSeparator
+ if type(g:UnconditionalPaste_JoinSeparator) == type([])
+ let [l:prefix, l:separator, l:suffix] = g:UnconditionalPaste_JoinSeparator
+ else
+ let l:separator = g:UnconditionalPaste_JoinSeparator
+ endif
else
throw 'ASSERT: Invalid how: ' . string(a:how)
endif
@@ -243,7 +262,7 @@ function! UnconditionalPaste#Paste( regName, how, ... )
let l:count = 0
endif
- let l:pasteContent = s:Flatten(l:pasteContent, l:separator)
+ let l:pasteContent = l:prefix . s:Flatten(l:pasteContent, l:linePrefix . l:separator . l:lineSuffix) . l:suffix
if a:0 && a:how !=# 'c' && s:IsSingleElement(l:regContent)
" DWIM: Put the separator in front (gqp) / after (gqP);
View
20 doc/UnconditionalPaste.txt
@@ -123,9 +123,18 @@ USAGE *UnconditionalPaste-usage*
*g,p* *g,P*
["x]g,p, ["x]g,P Paste characterwise, with each line delimited by ", "
instead of the newline (and indent).
+ *g,'p* *g,'P* *g,quotep* *g,quoteP*
+["x]g,'p, ["x]g,'P Paste characterwise, with each line surrounded by
+["x]g,"p, ["x]g,"P single / double quotes and delimited by ", " instead
+ of the newline (and indent).
*gqp* *gqP*
["x]gqp, ["x]gqP Query for a separator string, then paste
characterwise, with each line delimited by it.
+ You can also additionally input a prefix and suffix
+ (as {prefix}^M{separator}^M{suffix}, with ^M entered
+ as <C-V><Enter>). Examples:
+ "^M, ^M" -> "foo, bar, baz" ~
+ "^M", "^M" -> "foo", "bar", "baz" ~
*gQp* *gQP*
["x]gQp, ["x]gQP Paste characterwise, with each line delimited by the
previously queried (|gqp|) separator string.
@@ -171,7 +180,7 @@ CTRL-R , {0-9a-z"%#*+/:.-} *i_CTRL-R_,* *c_CTRL-R_,*
CTRL-R CTRL-Q {0-9a-z"%#*+/:.-} *i_CTRL-R_CTRL-Q* *c_CTRL-R_CTRL-Q*
Query for a separator string, then insert the contents
of a register characterwise, with each line delimited
- by it.
+ by it. Like |gqp|, but in insert mode.
*i_CTRL-R_CTRL-Q_CTRL-Q* *c_CTRL-R_CTRL-Q_CTRL-Q*
CTRL-R CTRL-Q CTRL-Q {0-9a-z"%#*+/:.-}
Insert the contents of a register characterwise, with
@@ -267,6 +276,10 @@ script (e.g. in your |vimrc|): >
nmap <Leader>pD <Plug>UnconditionalPasteRecallDelimitedAfter
nmap <Leader>P, <Plug>UnconditionalPasteCommaBefore
nmap <Leader>p, <Plug>UnconditionalPasteCommaAfter
+ nmap <Leader>P' <Plug>UnconditionalPasteCommaSingleQuoteBefore
+ nmap <Leader>p' <Plug>UnconditionalPasteCommaSingleQuoteAfter
+ nmap <Leader>P" <Plug>UnconditionalPasteCommaDoubleQuoteBefore
+ nmap <Leader>p" <Plug>UnconditionalPasteCommaDoubleQuoteAfter
nmap <Leader>Pq <Plug>UnconditionalPasteQueriedBefore
nmap <Leader>pq <Plug>UnconditionalPasteQueriedAfter
nmap <Leader>PQ <Plug>UnconditionalPasteRecallQueriedBefore
@@ -306,6 +319,11 @@ IDEAS *UnconditionalPaste-ideas*
==============================================================================
HISTORY *UnconditionalPaste-history*
+3.10 23-Dec-2014
+- Add g,'p and g,"p variants of g,p.
+- ENH: Allow to specify prefix and suffix when querying for the separator
+ string in gqp and i_CTRL-R_CTRL-Q.
+
3.03 03-Dec-2014
- BUG: gsp / gsP border check adds spaces on both sides when there's a single
character in line (like when there's a completely empty line, where this
View
3  plugin/UnconditionalPaste.vim
@@ -14,6 +14,7 @@
" http://vim.wikia.com/wiki/Unconditional_linewise_or_characterwise_paste
"
" REVISION DATE REMARKS
+" 3.10.031 03-Dec-2014 Add g,'p and g,"p variants of g,p.
" 3.02.034 17-Jun-2014 CHG: Change default mappings of gdp and gDp to
" gqbp and gQBp, respectively.
" 3.00.033 21-Mar-2014 Add gBp mapping to paste as a minimal fitting
@@ -144,7 +145,7 @@ endif
function! s:CreateMappings()
for [l:pasteName, l:pasteType] in
\ [
- \ ['Char', 'c'], ['Line', 'l'], ['Block', 'b'], ['Comma', ','],
+ \ ['Char', 'c'], ['Line', 'l'], ['Block', 'b'], ['Comma', ','], ['CommaSingleQuote', ",'"], ['CommaDoubleQuote', ',"'],
\ ['Indented', 'l'],
\ ['MoreIndent', 'm'], ['LessIndent', 'n'],
\ ['Shifted', '>'],
Please sign in to comment.
Something went wrong with that request. Please try again.