Sublime Forum

Add occurence to selection in EmacsPro mode

#1

Hello
I use Option-D in the Mac to add marked occurence to ring.
In Linux, CTRL-D performs the same thing.
But in Emacs model, CTRL-D deletes next character. How do I accomplish the equivalent of Option-D in Linux under Emacs mode? I can do ALT-F3, but that selects all occurence. I only want to add next occurence to the ring.

Many thanks.

0 Likes

#2

Are you sure you don’t have something in Emacs overwriting the C-d action? I’ve got a pretty stock version of Emacs here and C-d deletes character at/ahead of the point. I also checked C-D. I also selected a word and looked to see if C-d would delete the section and add to the kill ring and it still deleted the character at/ahead of the point.

For kill selection, I’ve always (in Emacs and Sublime with Emacs Pro Essentials) used C-w and then M-w for add to kill ring without deleting.

Hope that helps? I know it’s not exactly a solution, but I kind of think maybe your Linux Emacs has something custom to it.

0 Likes

#3

Thanks. C-D and C-d both delete, as they should under emacs. But under SUBL, it should be “add next occurence to selection”. I was asking how to “add next occurence” when I am in Emacs mode. Sorry I wasn’t clear.
I fix this by binding CTRL-F3 to “add next occurence to selection”. It works now. Thanks again.

1 Like

#4

OH, yes there are a number of Sublime features that get unbound when using Emacs Pro Essentials I believe. I’m glad you found a solution to that.

0 Likes

#5

The Emacs Pro Essentials plugin has a key combination (CMD-D on the Mac) for adding the current highlighted word to the selection/future cursors. The nice thing about it is, If you add it and change your mind you can press Backspace and because it’s incremental search it will remove that addition.

1 Like

#6

Thanks… Yes, CMD-D works on my mac. But in Linux it is CTRL-D, and Emacs Pro already uses CTRL-D for delete word. I got it to work by binding CTRL-F3 to the “add next occurence to selection”.
BTW… Thanks very much for the package.

0 Likes

#7

This is the key binding that works on Macs. So you could also add one for linux for ctrl+d.

    {"keys": ["super+d"], "command": "sbp_inc_search", "args": {"cmd": "next", "keep": true},
        "context": [ {"key": "i_search_active"}, {"key": "panel_has_focus"} ]
    },

I suppose its quite bad that I never created a bindings file for linux and/or windows. But there’s no reason you can’t just modify the above binding and replace super+d with ctrl+d. It’s control+d, which is right_delete normally, but overridden when doing incremental search.

Add next occurrence to selection is … perhaps not entirely the same as the isearch command sbp_inc_search(“next”, keep=true).

0 Likes

#8

I have to say, the bindings for Windows seems to largely map against Emacs ported for windows (EmacsW32) so it’s been okay for me. The only one I found that was an issue was the undo forward slash binding which I opened that issue for awhile back and that’s easily enough accomplished on my own.

0 Likes

#9

Unfortunately, this does not work. I replace super-d by ctrl-d as you suggested. It still deletes characters (according to the emacs binding).

My Ctrl-F3 also does not work. It marks the next occurrence. This part works. But if I make changes to the marked selection, only the last selection is changed. I want changes to all selections, as in multi-cursor.
Further suggestions would be much appreciated.
Thanks!

0 Likes

#10

By “ctrl-d” do you mean “ctrl+d”?

Otherwise I have no idea why it wouldn’t work.

Please let me know.

0 Likes

#11

Yes, by ctrl-d, I meant ctrl+d. I pasted the lines you suggested into the kepmap file for user, changed shift to ctrl.
Suppose I have these lines

I have one dog
I have two dog
I have three dog

and I want to change dog to cat.
Without the emacs bindings, I mark one of the ‘dog’, hit CTRL-D twice. Then I type cat and all `dog’ will be ‘cat’.
With the emacs bindings, CTRL-D deletes character.

Maybe I am not understanding how to use the new bindings with multi-cursor. Would it be possible to give me a example of what you suggests in the readme (pasted below)? What keystrokes combinations do I need to change ‘dog’ to ‘cat’? Hopefully with an example
I can try to figure this out with bothering you further. Many thanks for your help.

If you had multiple cursors while appending to the kill ring, the kill entry will contain and remember those separate cursors. If you try to yank multiple cursors, it will work as >expected if you still have the same number of cursors.

when you supply a numeric argument to the ctrl+x ctrl+y command, it will let you >choose which item to yank all cursors for. And now the choose command shows you >which entries have more than one cursor.

0 Likes