Select text using keyboard in linux shell - linux

It is common to not use the mouse at all in a terminal, but it is not easy to find how to select text in a terminal just with the keyboard.
Once selected CTRL+SHIFT+C and CTRL+SHIFT+V can be used to copy and paste, but how to select text?

Highlighting with the mouse. *runs*

Just found this on net..
Open screen: screen
Run your program, producing output you want copied
Enter copy mode: ^A [
Move your cursor to the start point
Hit enter
Move your cursor to the end point
Hit enter
Paste: ^A ]
would that do ?

Related

Vim: Paste seems to be acting weird. Carrying out the keyboard shortcuts of characters that are copy pasted

My vim seems to be acting weird today.When I try to copy paste it is carrying out the vim keyboard shortcuts related to the characters I have copied and pasted. e.g. If i copy and paste two letter ks they will not paste but the cursor will jump up two lines. I think it has something to do with SHIFT+CTRL+V taking me out of insert mode and into normal mode. Then paste is putting the kk as input into normal mode.
How do I get back to the correct copy paste functionality/ stop making shift+ctrl+v exit insert mode? Thanks!
My cluster terminal went into bracketed paste mode while in vim somehow.
Typing reset into the terminal outside of vim fixed it.

How do I copy/cut text which I selected using shift+Arrow keys in Nano?

When I am trying to copy/cut in Nano command while using Shift and Arrow key to select the lines, its not working. But if I am selecting the lines with my mouse to copy/cut, its working.
Is it normal or I have to change any setting.
Thanks in advance.
Alt-A starts marking. Move the cursor to mark the text.
Alt-6 is copy
Move to the target location.
Ctrl-U is paste
The shortcuts are displayed at the bottom of the screen. :)

copy to clipboard with vim running in windows 10 cmd line window

I have a windows 10 PC.
The VIM session is run from a command prompt window.
Normally when I copy and paste, I do the following steps:
1. go into edit mode by typing ":"
2. select the text with mouse drag
3. right click on mouse button
4. move cursor to a text editor, which is a different window than the VIM terminal.
5. right click and select Paste.
How do I do that the same with yank?
I know there's a trick about using clipboard "*y, but I tried it, it didn't work.
Use the yank command. Select the text you want to copy and type "*y

How to copy a selected word to the clipboard using VIM?

I would like to copy a selected word that the cursor is on to the clipboard. Is there a way to do this.
If support for clipboard is built into your Vim, clipboard is mapped to register *, so you use it the same as any other register. So, for example, to copy the word under cursor to clipboard you do "*yiw. To copy current line "*yy. To paste from clipboard "*p
Perhaps you just want to do this:
viwp
which will visually select a new word, and paste over it.
Now, if you don't want to lose your register when doing this, you can also put in your vimrc:
xnoremap p pgvy
First at all you must check if the clipboard feature on your VIM is enable or not. For that use the --version parameter (vim --version)
If not (-clipboard), you can use a gtk vim edition or compile VIM manually.
If yes (+clipboard), in normal mode "+yiw on your word for copy it in your clipboard.
Follow instruction in https://stackoverflow.com/a/65666057/9384511
Once you have set up your vim as per above link, you will be able to copy single or multiple lines from vim to clipboard by pressing Ctrlc. And paste from clipboard to vim by pressing Ctrlp
Now to copy just a single word to clipboard press bveCtrlc

Why can't I copy paste this text in Vim?

When even i try to copy paste this text in vim it put half of it in the command line and half in text editor main window
This is the text
sub(/;;/," ",$0)
How can i copy paste that
When you paste in console Vim (not GVIM), Vim cannot detect whether what you've pasted is typed by you or an actual paste. Therefore, any (insert mode) mappings will apply. You probably have a mapping (maybe ;;?) that leaves insert mode, and that is triggered during the paste, wreaking havoc.
There are two ways to prevent that:
Either paste in normal mode via "*p (active selection) or "+p (system clipboard), provided that Vim is able to interact with them.
Or, set the 'pastetoggle' option, e.g.
:set pastetoggle=<F2>
and then press F2 (in insert mode) before pasting (note how the mode changes to -- INSERT (paste) --, and again after it. This way, you explicitly tell Vim "the next characters aren't typed by me, treat them literally".
If this manual management is too much of a hassle for you, you can alternatively use graphical GVIM.
I'm not sure which way you're copying and pasting (i.e. from an Xorg window (like gnome-terminal) to vim or vice-versa). Let's assume you want to copy and paste from an Xorg window into your vim window. There are a few ways to do it:
Select the text to copy using the mouse, put vim into insert mode, then press the middle mouse button.
If you are using vim with X support in a console (often started by typeing vimx) then you can select the text to copy using the mouse, then in the vimx window press "*p. The text selected by the mouse is placed in the * register.
If you are using vim with X support in a console (started by typing vimx) then you can select the text to copy using the mouse, right click the mouse, choose menu item Copy and then in the vimx window hit "+p to paste. In this case, because you used the right click menu item to copy, the text was placed in the in the + register.
Items 2 and 3 above also work when using gvim.
What you can do is make sure you're in insert mode and copy the code snippet with ctrl+v on the keyboard and then left click to the vim window to put it back in focus, then tap right click once and your text should paste in. I just tested this to make sure and it worked on CentOS 6.3 at least.
In vim you have modes, to enter text you have to be in insert mode. Press i (before current char) or a (after current char) before pasting your text.
If you don't go into insert mode, the first char s will erase the current char and enter insert mode putting ub(/;;/," ",$0) on your file.
Press ESC to leave the insert mode.
Also if you happen to have a shared clipboard with your GUI pressing p will paste.
To have a shared clipboard on OSX insert set clipboard=unnamed in your ~/.vimrc file.

Resources