Quickest way to paste block of text into Vi Editor from external source
For instance, copying a conf section from a web page then pasting it into a .conf file that you have open in Vi.
linux text-editor vi
add a comment |
For instance, copying a conf section from a web page then pasting it into a .conf file that you have open in Vi.
linux text-editor vi
add a comment |
For instance, copying a conf section from a web page then pasting it into a .conf file that you have open in Vi.
linux text-editor vi
For instance, copying a conf section from a web page then pasting it into a .conf file that you have open in Vi.
linux text-editor vi
linux text-editor vi
edited Aug 4 '12 at 9:58
Tshepang
6,1201772113
6,1201772113
asked Dec 9 '10 at 19:24
asfsadfasfsadf
1,61652639
1,61652639
add a comment |
add a comment |
10 Answers
10
active
oldest
votes
Or if you use the system register, you can paste without being in insert mode:
"*p
This will paste the system's clipboard at the point of the cursor. No insert mode needed.
2
This won't work over SSH, though (it'll paste from the clipboard of the system you've SSHed into, not your system).
– Kat
Oct 23 '14 at 7:34
this did NOT look like it would work..
– Poat
Nov 9 '18 at 20:41
add a comment |
- Enter insert mode (Type i)
- Type: ctrl-shift-v
This works with Raspberry Pi. The "*p only pasted from vim's most recent register.
– rball
May 11 '16 at 4:41
add a comment |
One thing to bear in mind, sometimes Vim auto-indents text. This is mostly fine, but sometimes it messes up text that you paste into a document.
If your indentations are awry remove the pasted text, type :set paste
, paste the text in again, and when you're done type :set nopaste
.
add a comment |
The real answer:
:set paste
Enter Insert Mode: hit i
Paste: Command + v or Control + v
ESC
:set nopaste
There's a step missing: after step 3, press Esc to exit Insert Mode.
– boot13
Aug 27 '17 at 13:33
1
@boot13 thanks, fixed that
– Arian Faurtosh
Nov 13 '18 at 23:06
add a comment |
The easiest way is just to copy the text and just right clic where you want to paste it in VIM in INSERT Mode.
add a comment |
If you are using gvim, hit CTRL-R then either * or + in insert mode. It will paste last copied text.
add a comment |
Ctrl-V/ Apple-V? Just make sure you're in insert mode in vi (i)
1
Doesn't always work because of the auto indentation (and seems to be other issues -- auto quoting or something). If I paste a large block into my.vimrc
while in insert mode, I end up with a huge amount of indentation and random comments added.
– Kat
Oct 23 '14 at 7:35
add a comment |
You're systems paste shortcut key while in Insert mode or if your source is another file, you can type :r and it will be pasted at the current location of your cursor.
add a comment |
Easiest way on *nix is by selecting it with the mouse and pasting it in vim with a middle click, after having put vi in Insert mode.
Middle click could be a both left-right key if you're using a touchpad
add a comment |
The quickest way is to paste it using whatever paste key your system uses (e.g. ⌘-v for macs, Ctrl-V for windows, etc.) in insert mode. Some terminals require you to use Shift-Ctrl-V. However you are able to paste onto the command-line is how you should paste into vim. However, this can cause some problems with indentation, which is where :set paste
comes in. The fastest way to get in and out of this is to set a pastetoggle (see :help pastetoggle
). For example, I use
set pastetoggle=<leader>p
The reason to use a pastetoggle instead of a mapping is because if you set a mapping insert mode will read it literally when in paste mode. Thus if you :set paste
, go into insert mode, and type in any imap
the mapping will not be completed but instead the literal characters will be inserted. With pastetoggle
you can get around that since it's a builtin feature.
As others have said if you're in insert mode you can also use <C-r>*
, but why? Your normal pasting flow is most likely better. Understanding the *
register and <C-r>
is an important skill however. You can read more about them at :help registers
and :help i_CTRL-R
. You could also use "*p
but if you're faster at typing that then your normal paste I'm impressed. Of course you could map that to something else, but again... why? You should get used to quickly getting into insert mode with i, I, a, A, o, O, s, S, c, and C
so that you can be precise.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f4402198%2fquickest-way-to-paste-block-of-text-into-vi-editor-from-external-source%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
10 Answers
10
active
oldest
votes
10 Answers
10
active
oldest
votes
active
oldest
votes
active
oldest
votes
Or if you use the system register, you can paste without being in insert mode:
"*p
This will paste the system's clipboard at the point of the cursor. No insert mode needed.
2
This won't work over SSH, though (it'll paste from the clipboard of the system you've SSHed into, not your system).
– Kat
Oct 23 '14 at 7:34
this did NOT look like it would work..
– Poat
Nov 9 '18 at 20:41
add a comment |
Or if you use the system register, you can paste without being in insert mode:
"*p
This will paste the system's clipboard at the point of the cursor. No insert mode needed.
2
This won't work over SSH, though (it'll paste from the clipboard of the system you've SSHed into, not your system).
– Kat
Oct 23 '14 at 7:34
this did NOT look like it would work..
– Poat
Nov 9 '18 at 20:41
add a comment |
Or if you use the system register, you can paste without being in insert mode:
"*p
This will paste the system's clipboard at the point of the cursor. No insert mode needed.
Or if you use the system register, you can paste without being in insert mode:
"*p
This will paste the system's clipboard at the point of the cursor. No insert mode needed.
edited Apr 24 '17 at 15:03
Riker
219617
219617
answered Dec 9 '10 at 21:21
Jordan ParmerJordan Parmer
20.4k2086112
20.4k2086112
2
This won't work over SSH, though (it'll paste from the clipboard of the system you've SSHed into, not your system).
– Kat
Oct 23 '14 at 7:34
this did NOT look like it would work..
– Poat
Nov 9 '18 at 20:41
add a comment |
2
This won't work over SSH, though (it'll paste from the clipboard of the system you've SSHed into, not your system).
– Kat
Oct 23 '14 at 7:34
this did NOT look like it would work..
– Poat
Nov 9 '18 at 20:41
2
2
This won't work over SSH, though (it'll paste from the clipboard of the system you've SSHed into, not your system).
– Kat
Oct 23 '14 at 7:34
This won't work over SSH, though (it'll paste from the clipboard of the system you've SSHed into, not your system).
– Kat
Oct 23 '14 at 7:34
this did NOT look like it would work..
– Poat
Nov 9 '18 at 20:41
this did NOT look like it would work..
– Poat
Nov 9 '18 at 20:41
add a comment |
- Enter insert mode (Type i)
- Type: ctrl-shift-v
This works with Raspberry Pi. The "*p only pasted from vim's most recent register.
– rball
May 11 '16 at 4:41
add a comment |
- Enter insert mode (Type i)
- Type: ctrl-shift-v
This works with Raspberry Pi. The "*p only pasted from vim's most recent register.
– rball
May 11 '16 at 4:41
add a comment |
- Enter insert mode (Type i)
- Type: ctrl-shift-v
- Enter insert mode (Type i)
- Type: ctrl-shift-v
answered Aug 16 '13 at 12:34
RationalPiRationalPi
16113
16113
This works with Raspberry Pi. The "*p only pasted from vim's most recent register.
– rball
May 11 '16 at 4:41
add a comment |
This works with Raspberry Pi. The "*p only pasted from vim's most recent register.
– rball
May 11 '16 at 4:41
This works with Raspberry Pi. The "*p only pasted from vim's most recent register.
– rball
May 11 '16 at 4:41
This works with Raspberry Pi. The "*p only pasted from vim's most recent register.
– rball
May 11 '16 at 4:41
add a comment |
One thing to bear in mind, sometimes Vim auto-indents text. This is mostly fine, but sometimes it messes up text that you paste into a document.
If your indentations are awry remove the pasted text, type :set paste
, paste the text in again, and when you're done type :set nopaste
.
add a comment |
One thing to bear in mind, sometimes Vim auto-indents text. This is mostly fine, but sometimes it messes up text that you paste into a document.
If your indentations are awry remove the pasted text, type :set paste
, paste the text in again, and when you're done type :set nopaste
.
add a comment |
One thing to bear in mind, sometimes Vim auto-indents text. This is mostly fine, but sometimes it messes up text that you paste into a document.
If your indentations are awry remove the pasted text, type :set paste
, paste the text in again, and when you're done type :set nopaste
.
One thing to bear in mind, sometimes Vim auto-indents text. This is mostly fine, but sometimes it messes up text that you paste into a document.
If your indentations are awry remove the pasted text, type :set paste
, paste the text in again, and when you're done type :set nopaste
.
answered Dec 9 '10 at 21:40
mattmatt
1338
1338
add a comment |
add a comment |
The real answer:
:set paste
Enter Insert Mode: hit i
Paste: Command + v or Control + v
ESC
:set nopaste
There's a step missing: after step 3, press Esc to exit Insert Mode.
– boot13
Aug 27 '17 at 13:33
1
@boot13 thanks, fixed that
– Arian Faurtosh
Nov 13 '18 at 23:06
add a comment |
The real answer:
:set paste
Enter Insert Mode: hit i
Paste: Command + v or Control + v
ESC
:set nopaste
There's a step missing: after step 3, press Esc to exit Insert Mode.
– boot13
Aug 27 '17 at 13:33
1
@boot13 thanks, fixed that
– Arian Faurtosh
Nov 13 '18 at 23:06
add a comment |
The real answer:
:set paste
Enter Insert Mode: hit i
Paste: Command + v or Control + v
ESC
:set nopaste
The real answer:
:set paste
Enter Insert Mode: hit i
Paste: Command + v or Control + v
ESC
:set nopaste
edited Nov 13 '18 at 23:05
answered Nov 11 '15 at 7:12
Arian FaurtoshArian Faurtosh
8,692156192
8,692156192
There's a step missing: after step 3, press Esc to exit Insert Mode.
– boot13
Aug 27 '17 at 13:33
1
@boot13 thanks, fixed that
– Arian Faurtosh
Nov 13 '18 at 23:06
add a comment |
There's a step missing: after step 3, press Esc to exit Insert Mode.
– boot13
Aug 27 '17 at 13:33
1
@boot13 thanks, fixed that
– Arian Faurtosh
Nov 13 '18 at 23:06
There's a step missing: after step 3, press Esc to exit Insert Mode.
– boot13
Aug 27 '17 at 13:33
There's a step missing: after step 3, press Esc to exit Insert Mode.
– boot13
Aug 27 '17 at 13:33
1
1
@boot13 thanks, fixed that
– Arian Faurtosh
Nov 13 '18 at 23:06
@boot13 thanks, fixed that
– Arian Faurtosh
Nov 13 '18 at 23:06
add a comment |
The easiest way is just to copy the text and just right clic where you want to paste it in VIM in INSERT Mode.
add a comment |
The easiest way is just to copy the text and just right clic where you want to paste it in VIM in INSERT Mode.
add a comment |
The easiest way is just to copy the text and just right clic where you want to paste it in VIM in INSERT Mode.
The easiest way is just to copy the text and just right clic where you want to paste it in VIM in INSERT Mode.
answered Apr 28 '16 at 0:47
BarthBarth
211
211
add a comment |
add a comment |
If you are using gvim, hit CTRL-R then either * or + in insert mode. It will paste last copied text.
add a comment |
If you are using gvim, hit CTRL-R then either * or + in insert mode. It will paste last copied text.
add a comment |
If you are using gvim, hit CTRL-R then either * or + in insert mode. It will paste last copied text.
If you are using gvim, hit CTRL-R then either * or + in insert mode. It will paste last copied text.
answered Dec 9 '10 at 20:24
BenoitBenoit
59.1k15168212
59.1k15168212
add a comment |
add a comment |
Ctrl-V/ Apple-V? Just make sure you're in insert mode in vi (i)
1
Doesn't always work because of the auto indentation (and seems to be other issues -- auto quoting or something). If I paste a large block into my.vimrc
while in insert mode, I end up with a huge amount of indentation and random comments added.
– Kat
Oct 23 '14 at 7:35
add a comment |
Ctrl-V/ Apple-V? Just make sure you're in insert mode in vi (i)
1
Doesn't always work because of the auto indentation (and seems to be other issues -- auto quoting or something). If I paste a large block into my.vimrc
while in insert mode, I end up with a huge amount of indentation and random comments added.
– Kat
Oct 23 '14 at 7:35
add a comment |
Ctrl-V/ Apple-V? Just make sure you're in insert mode in vi (i)
Ctrl-V/ Apple-V? Just make sure you're in insert mode in vi (i)
answered Dec 9 '10 at 19:26
Tyler EavesTyler Eaves
8,65812537
8,65812537
1
Doesn't always work because of the auto indentation (and seems to be other issues -- auto quoting or something). If I paste a large block into my.vimrc
while in insert mode, I end up with a huge amount of indentation and random comments added.
– Kat
Oct 23 '14 at 7:35
add a comment |
1
Doesn't always work because of the auto indentation (and seems to be other issues -- auto quoting or something). If I paste a large block into my.vimrc
while in insert mode, I end up with a huge amount of indentation and random comments added.
– Kat
Oct 23 '14 at 7:35
1
1
Doesn't always work because of the auto indentation (and seems to be other issues -- auto quoting or something). If I paste a large block into my
.vimrc
while in insert mode, I end up with a huge amount of indentation and random comments added.– Kat
Oct 23 '14 at 7:35
Doesn't always work because of the auto indentation (and seems to be other issues -- auto quoting or something). If I paste a large block into my
.vimrc
while in insert mode, I end up with a huge amount of indentation and random comments added.– Kat
Oct 23 '14 at 7:35
add a comment |
You're systems paste shortcut key while in Insert mode or if your source is another file, you can type :r and it will be pasted at the current location of your cursor.
add a comment |
You're systems paste shortcut key while in Insert mode or if your source is another file, you can type :r and it will be pasted at the current location of your cursor.
add a comment |
You're systems paste shortcut key while in Insert mode or if your source is another file, you can type :r and it will be pasted at the current location of your cursor.
You're systems paste shortcut key while in Insert mode or if your source is another file, you can type :r and it will be pasted at the current location of your cursor.
answered Dec 9 '10 at 19:28
Ronnie HowellRonnie Howell
60938
60938
add a comment |
add a comment |
Easiest way on *nix is by selecting it with the mouse and pasting it in vim with a middle click, after having put vi in Insert mode.
Middle click could be a both left-right key if you're using a touchpad
add a comment |
Easiest way on *nix is by selecting it with the mouse and pasting it in vim with a middle click, after having put vi in Insert mode.
Middle click could be a both left-right key if you're using a touchpad
add a comment |
Easiest way on *nix is by selecting it with the mouse and pasting it in vim with a middle click, after having put vi in Insert mode.
Middle click could be a both left-right key if you're using a touchpad
Easiest way on *nix is by selecting it with the mouse and pasting it in vim with a middle click, after having put vi in Insert mode.
Middle click could be a both left-right key if you're using a touchpad
answered Dec 10 '10 at 9:38
MetiuMetiu
1,03211123
1,03211123
add a comment |
add a comment |
The quickest way is to paste it using whatever paste key your system uses (e.g. ⌘-v for macs, Ctrl-V for windows, etc.) in insert mode. Some terminals require you to use Shift-Ctrl-V. However you are able to paste onto the command-line is how you should paste into vim. However, this can cause some problems with indentation, which is where :set paste
comes in. The fastest way to get in and out of this is to set a pastetoggle (see :help pastetoggle
). For example, I use
set pastetoggle=<leader>p
The reason to use a pastetoggle instead of a mapping is because if you set a mapping insert mode will read it literally when in paste mode. Thus if you :set paste
, go into insert mode, and type in any imap
the mapping will not be completed but instead the literal characters will be inserted. With pastetoggle
you can get around that since it's a builtin feature.
As others have said if you're in insert mode you can also use <C-r>*
, but why? Your normal pasting flow is most likely better. Understanding the *
register and <C-r>
is an important skill however. You can read more about them at :help registers
and :help i_CTRL-R
. You could also use "*p
but if you're faster at typing that then your normal paste I'm impressed. Of course you could map that to something else, but again... why? You should get used to quickly getting into insert mode with i, I, a, A, o, O, s, S, c, and C
so that you can be precise.
add a comment |
The quickest way is to paste it using whatever paste key your system uses (e.g. ⌘-v for macs, Ctrl-V for windows, etc.) in insert mode. Some terminals require you to use Shift-Ctrl-V. However you are able to paste onto the command-line is how you should paste into vim. However, this can cause some problems with indentation, which is where :set paste
comes in. The fastest way to get in and out of this is to set a pastetoggle (see :help pastetoggle
). For example, I use
set pastetoggle=<leader>p
The reason to use a pastetoggle instead of a mapping is because if you set a mapping insert mode will read it literally when in paste mode. Thus if you :set paste
, go into insert mode, and type in any imap
the mapping will not be completed but instead the literal characters will be inserted. With pastetoggle
you can get around that since it's a builtin feature.
As others have said if you're in insert mode you can also use <C-r>*
, but why? Your normal pasting flow is most likely better. Understanding the *
register and <C-r>
is an important skill however. You can read more about them at :help registers
and :help i_CTRL-R
. You could also use "*p
but if you're faster at typing that then your normal paste I'm impressed. Of course you could map that to something else, but again... why? You should get used to quickly getting into insert mode with i, I, a, A, o, O, s, S, c, and C
so that you can be precise.
add a comment |
The quickest way is to paste it using whatever paste key your system uses (e.g. ⌘-v for macs, Ctrl-V for windows, etc.) in insert mode. Some terminals require you to use Shift-Ctrl-V. However you are able to paste onto the command-line is how you should paste into vim. However, this can cause some problems with indentation, which is where :set paste
comes in. The fastest way to get in and out of this is to set a pastetoggle (see :help pastetoggle
). For example, I use
set pastetoggle=<leader>p
The reason to use a pastetoggle instead of a mapping is because if you set a mapping insert mode will read it literally when in paste mode. Thus if you :set paste
, go into insert mode, and type in any imap
the mapping will not be completed but instead the literal characters will be inserted. With pastetoggle
you can get around that since it's a builtin feature.
As others have said if you're in insert mode you can also use <C-r>*
, but why? Your normal pasting flow is most likely better. Understanding the *
register and <C-r>
is an important skill however. You can read more about them at :help registers
and :help i_CTRL-R
. You could also use "*p
but if you're faster at typing that then your normal paste I'm impressed. Of course you could map that to something else, but again... why? You should get used to quickly getting into insert mode with i, I, a, A, o, O, s, S, c, and C
so that you can be precise.
The quickest way is to paste it using whatever paste key your system uses (e.g. ⌘-v for macs, Ctrl-V for windows, etc.) in insert mode. Some terminals require you to use Shift-Ctrl-V. However you are able to paste onto the command-line is how you should paste into vim. However, this can cause some problems with indentation, which is where :set paste
comes in. The fastest way to get in and out of this is to set a pastetoggle (see :help pastetoggle
). For example, I use
set pastetoggle=<leader>p
The reason to use a pastetoggle instead of a mapping is because if you set a mapping insert mode will read it literally when in paste mode. Thus if you :set paste
, go into insert mode, and type in any imap
the mapping will not be completed but instead the literal characters will be inserted. With pastetoggle
you can get around that since it's a builtin feature.
As others have said if you're in insert mode you can also use <C-r>*
, but why? Your normal pasting flow is most likely better. Understanding the *
register and <C-r>
is an important skill however. You can read more about them at :help registers
and :help i_CTRL-R
. You could also use "*p
but if you're faster at typing that then your normal paste I'm impressed. Of course you could map that to something else, but again... why? You should get used to quickly getting into insert mode with i, I, a, A, o, O, s, S, c, and C
so that you can be precise.
answered Aug 4 '12 at 15:34
ConnerConner
23.3k84568
23.3k84568
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f4402198%2fquickest-way-to-paste-block-of-text-into-vi-editor-from-external-source%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown