cut and paste source code to console
0 votos
January 2nd, 2007 mysurface Posted in Text Manipulation, cat | Hits: 12613 |
If your vim have auto indent enabled, you may facing this problem. Vim are too smart to help you indent copied source code, and the comment line will kill your pasting very much. I usually do copy and paste source code from ebook or web page to a file so that I can compile and run for test. In this case vim is not helping. I use cat instead.
Let say I copy a sample source code from the web, by typing the command line bellow:
cat > sample.c
I can now paste the source code and press Enter to insert a new line then ctrl+d after finish pasting.
Okay its done, now I can compile the sample source code.
Live Chat!









January 3rd, 2007 at 8:31 am
Do you have shortcut key for paste action in console?
E.g. Copy some contents from a web page from Firefox and paste into vim in console.
January 3rd, 2007 at 8:42 am
Paste to vim at console is dangerous, it may results something that out of your expectation. Use the example stated above is more promising.
Shortcut for pasting to console is
1. Mouse middle click
2. keyboard Shift+Insert
January 3rd, 2007 at 11:54 pm
I think this will help for vim
January 4th, 2007 at 1:15 am
Great! that works!
January 4th, 2007 at 7:51 pm
Really thanks for the keyboard shortcut! I know there must be a shortcut key for that.
However,
when using vim, in what case that we need to use the command:
:set pastei
As I try, there is nothing different with/without that command. Could you illustrate an example that able to show the difference?
June 7th, 2007 at 1:49 pm
But don’t set :set paste permanently in your .vimrc, as it disables imap, cmap, and abbreviations.
June 7th, 2007 at 4:24 pm
correct, the best way is do it by toggle set paste like this
:set paste!When you trigger the second time, the set paste will be disabled.
June 25th, 2007 at 1:30 pm
hw 2 get d hours from 12:09:08 using cut command
explain in brief
i m new 2 linux…plz..help…
June 26th, 2007 at 1:55 am
mythili:
You are looking for cut command instead, this post talks about cut and paste into vim which is not what you want.
Type cut at search text box, and the result will be this.
October 17th, 2007 at 12:34 am
btw, simply
:adoes often the same job.
October 19th, 2007 at 9:38 pm
my paste function ;
“fix pasting so you dont get the step down effect
nnoremap <F5> :set invpaste paste?<Enter>
imap <F5> <C-O><F5>
set pastetoggle=<F5>
October 21st, 2007 at 1:21 am
adam: Not really understand how it works, but will look into it later, thanks.
June 27th, 2008 at 7:38 am
Sorry for the last comment …
not what I wanted to show you (pasted the wrong text …)
The following steps is what I use to copy/paste between multiples instances of VIM:
Accessing the system clipboard
From Vim Tips Wiki
Jump to: navigation, search
Tip 984 Previous Tip • Next Tip
Created: September 4, 2005 Complexity: basic Author: JimD Minimum version: 6.0 Karma: 30/17 Imported from: Tip#984
One of the traditional disconnects between vi and modern graphical environments has been using mouse-driven copy/paste between a terminal or command prompt window, and any other application (for example, a web browser).
Vim has extended vi to allow use of the * register as a reference to the system clipboard. So we can use normal mode commands like: “*dd or 1G”*yG to copy things into the * register and “*p to paste text from it. We can also use this * register with the ex yank command, so :%y * will accomplish the same goal as gg”*yG (copy all text into the system clipboard so it can be pasted into an X or MS Windows application).
The * register acts just like any of the normal (single letter) registers in vi except that it also refers to the system clipboard in X11 or MS Windows.
I’ve also found that it’s much faster and more reliable than pasting a large body of text into Vim through an xterm. Normally I run Vim under the Linux screen utility and any more than one screen full of text is often corrupted, and large selections (>10KB) take several seconds of gnashing and flashing to finish pasting (almost always corrupted). By contrast, pasting 100KB text using “*p is very reliable and fast.