Copy text from one tmux pane to another (using vim)
up vote
100
down vote
favorite
I have two files opened in vim, each in one tmux pane. I would like to copy let's say 10 lines from one file to another.
How can I accomplish this not using the mouse's Copy
-> Paste
?
vim tmux copy-paste
add a comment |
up vote
100
down vote
favorite
I have two files opened in vim, each in one tmux pane. I would like to copy let's say 10 lines from one file to another.
How can I accomplish this not using the mouse's Copy
-> Paste
?
vim tmux copy-paste
1
You could involve tmux, but there are generally simpler ways. Are both the Vim instances on the same (local?) machine? Usually, I would just use a temporary file for that (i.e. visually select the lines,:w /tmp/lines
, then:r /tmp/lines
in the other instance). Or, if your Vim knows how to talk to your system clipboard, you could use the+
or*
registers to avoid the temporary file.
– Chris Johnsen
Dec 19 '12 at 5:39
add a comment |
up vote
100
down vote
favorite
up vote
100
down vote
favorite
I have two files opened in vim, each in one tmux pane. I would like to copy let's say 10 lines from one file to another.
How can I accomplish this not using the mouse's Copy
-> Paste
?
vim tmux copy-paste
I have two files opened in vim, each in one tmux pane. I would like to copy let's say 10 lines from one file to another.
How can I accomplish this not using the mouse's Copy
-> Paste
?
vim tmux copy-paste
vim tmux copy-paste
asked Dec 18 '12 at 11:06
Patryk
3,525114052
3,525114052
1
You could involve tmux, but there are generally simpler ways. Are both the Vim instances on the same (local?) machine? Usually, I would just use a temporary file for that (i.e. visually select the lines,:w /tmp/lines
, then:r /tmp/lines
in the other instance). Or, if your Vim knows how to talk to your system clipboard, you could use the+
or*
registers to avoid the temporary file.
– Chris Johnsen
Dec 19 '12 at 5:39
add a comment |
1
You could involve tmux, but there are generally simpler ways. Are both the Vim instances on the same (local?) machine? Usually, I would just use a temporary file for that (i.e. visually select the lines,:w /tmp/lines
, then:r /tmp/lines
in the other instance). Or, if your Vim knows how to talk to your system clipboard, you could use the+
or*
registers to avoid the temporary file.
– Chris Johnsen
Dec 19 '12 at 5:39
1
1
You could involve tmux, but there are generally simpler ways. Are both the Vim instances on the same (local?) machine? Usually, I would just use a temporary file for that (i.e. visually select the lines,
:w /tmp/lines
, then :r /tmp/lines
in the other instance). Or, if your Vim knows how to talk to your system clipboard, you could use the +
or *
registers to avoid the temporary file.– Chris Johnsen
Dec 19 '12 at 5:39
You could involve tmux, but there are generally simpler ways. Are both the Vim instances on the same (local?) machine? Usually, I would just use a temporary file for that (i.e. visually select the lines,
:w /tmp/lines
, then :r /tmp/lines
in the other instance). Or, if your Vim knows how to talk to your system clipboard, you could use the +
or *
registers to avoid the temporary file.– Chris Johnsen
Dec 19 '12 at 5:39
add a comment |
7 Answers
7
active
oldest
votes
up vote
151
down vote
accepted
You'll have to use tmux shortcuts. Assuming your tmux command shortcut is the default: Ctrl+b, then:
Ctrl+b, [ Enter copy(?) mode.
Move to start/end of text to highlight.
Ctrlspace
Start highlighting text (on Arch Linux). When I've compiled tmux from source on OSX and other Linux's, just Space on its own usually works. Selected text changes the colours, so you'll know if the command worked.
Move to opposite end of text to copy.
Alt+w Copies selected text into tmux clipboard. (On Mac use Esc+w.)
Move cursor to opposite tmux pane, or completely different tmux window. Put the cursor where you want to paste the text you just copied.
Ctrl+b, ] Paste copied text from tmux clipboard.
tmux is quite good at mapping commands to custom keyboard shortcuts.
See Ctrl+b,? for the full list of set keyboard shortcuts.
2
Thanks. Just a sidenode: The Alt + w did not work on Mac. Alt was mapped to Esc by default. Hence it is Esc+w.
– Karan
Mar 22 '16 at 7:58
10
if you usescreen
shortcuts:Ctrl + A [
(enter copy-mode),Space
(start highlighting),Enter
(end highlighting),Ctrl + A ]
(paste).
– jfs
Aug 2 '16 at 9:58
6
Worth noting that "enter" works for me whereas alt+w does not.
– Elijah Lynn
Nov 29 '17 at 1:02
2
As noted in awhan.wordpress.com/2010/06/20/copy-paste-in-tmux, if you have vi key bindings, step 5 should be replaced withEnter
key.
– Ying Xiong
Dec 4 '17 at 13:04
2
what If I need to copy and paste to a text editor? For some reason it doesn't seem to pick up that selected text even after pressing 'enter' after selecting the text.
– uday
Dec 5 '17 at 20:38
|
show 7 more comments
up vote
28
down vote
Unfortunately, I can't add a comment yet to Alex Leach's answer so I'm going to include an addendum here for Mac OS X users:
Enter Copies the selected text
1
thanks! I am on Ubuntu Xenial, usingbyobu
/tmux
with all default settings, this worked, Alt + w did not.
– Andrea Zonca
Mar 21 '16 at 18:16
This doesn't work on OS X Yosemite with tmux 2.0, nor does alt+w, nor does esc+w :(
– weberc2
Apr 6 '16 at 15:59
Works for me too on Windows using a Zoc terminal.
– jdhao
Oct 22 at 9:24
add a comment |
up vote
8
down vote
If you are using vim and tmux on macOS (Tested on macOS 10.12.2, tmux 2.3):
(Assume that prefix key combination of tmux is prefix. The prefix is ctrl + b in defaults.)
- Copy:
- Press prefix + [ to enter copy mode.
- Use arrow keys to go to the start/end of text selection.
- Press ctrl + space (If you have set ctrl + space as prefix, Press ctrl + space + space instead)
- Use arrow keys to move to the other side of selection.
- Press ctrl + w.
- Paste:
- Press prefix + ] in insert mode.
add a comment |
up vote
1
down vote
You could use the system clip board with "*y and "*p instead of the normal y and p.
1
To use system clipboard you have to use"+2yy
– copy two lines to X11 clipboard"+dd
– cut line to X11 clipboard"+p
– paste X11 clipboard
– Patryk
Jan 9 '13 at 12:59
Do I need to type anything before using these commands?
– Thomas Ahle
Mar 9 at 12:46
@ThomasAhle, no.. its literally the double quotes ("), followed by plus (+) followed by 2ys (y). Make sure you are in normal mode. If you are in normal mode, you should be able to useh,j,k,l
to move . I have also seen sometimes on my ubuntu VM, the "+" register vanishes, for unknown reason. To verify that you have the+
register, you can type:reg
and check whether there is string"+
in the first column.
– alpha_989
Apr 12 at 15:05
add a comment |
up vote
1
down vote
If you have vim
open, its better to use the vim copy paste to copy text.
Tmux copy paste will work, however there are several disadvantages.
First, when copying multiple lines of text, you will have to select multiple lines. Tmux copy paste typically doesnt understand that vim
has line numbers or there are markings in the vim gutter (such as relative numbers/absolute numbers). As a result, it will copy those as well.
Secondly, I have found that if the text has certain language specific formatting, and you directly try to copy paste using tmux to vim, it will mess up the formatting. This can be avoided by using set paste!
. However, this requires a lot more work.
Use "+y
to copy and "+p
to paste
Vim
natively provides a method to copy paste between the vim buffer and the system clipboard, using either "+y
or "*y
. Then pasting using "+p
or "*p
. This will avoide copying the relative numbers in the gutter or other random marks which are not relevant to vim
add a comment |
up vote
1
down vote
I am connecting to my CentOS server on a Windows machine using ZOC terminal ssh client. Here is what works for me:
- Enter copy mode:
<prefix>
+[
- Start copy:
<Space>
- Copy text:
<Enter>
- Paste text:
<prefix>
+]
add a comment |
up vote
0
down vote
A couple of options for vim use since the tmux shortcut sequence is bit long and I find it hard to remember
Like the answers above said you can use "+y
and "*y
to copy and then "+p
and "*p
respectively to paste. If you want vim to use the clipboard by default so you can just use y/p
directly then.
set clipboard=unamed "sets the default copy register to be *
set clipboard=unamedplus "sets the default copy register to be +
source for clipboard command: https://vi.stackexchange.com/questions/84/how-can-i-copy-text-to-the-system-clipboard-from-vim
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
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',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2funix.stackexchange.com%2fquestions%2f58763%2fcopy-text-from-one-tmux-pane-to-another-using-vim%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
7 Answers
7
active
oldest
votes
7 Answers
7
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
151
down vote
accepted
You'll have to use tmux shortcuts. Assuming your tmux command shortcut is the default: Ctrl+b, then:
Ctrl+b, [ Enter copy(?) mode.
Move to start/end of text to highlight.
Ctrlspace
Start highlighting text (on Arch Linux). When I've compiled tmux from source on OSX and other Linux's, just Space on its own usually works. Selected text changes the colours, so you'll know if the command worked.
Move to opposite end of text to copy.
Alt+w Copies selected text into tmux clipboard. (On Mac use Esc+w.)
Move cursor to opposite tmux pane, or completely different tmux window. Put the cursor where you want to paste the text you just copied.
Ctrl+b, ] Paste copied text from tmux clipboard.
tmux is quite good at mapping commands to custom keyboard shortcuts.
See Ctrl+b,? for the full list of set keyboard shortcuts.
2
Thanks. Just a sidenode: The Alt + w did not work on Mac. Alt was mapped to Esc by default. Hence it is Esc+w.
– Karan
Mar 22 '16 at 7:58
10
if you usescreen
shortcuts:Ctrl + A [
(enter copy-mode),Space
(start highlighting),Enter
(end highlighting),Ctrl + A ]
(paste).
– jfs
Aug 2 '16 at 9:58
6
Worth noting that "enter" works for me whereas alt+w does not.
– Elijah Lynn
Nov 29 '17 at 1:02
2
As noted in awhan.wordpress.com/2010/06/20/copy-paste-in-tmux, if you have vi key bindings, step 5 should be replaced withEnter
key.
– Ying Xiong
Dec 4 '17 at 13:04
2
what If I need to copy and paste to a text editor? For some reason it doesn't seem to pick up that selected text even after pressing 'enter' after selecting the text.
– uday
Dec 5 '17 at 20:38
|
show 7 more comments
up vote
151
down vote
accepted
You'll have to use tmux shortcuts. Assuming your tmux command shortcut is the default: Ctrl+b, then:
Ctrl+b, [ Enter copy(?) mode.
Move to start/end of text to highlight.
Ctrlspace
Start highlighting text (on Arch Linux). When I've compiled tmux from source on OSX and other Linux's, just Space on its own usually works. Selected text changes the colours, so you'll know if the command worked.
Move to opposite end of text to copy.
Alt+w Copies selected text into tmux clipboard. (On Mac use Esc+w.)
Move cursor to opposite tmux pane, or completely different tmux window. Put the cursor where you want to paste the text you just copied.
Ctrl+b, ] Paste copied text from tmux clipboard.
tmux is quite good at mapping commands to custom keyboard shortcuts.
See Ctrl+b,? for the full list of set keyboard shortcuts.
2
Thanks. Just a sidenode: The Alt + w did not work on Mac. Alt was mapped to Esc by default. Hence it is Esc+w.
– Karan
Mar 22 '16 at 7:58
10
if you usescreen
shortcuts:Ctrl + A [
(enter copy-mode),Space
(start highlighting),Enter
(end highlighting),Ctrl + A ]
(paste).
– jfs
Aug 2 '16 at 9:58
6
Worth noting that "enter" works for me whereas alt+w does not.
– Elijah Lynn
Nov 29 '17 at 1:02
2
As noted in awhan.wordpress.com/2010/06/20/copy-paste-in-tmux, if you have vi key bindings, step 5 should be replaced withEnter
key.
– Ying Xiong
Dec 4 '17 at 13:04
2
what If I need to copy and paste to a text editor? For some reason it doesn't seem to pick up that selected text even after pressing 'enter' after selecting the text.
– uday
Dec 5 '17 at 20:38
|
show 7 more comments
up vote
151
down vote
accepted
up vote
151
down vote
accepted
You'll have to use tmux shortcuts. Assuming your tmux command shortcut is the default: Ctrl+b, then:
Ctrl+b, [ Enter copy(?) mode.
Move to start/end of text to highlight.
Ctrlspace
Start highlighting text (on Arch Linux). When I've compiled tmux from source on OSX and other Linux's, just Space on its own usually works. Selected text changes the colours, so you'll know if the command worked.
Move to opposite end of text to copy.
Alt+w Copies selected text into tmux clipboard. (On Mac use Esc+w.)
Move cursor to opposite tmux pane, or completely different tmux window. Put the cursor where you want to paste the text you just copied.
Ctrl+b, ] Paste copied text from tmux clipboard.
tmux is quite good at mapping commands to custom keyboard shortcuts.
See Ctrl+b,? for the full list of set keyboard shortcuts.
You'll have to use tmux shortcuts. Assuming your tmux command shortcut is the default: Ctrl+b, then:
Ctrl+b, [ Enter copy(?) mode.
Move to start/end of text to highlight.
Ctrlspace
Start highlighting text (on Arch Linux). When I've compiled tmux from source on OSX and other Linux's, just Space on its own usually works. Selected text changes the colours, so you'll know if the command worked.
Move to opposite end of text to copy.
Alt+w Copies selected text into tmux clipboard. (On Mac use Esc+w.)
Move cursor to opposite tmux pane, or completely different tmux window. Put the cursor where you want to paste the text you just copied.
Ctrl+b, ] Paste copied text from tmux clipboard.
tmux is quite good at mapping commands to custom keyboard shortcuts.
See Ctrl+b,? for the full list of set keyboard shortcuts.
edited Nov 15 '17 at 14:27
RubberDuck
1034
1034
answered Dec 18 '12 at 11:37
Alex Leach
4,10242326
4,10242326
2
Thanks. Just a sidenode: The Alt + w did not work on Mac. Alt was mapped to Esc by default. Hence it is Esc+w.
– Karan
Mar 22 '16 at 7:58
10
if you usescreen
shortcuts:Ctrl + A [
(enter copy-mode),Space
(start highlighting),Enter
(end highlighting),Ctrl + A ]
(paste).
– jfs
Aug 2 '16 at 9:58
6
Worth noting that "enter" works for me whereas alt+w does not.
– Elijah Lynn
Nov 29 '17 at 1:02
2
As noted in awhan.wordpress.com/2010/06/20/copy-paste-in-tmux, if you have vi key bindings, step 5 should be replaced withEnter
key.
– Ying Xiong
Dec 4 '17 at 13:04
2
what If I need to copy and paste to a text editor? For some reason it doesn't seem to pick up that selected text even after pressing 'enter' after selecting the text.
– uday
Dec 5 '17 at 20:38
|
show 7 more comments
2
Thanks. Just a sidenode: The Alt + w did not work on Mac. Alt was mapped to Esc by default. Hence it is Esc+w.
– Karan
Mar 22 '16 at 7:58
10
if you usescreen
shortcuts:Ctrl + A [
(enter copy-mode),Space
(start highlighting),Enter
(end highlighting),Ctrl + A ]
(paste).
– jfs
Aug 2 '16 at 9:58
6
Worth noting that "enter" works for me whereas alt+w does not.
– Elijah Lynn
Nov 29 '17 at 1:02
2
As noted in awhan.wordpress.com/2010/06/20/copy-paste-in-tmux, if you have vi key bindings, step 5 should be replaced withEnter
key.
– Ying Xiong
Dec 4 '17 at 13:04
2
what If I need to copy and paste to a text editor? For some reason it doesn't seem to pick up that selected text even after pressing 'enter' after selecting the text.
– uday
Dec 5 '17 at 20:38
2
2
Thanks. Just a sidenode: The Alt + w did not work on Mac. Alt was mapped to Esc by default. Hence it is Esc+w.
– Karan
Mar 22 '16 at 7:58
Thanks. Just a sidenode: The Alt + w did not work on Mac. Alt was mapped to Esc by default. Hence it is Esc+w.
– Karan
Mar 22 '16 at 7:58
10
10
if you use
screen
shortcuts: Ctrl + A [
(enter copy-mode), Space
(start highlighting), Enter
(end highlighting), Ctrl + A ]
(paste).– jfs
Aug 2 '16 at 9:58
if you use
screen
shortcuts: Ctrl + A [
(enter copy-mode), Space
(start highlighting), Enter
(end highlighting), Ctrl + A ]
(paste).– jfs
Aug 2 '16 at 9:58
6
6
Worth noting that "enter" works for me whereas alt+w does not.
– Elijah Lynn
Nov 29 '17 at 1:02
Worth noting that "enter" works for me whereas alt+w does not.
– Elijah Lynn
Nov 29 '17 at 1:02
2
2
As noted in awhan.wordpress.com/2010/06/20/copy-paste-in-tmux, if you have vi key bindings, step 5 should be replaced with
Enter
key.– Ying Xiong
Dec 4 '17 at 13:04
As noted in awhan.wordpress.com/2010/06/20/copy-paste-in-tmux, if you have vi key bindings, step 5 should be replaced with
Enter
key.– Ying Xiong
Dec 4 '17 at 13:04
2
2
what If I need to copy and paste to a text editor? For some reason it doesn't seem to pick up that selected text even after pressing 'enter' after selecting the text.
– uday
Dec 5 '17 at 20:38
what If I need to copy and paste to a text editor? For some reason it doesn't seem to pick up that selected text even after pressing 'enter' after selecting the text.
– uday
Dec 5 '17 at 20:38
|
show 7 more comments
up vote
28
down vote
Unfortunately, I can't add a comment yet to Alex Leach's answer so I'm going to include an addendum here for Mac OS X users:
Enter Copies the selected text
1
thanks! I am on Ubuntu Xenial, usingbyobu
/tmux
with all default settings, this worked, Alt + w did not.
– Andrea Zonca
Mar 21 '16 at 18:16
This doesn't work on OS X Yosemite with tmux 2.0, nor does alt+w, nor does esc+w :(
– weberc2
Apr 6 '16 at 15:59
Works for me too on Windows using a Zoc terminal.
– jdhao
Oct 22 at 9:24
add a comment |
up vote
28
down vote
Unfortunately, I can't add a comment yet to Alex Leach's answer so I'm going to include an addendum here for Mac OS X users:
Enter Copies the selected text
1
thanks! I am on Ubuntu Xenial, usingbyobu
/tmux
with all default settings, this worked, Alt + w did not.
– Andrea Zonca
Mar 21 '16 at 18:16
This doesn't work on OS X Yosemite with tmux 2.0, nor does alt+w, nor does esc+w :(
– weberc2
Apr 6 '16 at 15:59
Works for me too on Windows using a Zoc terminal.
– jdhao
Oct 22 at 9:24
add a comment |
up vote
28
down vote
up vote
28
down vote
Unfortunately, I can't add a comment yet to Alex Leach's answer so I'm going to include an addendum here for Mac OS X users:
Enter Copies the selected text
Unfortunately, I can't add a comment yet to Alex Leach's answer so I'm going to include an addendum here for Mac OS X users:
Enter Copies the selected text
answered Jul 29 '15 at 16:37
Mieczysław Daniel Dyba
38132
38132
1
thanks! I am on Ubuntu Xenial, usingbyobu
/tmux
with all default settings, this worked, Alt + w did not.
– Andrea Zonca
Mar 21 '16 at 18:16
This doesn't work on OS X Yosemite with tmux 2.0, nor does alt+w, nor does esc+w :(
– weberc2
Apr 6 '16 at 15:59
Works for me too on Windows using a Zoc terminal.
– jdhao
Oct 22 at 9:24
add a comment |
1
thanks! I am on Ubuntu Xenial, usingbyobu
/tmux
with all default settings, this worked, Alt + w did not.
– Andrea Zonca
Mar 21 '16 at 18:16
This doesn't work on OS X Yosemite with tmux 2.0, nor does alt+w, nor does esc+w :(
– weberc2
Apr 6 '16 at 15:59
Works for me too on Windows using a Zoc terminal.
– jdhao
Oct 22 at 9:24
1
1
thanks! I am on Ubuntu Xenial, using
byobu
/tmux
with all default settings, this worked, Alt + w did not.– Andrea Zonca
Mar 21 '16 at 18:16
thanks! I am on Ubuntu Xenial, using
byobu
/tmux
with all default settings, this worked, Alt + w did not.– Andrea Zonca
Mar 21 '16 at 18:16
This doesn't work on OS X Yosemite with tmux 2.0, nor does alt+w, nor does esc+w :(
– weberc2
Apr 6 '16 at 15:59
This doesn't work on OS X Yosemite with tmux 2.0, nor does alt+w, nor does esc+w :(
– weberc2
Apr 6 '16 at 15:59
Works for me too on Windows using a Zoc terminal.
– jdhao
Oct 22 at 9:24
Works for me too on Windows using a Zoc terminal.
– jdhao
Oct 22 at 9:24
add a comment |
up vote
8
down vote
If you are using vim and tmux on macOS (Tested on macOS 10.12.2, tmux 2.3):
(Assume that prefix key combination of tmux is prefix. The prefix is ctrl + b in defaults.)
- Copy:
- Press prefix + [ to enter copy mode.
- Use arrow keys to go to the start/end of text selection.
- Press ctrl + space (If you have set ctrl + space as prefix, Press ctrl + space + space instead)
- Use arrow keys to move to the other side of selection.
- Press ctrl + w.
- Paste:
- Press prefix + ] in insert mode.
add a comment |
up vote
8
down vote
If you are using vim and tmux on macOS (Tested on macOS 10.12.2, tmux 2.3):
(Assume that prefix key combination of tmux is prefix. The prefix is ctrl + b in defaults.)
- Copy:
- Press prefix + [ to enter copy mode.
- Use arrow keys to go to the start/end of text selection.
- Press ctrl + space (If you have set ctrl + space as prefix, Press ctrl + space + space instead)
- Use arrow keys to move to the other side of selection.
- Press ctrl + w.
- Paste:
- Press prefix + ] in insert mode.
add a comment |
up vote
8
down vote
up vote
8
down vote
If you are using vim and tmux on macOS (Tested on macOS 10.12.2, tmux 2.3):
(Assume that prefix key combination of tmux is prefix. The prefix is ctrl + b in defaults.)
- Copy:
- Press prefix + [ to enter copy mode.
- Use arrow keys to go to the start/end of text selection.
- Press ctrl + space (If you have set ctrl + space as prefix, Press ctrl + space + space instead)
- Use arrow keys to move to the other side of selection.
- Press ctrl + w.
- Paste:
- Press prefix + ] in insert mode.
If you are using vim and tmux on macOS (Tested on macOS 10.12.2, tmux 2.3):
(Assume that prefix key combination of tmux is prefix. The prefix is ctrl + b in defaults.)
- Copy:
- Press prefix + [ to enter copy mode.
- Use arrow keys to go to the start/end of text selection.
- Press ctrl + space (If you have set ctrl + space as prefix, Press ctrl + space + space instead)
- Use arrow keys to move to the other side of selection.
- Press ctrl + w.
- Paste:
- Press prefix + ] in insert mode.
answered Dec 28 '16 at 15:37
Hamid Rohani
18115
18115
add a comment |
add a comment |
up vote
1
down vote
You could use the system clip board with "*y and "*p instead of the normal y and p.
1
To use system clipboard you have to use"+2yy
– copy two lines to X11 clipboard"+dd
– cut line to X11 clipboard"+p
– paste X11 clipboard
– Patryk
Jan 9 '13 at 12:59
Do I need to type anything before using these commands?
– Thomas Ahle
Mar 9 at 12:46
@ThomasAhle, no.. its literally the double quotes ("), followed by plus (+) followed by 2ys (y). Make sure you are in normal mode. If you are in normal mode, you should be able to useh,j,k,l
to move . I have also seen sometimes on my ubuntu VM, the "+" register vanishes, for unknown reason. To verify that you have the+
register, you can type:reg
and check whether there is string"+
in the first column.
– alpha_989
Apr 12 at 15:05
add a comment |
up vote
1
down vote
You could use the system clip board with "*y and "*p instead of the normal y and p.
1
To use system clipboard you have to use"+2yy
– copy two lines to X11 clipboard"+dd
– cut line to X11 clipboard"+p
– paste X11 clipboard
– Patryk
Jan 9 '13 at 12:59
Do I need to type anything before using these commands?
– Thomas Ahle
Mar 9 at 12:46
@ThomasAhle, no.. its literally the double quotes ("), followed by plus (+) followed by 2ys (y). Make sure you are in normal mode. If you are in normal mode, you should be able to useh,j,k,l
to move . I have also seen sometimes on my ubuntu VM, the "+" register vanishes, for unknown reason. To verify that you have the+
register, you can type:reg
and check whether there is string"+
in the first column.
– alpha_989
Apr 12 at 15:05
add a comment |
up vote
1
down vote
up vote
1
down vote
You could use the system clip board with "*y and "*p instead of the normal y and p.
You could use the system clip board with "*y and "*p instead of the normal y and p.
answered Dec 20 '12 at 6:17
Johan
3,20411728
3,20411728
1
To use system clipboard you have to use"+2yy
– copy two lines to X11 clipboard"+dd
– cut line to X11 clipboard"+p
– paste X11 clipboard
– Patryk
Jan 9 '13 at 12:59
Do I need to type anything before using these commands?
– Thomas Ahle
Mar 9 at 12:46
@ThomasAhle, no.. its literally the double quotes ("), followed by plus (+) followed by 2ys (y). Make sure you are in normal mode. If you are in normal mode, you should be able to useh,j,k,l
to move . I have also seen sometimes on my ubuntu VM, the "+" register vanishes, for unknown reason. To verify that you have the+
register, you can type:reg
and check whether there is string"+
in the first column.
– alpha_989
Apr 12 at 15:05
add a comment |
1
To use system clipboard you have to use"+2yy
– copy two lines to X11 clipboard"+dd
– cut line to X11 clipboard"+p
– paste X11 clipboard
– Patryk
Jan 9 '13 at 12:59
Do I need to type anything before using these commands?
– Thomas Ahle
Mar 9 at 12:46
@ThomasAhle, no.. its literally the double quotes ("), followed by plus (+) followed by 2ys (y). Make sure you are in normal mode. If you are in normal mode, you should be able to useh,j,k,l
to move . I have also seen sometimes on my ubuntu VM, the "+" register vanishes, for unknown reason. To verify that you have the+
register, you can type:reg
and check whether there is string"+
in the first column.
– alpha_989
Apr 12 at 15:05
1
1
To use system clipboard you have to use
"+2yy
– copy two lines to X11 clipboard "+dd
– cut line to X11 clipboard "+p
– paste X11 clipboard– Patryk
Jan 9 '13 at 12:59
To use system clipboard you have to use
"+2yy
– copy two lines to X11 clipboard "+dd
– cut line to X11 clipboard "+p
– paste X11 clipboard– Patryk
Jan 9 '13 at 12:59
Do I need to type anything before using these commands?
– Thomas Ahle
Mar 9 at 12:46
Do I need to type anything before using these commands?
– Thomas Ahle
Mar 9 at 12:46
@ThomasAhle, no.. its literally the double quotes ("), followed by plus (+) followed by 2ys (y). Make sure you are in normal mode. If you are in normal mode, you should be able to use
h,j,k,l
to move . I have also seen sometimes on my ubuntu VM, the "+" register vanishes, for unknown reason. To verify that you have the +
register, you can type :reg
and check whether there is string "+
in the first column.– alpha_989
Apr 12 at 15:05
@ThomasAhle, no.. its literally the double quotes ("), followed by plus (+) followed by 2ys (y). Make sure you are in normal mode. If you are in normal mode, you should be able to use
h,j,k,l
to move . I have also seen sometimes on my ubuntu VM, the "+" register vanishes, for unknown reason. To verify that you have the +
register, you can type :reg
and check whether there is string "+
in the first column.– alpha_989
Apr 12 at 15:05
add a comment |
up vote
1
down vote
If you have vim
open, its better to use the vim copy paste to copy text.
Tmux copy paste will work, however there are several disadvantages.
First, when copying multiple lines of text, you will have to select multiple lines. Tmux copy paste typically doesnt understand that vim
has line numbers or there are markings in the vim gutter (such as relative numbers/absolute numbers). As a result, it will copy those as well.
Secondly, I have found that if the text has certain language specific formatting, and you directly try to copy paste using tmux to vim, it will mess up the formatting. This can be avoided by using set paste!
. However, this requires a lot more work.
Use "+y
to copy and "+p
to paste
Vim
natively provides a method to copy paste between the vim buffer and the system clipboard, using either "+y
or "*y
. Then pasting using "+p
or "*p
. This will avoide copying the relative numbers in the gutter or other random marks which are not relevant to vim
add a comment |
up vote
1
down vote
If you have vim
open, its better to use the vim copy paste to copy text.
Tmux copy paste will work, however there are several disadvantages.
First, when copying multiple lines of text, you will have to select multiple lines. Tmux copy paste typically doesnt understand that vim
has line numbers or there are markings in the vim gutter (such as relative numbers/absolute numbers). As a result, it will copy those as well.
Secondly, I have found that if the text has certain language specific formatting, and you directly try to copy paste using tmux to vim, it will mess up the formatting. This can be avoided by using set paste!
. However, this requires a lot more work.
Use "+y
to copy and "+p
to paste
Vim
natively provides a method to copy paste between the vim buffer and the system clipboard, using either "+y
or "*y
. Then pasting using "+p
or "*p
. This will avoide copying the relative numbers in the gutter or other random marks which are not relevant to vim
add a comment |
up vote
1
down vote
up vote
1
down vote
If you have vim
open, its better to use the vim copy paste to copy text.
Tmux copy paste will work, however there are several disadvantages.
First, when copying multiple lines of text, you will have to select multiple lines. Tmux copy paste typically doesnt understand that vim
has line numbers or there are markings in the vim gutter (such as relative numbers/absolute numbers). As a result, it will copy those as well.
Secondly, I have found that if the text has certain language specific formatting, and you directly try to copy paste using tmux to vim, it will mess up the formatting. This can be avoided by using set paste!
. However, this requires a lot more work.
Use "+y
to copy and "+p
to paste
Vim
natively provides a method to copy paste between the vim buffer and the system clipboard, using either "+y
or "*y
. Then pasting using "+p
or "*p
. This will avoide copying the relative numbers in the gutter or other random marks which are not relevant to vim
If you have vim
open, its better to use the vim copy paste to copy text.
Tmux copy paste will work, however there are several disadvantages.
First, when copying multiple lines of text, you will have to select multiple lines. Tmux copy paste typically doesnt understand that vim
has line numbers or there are markings in the vim gutter (such as relative numbers/absolute numbers). As a result, it will copy those as well.
Secondly, I have found that if the text has certain language specific formatting, and you directly try to copy paste using tmux to vim, it will mess up the formatting. This can be avoided by using set paste!
. However, this requires a lot more work.
Use "+y
to copy and "+p
to paste
Vim
natively provides a method to copy paste between the vim buffer and the system clipboard, using either "+y
or "*y
. Then pasting using "+p
or "*p
. This will avoide copying the relative numbers in the gutter or other random marks which are not relevant to vim
answered Apr 12 at 15:13
alpha_989
1735
1735
add a comment |
add a comment |
up vote
1
down vote
I am connecting to my CentOS server on a Windows machine using ZOC terminal ssh client. Here is what works for me:
- Enter copy mode:
<prefix>
+[
- Start copy:
<Space>
- Copy text:
<Enter>
- Paste text:
<prefix>
+]
add a comment |
up vote
1
down vote
I am connecting to my CentOS server on a Windows machine using ZOC terminal ssh client. Here is what works for me:
- Enter copy mode:
<prefix>
+[
- Start copy:
<Space>
- Copy text:
<Enter>
- Paste text:
<prefix>
+]
add a comment |
up vote
1
down vote
up vote
1
down vote
I am connecting to my CentOS server on a Windows machine using ZOC terminal ssh client. Here is what works for me:
- Enter copy mode:
<prefix>
+[
- Start copy:
<Space>
- Copy text:
<Enter>
- Paste text:
<prefix>
+]
I am connecting to my CentOS server on a Windows machine using ZOC terminal ssh client. Here is what works for me:
- Enter copy mode:
<prefix>
+[
- Start copy:
<Space>
- Copy text:
<Enter>
- Paste text:
<prefix>
+]
answered Oct 22 at 9:29
jdhao
1619
1619
add a comment |
add a comment |
up vote
0
down vote
A couple of options for vim use since the tmux shortcut sequence is bit long and I find it hard to remember
Like the answers above said you can use "+y
and "*y
to copy and then "+p
and "*p
respectively to paste. If you want vim to use the clipboard by default so you can just use y/p
directly then.
set clipboard=unamed "sets the default copy register to be *
set clipboard=unamedplus "sets the default copy register to be +
source for clipboard command: https://vi.stackexchange.com/questions/84/how-can-i-copy-text-to-the-system-clipboard-from-vim
add a comment |
up vote
0
down vote
A couple of options for vim use since the tmux shortcut sequence is bit long and I find it hard to remember
Like the answers above said you can use "+y
and "*y
to copy and then "+p
and "*p
respectively to paste. If you want vim to use the clipboard by default so you can just use y/p
directly then.
set clipboard=unamed "sets the default copy register to be *
set clipboard=unamedplus "sets the default copy register to be +
source for clipboard command: https://vi.stackexchange.com/questions/84/how-can-i-copy-text-to-the-system-clipboard-from-vim
add a comment |
up vote
0
down vote
up vote
0
down vote
A couple of options for vim use since the tmux shortcut sequence is bit long and I find it hard to remember
Like the answers above said you can use "+y
and "*y
to copy and then "+p
and "*p
respectively to paste. If you want vim to use the clipboard by default so you can just use y/p
directly then.
set clipboard=unamed "sets the default copy register to be *
set clipboard=unamedplus "sets the default copy register to be +
source for clipboard command: https://vi.stackexchange.com/questions/84/how-can-i-copy-text-to-the-system-clipboard-from-vim
A couple of options for vim use since the tmux shortcut sequence is bit long and I find it hard to remember
Like the answers above said you can use "+y
and "*y
to copy and then "+p
and "*p
respectively to paste. If you want vim to use the clipboard by default so you can just use y/p
directly then.
set clipboard=unamed "sets the default copy register to be *
set clipboard=unamedplus "sets the default copy register to be +
source for clipboard command: https://vi.stackexchange.com/questions/84/how-can-i-copy-text-to-the-system-clipboard-from-vim
answered Dec 2 at 3:40
Avi Areman
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- 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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2funix.stackexchange.com%2fquestions%2f58763%2fcopy-text-from-one-tmux-pane-to-another-using-vim%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
1
You could involve tmux, but there are generally simpler ways. Are both the Vim instances on the same (local?) machine? Usually, I would just use a temporary file for that (i.e. visually select the lines,
:w /tmp/lines
, then:r /tmp/lines
in the other instance). Or, if your Vim knows how to talk to your system clipboard, you could use the+
or*
registers to avoid the temporary file.– Chris Johnsen
Dec 19 '12 at 5:39