Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have Vim configured to paste external text (i.e. text copied from an external source, not inside Vim) in two manners: Ctrl+v and Ctrl+Shift+v.
The former used to paste text subject to autocorrect action; the latter didn't.
I don't know exactly how I did it. I found this in my .vimrc:
Code:
" Pasting blockwise and linewise selections is not possible in Insert and
" Visual mode without the +virtualedit feature. They are pasted as if they
" were characterwise instead.
" Note: the same stuff appears in menu.vim.
if has("virtualedit")
nnoremap <silent> <SID>Paste :call <SID>Paste()<CR>
func! <SID>Paste()
let ove = &ve
set ve=all
normal `^
if @+ != ''
normal "+gP
endif
let c = col(".")
normal i^[
if col(".") < c " compensate for i<ESC> moving the cursor left
normal l
endif
let &ve = ove
endfunc
inoremap <script> <C-V> x<BS><Esc><SID>Pastegi
vnoremap <script> <C-V> "-c<Esc><SID>Paste
else
nnoremap <silent> <SID>Paste "=@+.'xy'<CR>gPFx"_2x
inoremap <script> <C-V> x<Esc><SID>Paste"_s
vnoremap <script> <C-V> "-c<Esc>gix<Esc><SID>Paste"_x
endif
I am 100% sure I didn't write any of that myself. I took it from someone else in the internets. It seems to explain where Ctrl+v is configured, but I still don't know where Ctrl+Shift+v is. I can't find any references to it in my .vimrc. I have many key bindings, but none involves the letter v. I've triple checked. Maybe it's in the code above, which I can't read very well. I'm not fluent in vimscript.
But I remember I changed something one day and neither key combination now is affected by autocorrect. They have the exact same effect... or almost.
The only difference between them now is that there is some limit to the amount of text I can paste with Ctrl+v. If I go above that limit, something else is pasted. Something I copied elsewhere some time ago, often hours ago and I don't know how or why it is still hanging somewhere.
Ctrl+Shift+v doesn't seem to have any limit. It seems to have infinite capacity. I have pasted hundreds of MB of text and it works.
My questions today are:
- Why is there such a limit? Why do the two actions work so differently?
- Where is the Ctrl+Shift+v action configured?
- How can I improve my handling of copy/pasting from/into Vim, in case you have a better idea?
I gave up farting about totally with vim. It's a bit like the lost chord - you get it out once and never find it again. Use Nano. No sweat with the middle mouse button.
I have never managed to paste into vim with CTRL-v; I always use CTRL-SHIFT-v. I just tested CTRL-v on Debian Testing; did not paste.
I think the question that should be asked is "why am I able to paste with CTRL-v?"
I used to find vim frustrating, then I realized I was approaching it wrong. I was trying to learn too much at once. I concentrated on becoming proficient with a few basic commands (x, i, o, y, p, dd, x, and / mainly) and am now quite comfortable using vim with the kinds of text files that I need to edit.
- How can I improve my handling of copy/pasting from/into Vim, in case you have a better idea?
TIA
I'm not sure if this is a better idea but I use vim on a regular basis and to copy I use 'Ctrl + alt + c' and to paste 'Shift + insert'. I've never had any problems with copying text and pasting into vim this way. Of course, I've never copied and pasted a hundred or more MBs of text.
Also, it might be worth it for you to create your own .vimrc. That way when you come across some functionality you would like to have, you can learn about it, add it to your .vimrc, and that way you know what every line of your .vimrc does. Just an idea. That's how I like to do things
I would try simply :r file and that will insert the content. Or you can open several files within vim and yank/put will work among those files. You do not need to complicate it. Originally vi was not meant to handle [external] copy&paste buffers.
As promised, here's a .vimrc from one of my machines:
Code:
$ cat .vimrc
set ruler laststatus=2 number title hlsearch
syntax on
set textwidth=80
set spell spelllang=en_us
set spellfile=$HOME/.vim/spell/en.utf-8.add
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.