Stack Exchange Network

Stack Exchange network consists of 174 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".

0
votes
1answer
24 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 ...
1
vote
1answer
47 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
78 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
0
votes
0answers
32 views

yank to register a no but x ok

Why I can't yank a word to register a? Is there something special to it? I'm able to yank a word to register x by doing: "xyiw I'm checking register contents with :reg Same behavior if I vim -u ...
1
vote
1answer
49 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
84 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
22 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
25 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
33 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
37 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
2answers
166 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
60 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
57 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
46 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
173 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
61 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
87 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
32 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
62 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
65 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
41 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
32 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$ ...
2
votes
1answer
169 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
89 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 this using :2,5y. But, when the function is big enough then to know the end line of the ...
0
votes
1answer
58 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
82 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
93 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....
0
votes
0answers
19 views

Yanks/deletes (even 'large ones') not saving/shifting through numbered registers

Running Vim snapshot 73 on Mac El Capitan. This problem happens whether I use my normal setup (with .vimrc etc) or even if I run as vim -u NONE or vim -i NONE When I yank or cut a piece of text (...
1
vote
2answers
59 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
164 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
104 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?
0
votes
1answer
21 views

Yank-in-word with indentation: Get/set buffer position, manipulate yank buffer

I am trying to write a command that yanks the whitespace (indentation) at the start of a line as well as yanking some other object. I have several ideas of how this could be done. Consider the ...
1
vote
1answer
56 views

Execute selection and redirect output to new buffer/tab

I want to automate something I started using. Short story is I have a file with some lines and I want to execute each line every now and then and see its' output, but I don't want it to override the ...
1
vote
1answer
33 views

Map key to paste and immediately select

I know I can select pasted text using this trick mapped to gp. That means if I paste and then want to select the pasted block, I need to say p and gp. I want to paste and immediately select that, ...
1
vote
2answers
108 views

Don't yank character with <DEL> key in normal mode

I am using NeoVim with Tmux on an Ubuntu on Windows setup. I have bound neovim's clipboard to the system clipboard by using : set clipboard+=unnamedplus and further configuration inside tmux. So far, ...
3
votes
1answer
55 views

How does vim know if register contents were from a linewise selection when pasting?

I haven't been able to find documentation on how vim knows if register contents came from a linewise-selection vs characterwise or blockwise selection. For example, given the text below: Hello there ...
7
votes
3answers
275 views

Paste link to image in clipboard when editing Markdown

I have an image on the clipboard and I want to paste it into my document as the text [](img/image1.png). Instead of first copying it to that directory, I want to do it with a single p key press in ...
0
votes
0answers
31 views

problem with copying and pasting with vim vsplit [duplicate]

background I usually split my screen in vim (using vsplit) and sometimes I show the menu tree etc.. Problem suppose I have 3 panels open (two vsplit windows and a tree browser).. when I want to ...
4
votes
2answers
73 views

Paste word on new line with indentation from current line

Using ]p in normal mode, I can paste a yanked line of text on a new line below the cursor with indentation equal to the current line. Using the :put command, I can paste a yanked word as if it were a ...
3
votes
1answer
231 views

Vim pasting yank register when opening a new file

For a few weeks, I have the strangest issue, on a single computer. On this computer, when I open a file with Vim, the yank register have a low chance of being pasted on the current position of the ...
3
votes
1answer
99 views

Is possible in vim to delete a line after a word or character?

I have this file name ... line1 name ... line 2 name ... line 3 etc I want to delete lines after the "..." sequence ,and preserve the others: is possible? The result will be name ... name ... ...
1
vote
2answers
207 views

The meaning of "= in Vim

I was solving a problem on Vimgolf (you can take a look at this) where I stumbled upon this solution. djgJ.V"=[<C-R><C-A>]<CR>pZZ Could you please walk me through the meaning of ...
0
votes
1answer
59 views

Vim yank and paste via a shared file [duplicate]

I posted this question on StackOverflow first, as I did not know about "Vi and Vim beta". How to augment Vim yank and paste, so when I yank, Vim writes the content to a file? When I paste, it uses ...
3
votes
2answers
79 views

Yank part of another line based on pattern

Im trying to yank part of another line: 1 foo=bar 2 3 (paste only foo here - without "going/moving" to 1) I understand that I can yank the whole line using :1y. A "pseudocode" for that would be :...
0
votes
1answer
72 views

Copy a substring in line to the front of the line

I have a list of file names I'm trying to create insert statements out of. In each file name is the ID I need for the primary key, that I just need to copy from inside the file name to the front of ...
0
votes
0answers
25 views

How to issue command "+p? [duplicate]

In multiple places I saw that in order to paste from clipboard I need to execute command "+p. I tried pressing " then + and then p but I am not getting the desired result. I also tried pressing them ...
0
votes
1answer
67 views

Select several lines untill a specific symbol

I have the next lines of text in a file: eslint.vim flow.vim jscs.vim jshint.vim standard.vim xo.vim How can I yank names (without '.vim' part)? Even better would be to format it to look like this: ...
1
vote
3answers
125 views

Copy a line, comment it and replace a word in copied line

Libraries evolve all the time and I often face the situation where after an update some function name have changed and they return errors in the updated version of the library. It's easy to replace ...
1
vote
1answer
214 views

Paste without messing up indentation in insert mode

I use Ctrl-R to paste in vim when I am in insert mode, but this , more often than, not messes up the inentation and I have to indent it manually or use =. All this makes Ctrl-R same as going to normal ...
0
votes
2answers
60 views

Strangely slow key bindings

I defined these maps, to yank into system clipboard. noremap <leader>y "*y noremap <leader>Y "*Y noremap <leader>yy "*yy But when I use the first one (<leader>y), I find it ...