Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [cut-copy-paste]

Questions about cutting, copying, and pasting text. In Vim, "cut" is also called "delete", "copy" is also called "yank", and "paste" is also called "put".

-1
votes
1answer
54 views

How to copy and paste arguments into function parenthesis?

I constantly need to copy existing variable names or expressions as arguments for my current typing function: // int TyrionLannister; int JonSnow; ... int AryaStark; ... // int DaenerysTargaryen;...
1
vote
0answers
15 views

paste doesn't work in visual mode with `clipboard+=unnamed`

I am running VIM 8.1 with MacVim on MacOS. If I set clipboard+=unnamed, then when I click p in visual mode, it simply copies the currently selected text into "* and "+. If I remove this and restart ...
5
votes
2answers
104 views

WORD movement across lines

Consider the following text snippet: value1, value2 Now, if the cursor is at (1,1) (the 'v' of value1), W takes me to (2,5) (the 'v' of value2) which is as expected. But if I do dW at the same ...
0
votes
2answers
36 views

How omit text between and including matching characters?

If I have a text containing markdown matching markings e.g. "Strikethrough uses two tildes. ~~Scratch this.~~" What would be a good way to delete all those occurrences such as - in this example - "~...
0
votes
1answer
44 views

How to copy up to the cursor without including the charater under the cursor

Like you would in virtually any application editing text. For example: this is a big sentence so I can explain ^ ^ start of selection my cursor is here I'd like to ...
0
votes
0answers
17 views

Cannot seem to copy paste - using gg > yG [duplicate]

Screen attached of two terminal windows: I would like to copy the 3 lines on the left and drop them into the window on the right. Tried gg to go to the top then yG. I get a message '3 lines yanked' ...
1
vote
1answer
47 views

Paste mode sometimes inserting “<Paste>”

Sometimes when I paste (via cmd+v) some text into neovim, it inserts <Paste> at the bottom, i.e: This was pasted and I got some bonus letters <Paste> I can't figure where this text comes ...
0
votes
0answers
61 views

Blockwise pasting from "+ register not working

UPDATE: I run an X server (XQuartz 2.7.11) on MacOS, which I forward via ssh to any Linux machine I use. The problem seems to be that under XQuartz, the "+ register does not support blockwise yanking/...
1
vote
2answers
75 views

Can I define something in .vimrc to speed up pasting of large amounts of data?

Occasionally, I paste large amounts of data into vim, using Ctrl+v in my terminal emulator (in Linux). This takes several seconds before vim is responsive again. I have tried two other methods, which ...
1
vote
0answers
27 views

Cursor position after pasting

I believe the default behaviour in vi(m) for pasting (p) or (P) was to leave the cursor at the current position as before pasting, and in order to paste a register and have the cursor be at the end of ...
0
votes
1answer
23 views

How do I delete the end-of-line to the right of my cursor?

Say I have the following text open in vi: Lorem Ipsum is simply dummy text [CURSOR] of the printing and ... The cursor position is denoted by [CURSOR] How can I delete the end-of-line that follows ...
6
votes
1answer
565 views

Repeat last yank

I'm appending text to "a" register with:"AyW. If I wanted to repeat last change I would use:. But in this case I would like to repeat the last yank command. Is there a command to repeat the last yank (...
1
vote
1answer
52 views

Vim: Replace visual selection without overwriting the unnamed register

How do I replace a visual selection with some register content without overwriting the unnamed ("") register by the visual selection? The question https://stackoverflow.com/questions/3837772/vim-...
1
vote
0answers
25 views

Update OS enviroment variables from inside VIM

I use vim inside tmux over an ssh session and I often run into the issue where the $DISPLAY variable gets changed, screwing up my copy-paste. When I log in, $DISPLAY gets assigned to something new: ...
0
votes
1answer
39 views

Copy and paste with breakindent set

I'm using breakindent to make long lines wraparound to the same indentation level as the start of the line. Unfortunately, with this setting on system copy and paste (in this case, out of the macOS ...
0
votes
2answers
28 views

How to yank a specified amount of lines in vim -E mode?

