All Questions
Tagged with cut-copy-paste key-bindings
34 questions
0
votes
2
answers
597
views
How do I synchronize system clipboard and nvim clipboard?
I would like to synchronize the system and nvim clipboards so I don't have to do anything extra to copy and paste. I want to do (since I am on MacOS) command c to copy and command v to paste, inside ...
1
vote
4
answers
47
views
Rotate list of lines
Assume you have the following block of text (yes: I am using vim-latex, but this is not relevant):
\begin{itemize}
\item 1
% [[[
\item 2
\item 3
\item 4
\item 5
% ]]]
\item 6
\end{itemize}
My ...
1
vote
3
answers
87
views
Block select unequal lines
I often have code of the form:
money = double(123)
user_level = user["level"]
timer = get_time()
and want to have:
money = double(123)
user_level = user["level"...
2
votes
2
answers
207
views
How to replace till the end of the line without joining lines?
One of the main usage I have for selection is replacement.
Suppose I have:
Jane: Hello foo1 & bar1
John: Hello
Jane: Hello foo2 and bar2
John: Hello
Jane: Hello foo3 or bar3
John: Hello
That I ...
3
votes
2
answers
248
views
Vim yank from cursor position to end of nth line
I am trying to yank from my cursor posintion to end of nth line defined by a motion. So for the below text
Lorem ipsum dolor sit amet,
consectetur adipiscing elit.
Donec non quam et erat pharetra
...
1
vote
1
answer
55
views
Why doesn't the dot command work after pasting in visual mode?
1. Why doesn't this work?
If my text file is:
aaa
test bbbb test
test bbbb test
test bbbb test
I can yank aaa, select bbbb in visual mode, and type "0p, to replace it with aaa, with the idea of ...
0
votes
1
answer
211
views
Vim mapping: Copy whole line X lines up/down and paste it X lines down/up
I find myself doing the following very often: xkyyxjp (where x is a number).
I copy a whole line x lines up, and then I paste it x lines down (and vice versa); and so I wanted to make a map so I can ...
8
votes
1
answer
497
views
ci) - also delete the surrounding parens?
I use ci) and ci] quite a lot to change what happens in between the parens or brackets.
Is there a way to remove everything including the parens or brackets?
0
votes
2
answers
1k
views
How to replace text with clipboard content in VsCode using VsCodeVim?
I am using vscode + vim. Consider a common scenario where I have to yank/delete some text from one place and replace it with some text anywhere else. But as I need to replace I have to first delete ...
5
votes
1
answer
130
views
Yanking results displayed in status line
After pressing <C-g> in normal mode, prints useful information in the status line. How can I yank this text?
3
votes
1
answer
291
views
How to reserve a dd into a register, so I can yank it immediately even after a couple more dd's in between
dd puts the text I want to yank, in some register.
Before a yank, a couple more dd's, now the first dd register has changed.
How do I yank so that it's the first dd I want. I can't keep track of ...
0
votes
2
answers
892
views
"Copy" is greyed out in the Terminal menu after "Select All" in "VIM embedded in Terminal"; VIM copy does not work. How to copy the full file text?
I have set VIM as the default editor in the Terminal.
I changed the ~/.bashrc:
export VISUAL=vim
export EDITOR="$VISUAL"
You can also set the default editor only for git:
git config --...
2
votes
1
answer
439
views
better copy-paste multiple lines in visual mode where vim pastes after that visual chunk of code
I want to select multiple lines in vim,
copy them, and paste after that chunk of code (with cursor at the beginning).
yp doesn't work because in visual chunk of code,
vim pastes after the 1st line of ...
-1
votes
1
answer
82
views
mapping to delete and yank multiple lines e.g. d4y instead of d4d
In my vimrc I have
nnoremap d "_d
nnoremap yd dd
to not save lines when I delete.
Is it possible to create a mapping that when I press e.g. d4y it will cut 4 lines and save them into buffers?
I ...
1
vote
0
answers
167
views
How to bind <C-U> to <Cmd><BS> in vimrc?
I understand that <C-W> is backward-kill-word and I have bound this to shiftBS and it works.
But now I want to bind <C-U> to cmdBS. Is this possible? If so, how can I do this?
1
vote
1
answer
66
views
How to prevent cursor shift when using <C-O>{delete cmd} at the end of a line?
<C-w> deletes a (small-)word in insert mode, but I often want to delete the Word (to last whitespace) I've most recently typed. I tried
inoremap <C-_> <C-o>dB
which kind-of works -- ...
0
votes
1
answer
1k
views
How can I make Neovim actually delete something instead of copy?
I find very frustrating in Neovim and vim that when I delete a text to replace it, what actually happens is that it copies the last thing I deleted.
I've tried with this line in my init.vim:
vnoremap ...
1
vote
1
answer
630
views
Disable Shift+Insert from pasting from Primary
In Vim, the canonical methods to interact with X11's Clipboard and Primary is to use + and * registers.
There are at least another two ways to paste from Primary into Vim: Shift-Insert and Mouse ...
2
votes
6
answers
1k
views
How to delete a pair of parenthesis with backspace
I'm using vim to code C++ and I want to handle the parenthesis more easily.
I knew that there was a plugin named Surround, which can help us but it is not what I expected.
I set some shortcuts as ...
2
votes
1
answer
335
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
1
answer
952
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 ...
0
votes
2
answers
598
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 ...
2
votes
2
answers
2k
views
How to set up Crtl-v map that works in insert mode?
What is the best way of linking the Ctrl-V key combination to pasting the clipboard in insert mode?
I used
map <C-v> "+gP
imap <C-v> <C-r><C-p>+
in .vimrc. However in ...
2
votes
1
answer
402
views
Delete wrapped lines?
How to delete wrapped lines?
I imagined something like gdd and gD but they did not work as expected, in a similar fashion to gj and gk to move through wrapped lines.
It would be really useful to ...
0
votes
1
answer
417
views
Can't map to <C-Insert>
I'm trying to use ac to copy the whole contents to the system clipboard in gVim. Putting this in my .vimrc isn't working:
nnoremap <leader>ac ggvG$<C-Insert>
If I manually press ggvG$[...
6
votes
5
answers
923
views
truncate sentence: delete up to, but not including period
How can I set up a keybinding to delete up to the end of a sentence that ends with a period, but keep the period?
The commands df., d), and D all truncate the sentence but don't keep the period. ...
2
votes
1
answer
214
views
How can I define an operator that takes a register as an argument?
I'm trying to write a "Paste-over" operator. It will work like a combination of p and R, so it will paste the contents of a register over the text currently in the buffer. I have this so far:
...
3
votes
1
answer
1k
views
Cut and copy : Blackhole and default register assignment
I currently have something like this in my vimrc. The reason i have this is because I do not want items to be copied to the default register when I delete or change.
"Copy the contents of delete to ...
0
votes
2
answers
183
views
How to paste a line inside another line ? i.e. How to paste a line as words?
I would like to easily transform these two lines :
One line.
long line with many words in this example
into the line :
One long line with many words in this example line.
How I currently do ...
7
votes
4
answers
2k
views
Prevent the cursor from moving to the start of the yanked text?
Vim help's change.txt states that
Note that after a characterwise yank command, Vim leaves the cursor on the
first yanked character that is closest to the start of the buffer. This means
that "...
0
votes
1
answer
505
views
Issue with paste command remap in vim
I want to auto indent code on pasting and found this:
:nnoremap p p=`] --(not working)
but it was not working for me as the code still came out unindented.
So I used:
:nnoremap &...
43
votes
2
answers
10k
views
Why is Y a synonym for yy instead of y$?
Is there a specific historical reason for this?
Background — (you can skip this part if you already understand the question.)
As intermediate/advanced vi users will know, y is the "yank" command—it ...
142
votes
8
answers
214k
views
How can I easily move a line?
What is the command (or shortcut) to move a line up or down in vim? My current workflow is to yank (copy) the line and than delete that line and than to put (paste) that line.
21
votes
1
answer
3k
views
How can I map d[count]d?
N.B. This is not a duplicate of How does the "d3fg" command work? Please read it before voting to close!
I've come to a bit of an impasse in my quest to get small deletions work like big ...