You are not logged in.

#1 2008-05-07 16:07:00

finferflu
Forum Fellow
From: Manchester, UK
Registered: 2007-06-21
Posts: 1,899
Website

Vim copy buffers?

I'm in the process of writing my final dissertation (am I late!), and I need a particularly useful feature.
I'm using LaTeX in Vim, and I would like to know if Vim has the feature of storing copied buffers to fetch them when needed (for example, pasting what I have copied 3 "copies" ago). I remember Emacs has something similar. I tried to google for it, but couldn't find anything, and I have not much time to dig this at the moment.

Is there anyone so kind as to point me to the right direction?
Thanks smile


Have you Syued today?
Free music for free people! | Earthlings

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery

Offline

#2 2008-05-07 16:15:58

skymt
Member
Registered: 2006-11-27
Posts: 443

Re: Vim copy buffers?

What you're looking for is the '"' (double-quote) key. '"ay' to yank something to the 'a' register, then '"ap' to put it. You can use any letter, so you have 52 registers to work with. You do need to remember to store the yank in a register, so that's one downside compared to Emacs's kill ring.

Vim also has something closer to the kill ring in some ways: registers 1 through 9 store recent deletes and changes, but not yanks.

Last edited by skymt (2008-05-07 16:16:24)

Offline

#3 2008-05-07 16:21:18

finferflu
Forum Fellow
From: Manchester, UK
Registered: 2007-06-21
Posts: 1,899
Website

Re: Vim copy buffers?

Thanks as lot smile
I can definitely see the downside here: I will have to manually save all the yanks I need, even when I don't know whether I will need them again. However I guess I could make this automatic (i.e. saving whatever I yank in a register, a-Z, alphabetically), knowing how Vim scripting works. I will do it when I have more time.

For now I could take advantage of the delete function, which is the one Emacs uses anyway: when you kill text, you delete it, and you kill it even when you only want to copy it, so you will need to paste it back. So, ho do I access the delete registers?

Thank you smile

Last edited by finferflu (2008-05-07 16:21:43)


Have you Syued today?
Free music for free people! | Earthlings

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery

Offline

#4 2008-05-07 19:01:40

Sigi
Member
From: Thurgau, Switzerland
Registered: 2005-09-22
Posts: 1,131

Re: Vim copy buffers?

finferflu wrote:

So, ho do I access the delete registers?

p


Haven't been here in a while. Still rocking Arch. smile

Offline

#5 2008-05-07 19:07:05

finferflu
Forum Fellow
From: Manchester, UK
Registered: 2007-06-21
Posts: 1,899
Website

Re: Vim copy buffers?

Ah, ok, so

"3p

pastes the third before the last deleted text.

Got it, thanks smile


Have you Syued today?
Free music for free people! | Earthlings

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery

Offline

#6 2008-05-07 22:09:26

nj
Member
Registered: 2007-04-06
Posts: 93

Re: Vim copy buffers?

There is also the yankring.vim plugin if you like the way emacs kill ring works. Hit p to paste the last and then C-p to cycle backwards.

Offline

#7 2008-05-08 05:15:06

peets
Member
From: Montreal
Registered: 2007-01-11
Posts: 936
Website

Re: Vim copy buffers?

If your goal is to avoid typing long LaTeX names, try vim's automatic completion feature: when in insert mode, start typing the word, then press Ctrl-n. No memory required --human memory, that is.

Offline

#8 2008-05-08 06:08:39

Sigi
Member
From: Thurgau, Switzerland
Registered: 2005-09-22
Posts: 1,131

Re: Vim copy buffers?

peets wrote:

If your goal is to avoid typing long LaTeX names, try vim's automatic completion feature: when in insert mode, start typing the word, then press Ctrl-n. No memory required --human memory, that is.

Sweet, didn't know that one, thanks peets


Haven't been here in a while. Still rocking Arch. smile

Offline

#9 2008-05-08 07:20:06

Husio
Member
From: Europe
Registered: 2005-12-04
Posts: 359
Website

Re: Vim copy buffers?

community/vim-supertab 0.45-1
    A Vim plugin that allows you to use the tab key to do all insert completion

This plugin will let you complete with Tab key. It also supports changing of completition type. (word, line, omnicomplete, etc)

Offline

#10 2008-05-08 12:39:32

finferflu
Forum Fellow
From: Manchester, UK
Registered: 2007-06-21
Posts: 1,899
Website