This is my first-post and question here so please be gentle (but also tell me if, it I wasn't specific enough etc...) So my questions seems rather simple to me, but still blocks me and I can't find ...
1
vote
1answer
32 views

Paste not working

File: 1111 2222 3333 4444 If I yyP on 2222, the system clipboard is pasted in, not 2222 as expected. However, :reg shows that 2222 was saved to register 0 and ". I expected it to save to th If I ...
1
vote
1answer
43 views

p (paste) but keep cursor same column

yyp pastes the current line underneath itself and moves the cursor to the start of the new line. If I start with my cursor on X: Ysiml yuipXedicious after yyp I get Ysiml yuipXedicious Ysiml ...
3
votes
2answers
117 views

Why can't I paste commands into vi?

I've been using vi for 40 years. A week ago I upgraded; Disaster struck! The upgrade was to VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Mar 4 2018 23:38:28) I run this on xterm under Cygwin (...
1
vote
1answer
46 views

How to delete Chinese characters in Lisp code (solved)

EDIT. Cause of problem has been found: the problem only appears when Tamas Kovacs' Paredit plugin is enabled. I have a lisp file containing comments and strings written using Chinese chracters. The ...
2
votes
4answers
138 views

How can I overwrite a whole file with the content of another?

I have two tabs open, file1.txt and file2.txt, each with different content. How can I copy the whole content of file1.txt and overwrite file2.txt with it, resulting in both files having the same ...
0
votes
1answer
31 views

Unable to copy line with .co

Since dot (.) is the range indicator for the current line I was expecting :.co to copy the current line, but it does not do this. What am I doing wrong? In contrast :.w my_line.txt will write the ...
3
votes
1answer
65 views

Is there a text object or motion for non-comment lines are not separated from comment lines by blank lines? E.g., in git commit messages

Consider the text A B # C # D Is there a text object or motion that will select lines A and B if the cursor is on either, but not select lines C and D? ap or ip with the cursor on any of those four ...
1
vote
4answers
81 views

How do I remove first 2 characters of each even numbered line?

Suppose, I have abcd efgh ijkl mnop qrst I want to delete the first 2 character of each even numbered line. abcd gh ijkl op qrst
1
vote
1answer
99 views

How to disable bad indentation when pasting text?

I am using vim and simply want to disable auto indent when I paste text into my terminal vim session. I have tried numerous solutions including various incantations of below to ~/.vimrc: set nopaste ...
1
vote
3answers
169 views

Paste in normal mode ignores autoindent

When I paste something within normal mode, vim ignores autoindent. I copy and paste with y and p. As mentioned autoindent is on. It works fine when I manually indent or type something before pasting. ...
1
vote
1answer
28 views

Pasting from register to command line inserts ^M instead of new line

Say I want to search for multiple lines (or do anything with them in the command line). I yank some lines and enter search mode (/). I press Ctrl + r" to paste what I just yanked, but I get ^M for ...
0
votes
1answer
67 views

IPython %cpaste command freezes in Terminal mode

I try to use IPython's %cpaste to paste the clipboard content (Python code) to my Terminal which is launched via Neovim's terminal mode. However, if I paste long lines of code, it freezes, and does ...
0
votes
1answer
102 views

How to use a value stored in a variable in the command mode?

Consider the following function function! AbbreviationsOpen() "go to the first word of the last line normal G "store the word in the register named a let @a = expand('<cword>') ...
1
vote
1answer
70 views

Copy-Paste C# style function with attributes

I have the following function: [Test] public void Some_Unit_Test_Function() { // some setup-test-assert code ... // end of code } What's the 'vim' way of copying the entire function (...
5
votes
4answers
558 views

How to copy text with syntax highlighting?

Want a simple way, like notepad++ plugin: NppExport - Export to RTF, to copy selected text with syntax highlighting. Notepad++, NppExport, Export to RTF example: Select text Copy RTF Paste ...
1
vote
1answer
73 views

Vim: remember last two items highlighted, with toggle

In vim, when highlighting and replacing individual words, I use: viwy Then, I go to the next word and type: viwp The default behavior is to immediately replace the yanked word with the replaced ...
-1
votes
2answers
63 views

Is visual model selection really faster than using mouse? [closed]

I don't mean to start an argument here. I am just trying to find the faster way. I have my monitor rotated 90 degrees, i.e., vertically. So when i code I can see more lines I found that using ...
4
votes
1answer
78 views

Why does VIM not copy the entire text inside the backticks in `\\sfdas\lsdfjla\` if I use `yi``

If I have a line say `\\sfdas\lsdfjla\` and I try to select the text inside the backtics using yi`, I expect that the entire text inside the backtics should be selected. However, it seems that in ...
2
votes
1answer
205 views

copy line XX and paste it below my cursor (avy / ace jump style)

I am wondering what the way of copying a line and pasting it below my cursor in vi/vim might be? Current workflow (copy line 21 and paste it below cursor): 21ggyy''p Is there something shorter like: ...
1
vote
1answer
235 views

disable clipboard: how to set clipboard option to Black hole register?

In some editing senario, I want to do a series of deleting, and do not want to clutter with the system clipboard, which I use an external program to management the history of it. The question is, ...
0
votes
0answers
214 views

Disable paste mode entirely

I get what paste mode does for you, but I have never found it particularly useful. I would like to completely deactivate it. I don't see an option to do so when looking at :help paste. However, I ...
0
votes
1answer
37 views

Better way to copy paste previous word using vim's default keyboard sequences?

Recently I have been documenting a lot of code which are usually in markdown files (.md). And I frequently come across texts where I have to retype previously written word. Like, cp file_1 file_2 mv -...
1
vote
1answer
63 views

Wrapping lines in a paragraph with header and footer lines

Say I have a paragraph like this line1 line2 line3 I want to select all and then transform like this :start line1 :end :start line2 :end :start line3 :end Don't ask me why, we have some strange ...
1
vote
2answers
68 views

How to remove a line and paste it at the beginning of a range

How to remove a line and paste it at the beginning of a range? line 1 line 2 line 3 line 4 xxxxxxxx For example, here I want to remove the 5th line and paste it before the first two lines, to change ...
0
votes
1answer
46 views

How to copy content in + register from local vim to remote vim in good format?

vim1 is my local vim.vim2 is the remote vim. ssh root@remote_ip vim #it is vim2 Now some content in my vim1's + register. curl -X POST https://content.dropboxapi.com/2/files/upload \ --...
0
votes
1answer
33 views

Delete from the next character till EOL

My problem Consider the following line: I have just pasted @SrvrlessDaysTLVtlv before tlv@serverlessdays.io, and I'd like to delete anything from the small-case t till EOL. What have I tried d$ ...
3
votes
1answer
285 views

Vim, tmux, and xterm-bracketed-paste

From Terminal.app on my Mac, I SSH in to a box where I run Vim 8.0.1601. Left at that, everything works fine. But if I launch Vim from within a tmux window, go to insert mode, and then attempt to ...
1
vote
3answers
137 views

Is there any way to copy a entire function without indicating line number?

I have a file.c containing #inlcude<stdio.h> int main() { printf("Hello world\n"); } I can copy the main function using :3,6y. But, when the function is big enough then in order to ...
0
votes
1answer
117 views

Cut a regex matching line and paste it at another line

I am trying to edit a json file, and I need to take out the lines starting and ending with {% and %} respectively and move them to the beginning of the file. I need to do it at different places in a ...
1
vote
1answer
100 views

Copying lines in visual mode only lets me paste 2 lines

I don't really know a better way to describe this, but copying multiple lines in Visual Mode flat out doesn't work. I hit V, highlight the lines, hit y, and then it will tell me "31 lines yanked" (or ...
0
votes
1answer
287 views

Copying to clipboard with clipboard=unnamed set

In the ~/.vimrc the clipboard has been enabled: set clipboard=unnamed But after hitting v for Visual and then hitting y (yank) then escape there is no contents in the clipboard. https://www....
1
vote
2answers
130 views

How to select/delete/yank the contents of only the current fold?

When using foldmethod=marker, how do you select or reference exactly the contents of the current fold? I want to swap the order of two folds. If they were paragraphs, I would do dap { p. However, I ...
0
votes
1answer
314 views

How to yank word from all selected lines in visual mode?

In the middle of a line, Press v and select multiple lines. How to yank the word at current cursor from all selected lines and add spaces if the word is shorter than the longest one to make copied ...
0
votes
1answer
221 views

How to yank string before a special character?

Example line: ^ some_string : other_string $. How to yank some_string before : without the spaces|tabs?