Friday, October 2, 2009

Insert contents from clipboard into Vim


# This usually works in insert mode
SHIFT + INSERT

# However sometimes my "CTRL + c" on other application doesn't get contents into Vim's "clipboard".
# The solution is to use Vim's multiline insert mode

:i or :in or :insert

# This will bring up lines which you can paste from Ubuntu's clipboard by "CTRL + SHIFT + v" to you heart's content.
# Finish the multilines with a "." at the end
# NOTE: better to turn off Vim's "autoindent" with "!"

:in!

This is first line
This is 2nd line
This is last line
.

# A similar method would be append instead of insert

:a, :append

No comments:

Blog Archive