hluk / CopyQ

Clipboard manager with advanced features
GNU General Public License v3.0
8.63k stars 440 forks source link

Number as shortcuts to paste item #246

Closed majkinetor closed 10 years ago

majkinetor commented 10 years ago

Unless I missed existing feature, I find it very unpractical to to j/k the list until I find the item I want.

It would be awesome if we could use number to paste item on that position, similar to what vim has with :number<cr> command.

Currently it starts up search for those numbers and I guess some people might want to have search for numbers available. This could be optional setting or could even require prefix like :

This feature, for example, exists in the best open source windows clipboard manager clcl

hluk commented 10 years ago

I think this feature existed in CopyQ few years back but was long forgotten. I'll add it back, it can really save keystrokes.

hluk commented 10 years ago

Added: 54dc0ed7c1d582648ff0a68fa55a60175a67610d

Just enter a number and appropriate row will be selected; additionally the number is highlighted in items as with normal search.

majkinetor commented 10 years ago

Thanks a lot for fast re-implementation :) I will test it ASAP and report any problems here.

majkinetor commented 9 years ago

Just enter a number and appropriate row will be selected; additionally the number is highlighted in items as with normal search.

"Appropriate row" may not be selected if numbers are content of preceding items. I tried with ^n but it actually eliminates the desired row always because number is not treated as regular expression start.

hluk commented 9 years ago

It does seem to work correctly for me. I enter number and item with that row number is selected. This works even if some preceding items contain the number as text -- these items are not hidden but neither are they selected.

majkinetor commented 9 years ago

You are right. Selection colors were not very visible so I missed it. Thanks.

pacid commented 4 years ago

Is this feature still working? I am searching high and low for such a feature as I am doing a lot of copy pasting repetitively and thought it must be somthing like pressing number or ctrl+number or alt+number, I means that't one of the first feature you think about and do it instinctively. I can't seem to find in docs and can't get it to work by just pressing the numbers with the window of CopyQ open. Halp!

majkinetor commented 4 years ago

You just press number while copy q windows is shown. Numbers are shown on the left. Number will be typed in search bar, don't that confuse you. So, is all you do.

It might be confusing that if there is the same number on some item before the one you want, it is also selected, but not as an item, but as a text. Along with that actuall item on that number is selected as item, not text.

pacid commented 4 years ago

Oh yeah figured that it's: 1) Open the CLIPBOARD window 2) Press the number of the stored text you want to paste 3) then ENTER to actually paste it

Thank you majkinetor for the response nonetheless!

How about: 1) Configure the global hotkeys which, in case they are pressed with number key (0-9) just paste the text. So I could have for instance ctrl+shift + (0-9) for a corresponding text in the clipboard.

My use case here is: I am pasting three different texts over and over, so I'd remember which one is which and it would save some steps. What do you think?

pacid commented 4 years ago

image Someone described it for another tool.

majkinetor commented 4 years ago

Configure the global hotkeys which, in case they are pressed with number key (0-9) just paste the text. So I could have for instance ctrl+shift + (0-9) for a corresponding text in the clipboard.

That is very nice idea, and it totally fits my workflow. I use a lot first 10 items, but they are not on the main tab. So any hotkey will have to take tab into option.

hluk commented 4 years ago

Configure the global hotkeys which, in case they are pressed with number key (0-9) just paste the text. So I could have for instance ctrl+shift + (0-9) for a corresponding text in the clipboard.

You can make that work with following command (here is how to add the command to CopyQ).

[Command]
Command="
    copyq:
    var n = str(data(mimeShortcut)).slice(-1)
    select(n)"
GlobalShortcut=ctrl+shift+0, ctrl+shift+1, ctrl+shift+2, ctrl+shift+3, ctrl+shift+4, ctrl+shift+5, ctrl+shift+6, ctrl+shift+7, ctrl+shift+8, ctrl+shift+9
Icon=\xf0cb
IsGlobalShortcut=true
Name=Select Nth Item

The behavior depends on current settings in the History config tab in Preferences dialog.

image

majkinetor commented 4 years ago

CopyQ rocks as always. Thx @hluk

pacid commented 4 years ago

Awesome!! I'd just add to it paste() at the end like that:


Command="
    copyq:
    var n = str(data(mimeShortcut)).slice(-1)
    select(n)
    paste()"
GlobalShortcut=ctrl+shift+0, ctrl+shift+1, ctrl+shift+2, ctrl+shift+3, ctrl+shift+4, ctrl+shift+5, ctrl+shift+6, ctrl+shift+7, ctrl+shift+8, ctrl+shift+9
Icon=\xf0cb
IsGlobalShortcut=true
Name=Select and Paste Nth Item```
pacid commented 4 years ago

image

DrZanuff commented 1 year ago

I have a problem with this code. Pretend I have two itens in clipboard history like that:

  1. "Hello"
  2. "World"

When I press Ctrl+1 it will paste "World", but my item order will change to:

  1. "World"
  2. "Hello"

If I press Ctrl+1 again it will paste now hello. I don't want this behavior, I want it to always mantain the original item order. This is how i fixed for my needs:

copyq:
var n = str(data(mimeShortcut)).slice(-1)
var item = getitem(n-1)
copy(item)
paste()
majkinetor commented 1 year ago

@DrZanuff , that doesn't make any sense really.

DrZanuff commented 1 year ago

@majkinetor sorry, I was speaking about @pacid implementation. I tried his proposed code but every time i've pasted it changed the selection order. My version will not change the order, so I shared in case anyone needed the same behavior.

majkinetor commented 1 year ago

Ah, ok, sorry :) Thx for sharing indeed :)

kayanco commented 1 year ago

Hi, What command can I add to this code to paste as plain text?

If I press Ctrl+1 again it will paste now hello. I don't want this behavior, I want it to always mantain the original item order. This is how i fixed for my needs:

copyq:
var n = str(data(mimeShortcut)).slice(-1)
var item = getitem(n-1)
copy(item)
paste()