Re: Vim copy buffers?

@ nj
Thanks for that, I'll look into that smile

@ peets
Thanks for the suggestion, but I wasn't looking for autocompletion. I knew that "trick" even though I don't find pressing Ctrl-n very comfy, which leads me to:

@ Husio
That's a very interesting plugin, but then I make extensive use of the TAB key (for writing bib files). So how would I actually insert a tab?


Have you Syued today?
Free music for free people! | Earthlings

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery

Offline

#11 2008-05-08 13:02:51

rson451
Member
From: Annapolis, MD USA
Registered: 2007-04-15
Posts: 1,233
Website

Re: Vim copy buffers?

i believe that supertab only shows it's menu if you are on a word or currently typing a word.  tabbing in whitespace is no problem.


archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson

Offline

#12 2008-05-08 13:07:42

finferflu
Forum Fellow
From: Manchester, UK
Registered: 2007-06-21
Posts: 1,899
Website

Re: Vim copy buffers?

How about the end of a word? Or do I have to insert a space before tabbing?
I guess I'll only have to try it out and see...


Have you Syued today?
Free music for free people! | Earthlings

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery

Offline

#13 2008-05-08 17:26:41

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Vim copy buffers?

Supertab is smart, but you should probably get used to the built in vim completion. You're going to hit a machine that has vim but no supertab plugin and feel stranded.

C-p and C-n will attempt to match the word with the "previous" or "next" word in the document.

Additionally, vim7 has super-duper completion for some things (:help ins-completion). My personal favorite is C-x,C-f which will complete files. Try "/usr/bin/C-x,C-f"

Offline

#14 2008-05-08 17:32:37

finferflu
Forum Fellow
From: Manchester, UK
Registered: 2007-06-21
Posts: 1,899
Website

Re: Vim copy buffers?

I already know C-p and C-n, but they're uncomfy and it's just quicker for me to actually type the word in most cases.

As for the file names, I think I will find that useful when once learn some coding (or perhaps editing some config files, thinking about it). Thanks for the tips smile

Now I'm in the uni library, and FTP is blocked, so I can't install anything via repos.


Have you Syued today?
Free music for free people! | Earthlings

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery

Offline

#15 2008-05-09 00:24:21

peets
Member
From: Montreal
Registered: 2007-01-11
Posts: 936
Website

Re: Vim copy buffers?

I used to type all C-<something> shortcuts with the left hand. Works well for the keys that are on the left side of my QWERTY keyboard (C-z, C-c, C-a, etc.) I found C-n very uncomfortable too. Now I do it with two hands, and it's not harder than using shift to type capital letter, WHICH WE ALL DO EFFORTLESSLY.

I must admit that I use C-space at work in this horrible program called eclipse. I should try and fix javacomplete.

Offline

#16 2008-06-01 21:50:01

finferflu
Forum Fellow
From: Manchester, UK
Registered: 2007-06-21
Posts: 1,899
Website

Re: Vim copy buffers?

OK, now I have a bit more time to dedicate to this, since it is also getting pretty annoying.
So, ever since I installed yankring, I keep getting the following message whenever I start Vim:

YR: The yankring can only persist if the viminfo setting has a "!" 
Press ENTER or type command to continue

What does that mean? I have no clue.


Have you Syued today?
Free music for free people! | Earthlings

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery

Offline

#17 2008-06-02 00:23:12

nj
Member
Registered: 2007-04-06
Posts: 93

Re: Vim copy buffers?

Put one of these lines in your .vimrc

" tell yankring not to persist between different vim sessions
" the yankring will be cleared every time vim is opened
let g:yankring_persist = 0
" store global variables in .viminfo, for yankring to persist between different vim sessions
set viminfo+=!

Offline

#18 2008-06-02 00:39:09

mintcoffee
Member
From: Waterloo, ON
Registered: 2007-10-05
Posts: 120
Website

Re: Vim copy buffers?

You might also find :reg useful, since it lists out the current registers. However, these include deleted / cut lines and not just yanked lines (like yankring).


Arch on a Thinkpad T400s

Offline

#19 2008-06-02 08:45:46

finferflu
Forum Fellow
From: Manchester, UK
Registered: 2007-06-21
Posts: 1,899
Website

Re: Vim copy buffers?

Thanks for your help smile


Have you Syued today?
Free music for free people! | Earthlings

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery

Offline

Board footer

Powered by FluxBB