Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Force linewise or characterwise paste, regardless of how it was yanked.
VimL
branch: master

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.
latest commit 1ace5e3aae
Ingo Karkat authored committed
Failed to load latest commit information.
autoload Version 3.10
doc Version 3.10
plugin Version 3.10
README Version 3.10

README

This is a mirror of http://www.vim.org/scripts/script.php?script_id=3355

DESCRIPTION
If you're like me, you occasionally do a linewise yank, and then want to
insert that yanked text in the middle of some other line (or vice versa).
The mappings defined by this plugin will allow you to do a character-, line-,
or block-wise paste no matter how you yanked the text, both from normal and
insert mode.

Often, the register contents aren't quite in the form you need them. Maybe you
need to convert yanked lines to comma-separated arguments, maybe join the
lines with another separator, maybe the reverse: un-joining a single line on
some pattern to yield multiple lines. Though you can do the manipulation after
pasting, this plugin offers shortcut mappings for these actions, which are
especially helpful when you need to repeat the paste multiple times.

SOURCE
Based on vimtip #1199 by cory,
    http://vim.wikia.com/wiki/Unconditional_linewise_or_characterwise_paste

RELATED WORKS
- whitespaste.vim (vimscript #4351) automatically removes blank lines around
  linewise contents, and condenses inner lines to a single one. By default, it
  remaps p / P, but this can be changed.

USAGE
["x]gcp, ["x]gcP        Paste characterwise (newline characters and indent are
                        flattened to spaces) [count] times.

["x]glp, ["x]glP        Paste linewise (even if yanked text is not a complete
                        line) [count] times.

["x]gbp, ["x]gbP        Paste blockwise (inserting multiple lines in-place,
                        pushing existing text further to the right) [count]
                        times.

["x]g]p, ["x]g[P  or    Paste linewise (even if yanked text is not a complete
         ["x]g]P  or    line) [count] times like glp, but adjust the indent
         ["x]g[p        to the current line (like ]p).

["x]g]]p, ["x]g]]P      Paste linewise below / above, with [count] more indent
                        than the current line.
["x]g[[p, ["x]g[[P      Paste linewise below / above, with [count] less indent
                        than the current line.

["x]g>p, ["x]g>P        Paste lines with [count] times 'shiftwidth' indent.
                        For characterwise and blockwise register contents,
                        paste at the beginning / end of the line(s) with the
                        indent before (g>p) / after (g>P) each line's
                        content. Multiple characterwise lines are flattened
                        into one as with gcp. The indent of blocks is based
                        on the current line's width; if subsequent lines are
                        longer, and additional indent is added there.

["x]g#p, ["x]g#P        Paste linewise (even if yanked text is not a complete
                        line) as commented text [count] times. This applies
                        'commentstring' to each individual line, and adjusts
                        the indent (of the entire comment) to the current line
                        (like ]p).
                        This is useful when you want to paste indented text as
                        comments, but avoid the progressive auto-indenting
                        that would normally happen with i_CTRL-R.

["x]gsp, ["x]gsP        Paste with [count] spaces (characterwise; blockwise:
                        around each line) / empty lines (linewise) around the
                        register contents. When pasting before the start or
                        after the end of the line / buffer, or with whitespace
                        / empty lines around the current position, this is
                        added only to the "other" side, unless there's
                        emptyness at both sides. (Else, you could just use
                        plain p|/|P.)

["x]gBp, ["x]gBP        Paste as a minimal fitting (not rectangular) block
                        with a jagged right edge; i.e. the lines
                        "foobar\nhi\n" will be pasted as 6-character "foobar"
                        in the current line and 2-character "hi" in the
                        following one.
                        With [count], each line's content is pasted [count]
                        times.
                        When pasting with gBp at the end of the line,
                        appends at the jagged end of following lines.
                        When pasting with gBP on the first non-indent
                        character (after column 1) of a line, prepends after
                        existing indent of following lines.

["x]gqbp, ["x]gqbP      Query for a separator string, then paste as a minimal
                        fitting (not rectangular) block (like gBp) with that
                        separator around each line (similar to gqp),
                        omitting the separator at the start and end of the
                        line or when there's already one at that side, like
                        with gsp.
                        With [count], each line's content is pasted [count]
                        times, with the separator between each.
                        When pasting with gqbp at the end of the line,
                        appends (with separator) at the jagged end of
                        following lines.
                        When pasting with gqbP on the first non-indent
                        character (after column 1) of a line, prepends (with
                        separator) after existing indent of following lines.

["x]gQBp, ["x]gQBP      Paste blockwise with the previously queried (gqbp)
                        separator string.

["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.

["x]gup, ["x]guP        Query for a separator pattern, un-join the register
                        contents, then paste linewise.

["x]gUp, ["x]gUP        Un-join the register contents on the previously
                        queried (gup) separator pattern, then paste
                        linewise.

["x]gpp, ["x]gpP        Paste with the first decimal number found on or after
                        the current cursor column (or the overall first
                        number, if no such match, or the last number, if the
                        cursor is at the end of the line) incremented /
                        decremented by 1.
                        Do this [count] times, with each paste further
                        incremented / decremented.

["x]gPp, ["x]gPP        Paste with all decimal numbers incremented /
                        decremented by 1.
                        Do this [count] times, with each paste further
                        incremented / decremented.

CTRL-R CTRL-C {0-9a-z"%#*+/:.-}
                        Insert the contents of a register characterwise
                        (newline characters and indent are flattened to
                        spaces).
                        If you have options like 'textwidth', 'formatoptions',
                        or 'autoindent' set, this will influence what will be
                        inserted.
                        Note: If the command-line mapping aborts
                        the command line, try defining
                            :cnoremap <C-c> <C-c>
                       or redefine the mapping.
CTRL-R , {0-9a-z"%#*+/:.-}
                        Insert the contents of a register characterwise, with
                        each line delimited by ", " instead of the newline
                        (and indent).
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. Like gqp, but in insert mode.

CTRL-R CTRL-Q CTRL-Q {0-9a-z"%#*+/:.-}
                        Insert the contents of a register characterwise, with
                        each line delimited by the previously queried (gqp,
                        i_CTRL-R_CTRL-Q) separator string.
CTRL-R CTRL-U {0-9a-z"%#*+/:.-}
                        Query for a separator pattern, un-join the contents of
                        a register, then insert it linewise.

CTRL-R CTRL-U CTRL-U {0-9a-z"%#*+/:.-}
                        Un-join the contents of
                        a register on the previously queried (gup,
                        i_CTRL_R_CTRL-U) pattern, then insert it linewise.
Something went wrong with that request. Please try again.