How to clear the line number in Vim when copying?
If you have line numbers, I'm quite sure you are not using Vim's yank/put operations (these will never copy the linenumbers, foldcolumn, icons etc) because in terms of the edit buffer, they don't exist.
My guess is you are working in a terminal emulator and using the mouse to copy stuff to the clipboard, which possibly selects the 'extraneous' room of the screen (including virtual spaces at the end, line numbers, fold markers etc)
You might have luck setting
:se mouse+=a
in order to get the behaviour of the mouse like you expect it. Otherwise, do the selection with V<movement>...
y (y
for yank
, which corresponds to 'copy')
Then on the destination use p (put at cursor), or P (put before cursor)
Let me know if that helped or you need more info
Vim copying the line numbers?
:set nonumber
copy what you want
:set number
:help number
How to take off line numbers in Vi?
If you are talking about show line number command in vi/vim
you could use
set nu
in commandline mode to turn on and
set nonu
will turn off the line number display or
set nu!
to toggle off display of line numbers
how to copy by specifying line numbers in vi
:364,757y
should work just fine, but it is probably more common to just do something like364GV757Gy
, allowing the range to be interactively modified when you realize that you really means line 759 or so.
Vim how to copy to a real (no relative) line number
- Move to line 247,
- set a mark, e.g.
a
, viama
- move to line 127
- yank from there to the mark
y'a
All in all: 247ggma127ggy'a
How to copy from current position to the end of line in vi
The normal-mode command to move to the end of the line is $
.
You can copy to the end of the line with y$
and paste with p
.
To copy/paste between different instances, you can use the system clipboard by selecting the *
register, so the commands become "*y$
for copying and "*p
for pasting.
$
move-to-linebreak
$
y$
yank-to-linebreak
y,$
"*y$
select clipboard-register yank-to-linebreak
",*,y,$
"*p
select clipboard-register paste
",*,p
Check :h registers
for more information.
Vim: Can you delete a specific line number from another line?
The address of a colon-command (eg: the line number) comes first.
:89d
Note that this will also cause you to navigate to the location of the change. You can use ``
to jump back.
If you'd prefer to have this be a single command you can define a custom command. eg:
command! -range -nargs=0 Delete <line1>,<line2>d|norm ``
This defines a command called Delete
that deletes the addressed range (<line1>,<line2>d
) and then navigates back (norm ``
).
You can call it like:
:89Delete
You can actually invoke it with any unique prefix, so you may be able to get it down to:
:89D
How to delete (not cut) in Vim?
Use the "black hole register", "_
to really delete something: "_d
.
Use "_dP
to paste something and keep it available for further pasting.
For the second question, you could use <C-o>dw
. <C-o>
is used to execute a normal command without leaving the insert mode.
You can setup your own mappings to save typing, of course. I have these:
nnoremap <leader>d "_d
xnoremap <leader>d "_d
xnoremap <leader>p "_dP
Copy all the lines to clipboard
You should yank the text to the *
or +
registers:
gg"*yG
Explanation:
gg
to get the cursor to the first character of the file"*y
to start a yank command to the register*
from the first line, until...G
to go the end of the file
Related Topics
Bash: Difference Between "Export K=1" VS. "K=1"
How to Check If Hadoop Daemons Are Running
Possible to Use a .Dll on Linux
How to Sleep for 1 Second Between Each Xargs Command
View a Particular Line of a File Denoted by a Number
Linux Command to Empty All Files of a Directory
Arch Linux - Apt-Get Update Equivalent Command
How to Recursively Copy a Directory into Another and Replace Only the Files That Have Not Changed
Link a Static Library to a Shared One During Build
Define Alias That References Other Aliases
How to Make Debian Package Install Dependencies
How to Fix Permission Denied for .Git/ Directory When Performing Git Push
How to Convert String to Number in Gnuplot
How to Write Linux Driver Module Call/Use Another Driver Module
Selecting the Right Linux I/O Scheduler for a Host Equipped with Nvme Ssd