Sublime Forum

Is there an analogue of my favorite Vim feature?

#1

Hello all,

I got addicted to Vim because it can do the following: given text such as “1+1+1 = three = two plus one”, you can put the cursor at the first 1, type ‘d/two’ to delete until the next occurence of ‘two’. Is there any feature in Sublime text (or even Emacs) to delete/copy/cut from the cursor until the next occurence of ‘blah’?

I have tried the VI emulation in Sublime, and this feature is not supported there (pressing / turns on the search mode, but forgets that I meant to delete until the search result). Are there plans to add it? On the other hand, I would be more interested in a more organic and native approach.

Thank you!

            Ilya.
0 Likes

#2

You do this by Edit / Mark / Set Mark, then move by searching or some other method, and then Edit / Mark / Delete to Mark. Of course you’d rather use the key equivalents for your platform. I believe you use the same approach in Emacs, and even in Vim if that’s your fancy.

0 Likes

#3

The point is that the Vim method is fast. Setting the mark alone requires two different key combinations.

0 Likes

#4

Sure, but you asked for the native way of doing this, not for the exact same as in Vim. The native Sublime way of using it with marks is quick enough for me. Can’t say that I delete from the cursor up to some close-by text that often, but to each his own. You could speed it up a little by binding set mark / delete to mark to single keystrokes. Don’t know if it would make much difference though.

0 Likes

#5

I guess this was a stupid question, I shouldn’t really expect such things to work in other editors. It’s just that this now feels to me as the most natural way to edit text: whenever I want to change a piece of a sentence, I go there, look at the first word I want to keep, and do “c/that word”. I.e., I am an addict :wink:.

Thanks for the help!

0 Likes

#6

I don’t think it was a stupid question as I had the exact same one :wink: I can tell this is one of the tricks I use the most in VI because it’s a real pain point for me when using Sublime. It’s a give and take though, I use VI for most stuff, and switch to Sublime when a project has many files and folders.

0 Likes

#7

On Vintage you can do:

d f t

delete + find + t ( and it’ll delete till the first t )

if if there’s a t before that you can hit . to repeat action.

0 Likes

#8

This is just the way it’s done with Sublime.

This is the quickest keyboardy way I know of (on Windows):

Ctrl+k, Ctrl+SPACE (Set Mark)
Ctrl-f some word, ESC, Cursor left (Move to start of search string)
Ctrl+k, Ctrl+w (Delete between cursor and Mark)
And then if you’re being thorough:
Ctrl+k, Ctrl+g (Clear Mark)

I agree that on Vi/Vim it’s quicker, but I think that’s just because it’s a modal editor, and that particular action is well-suited to the structure of Vi commands.

Linguistically speaking, a non-modal editor like Sublime has a different word order, and the verb doesn’t appear until the end, so you usually need some way of defining your selection first and then performing a command.
You may also like to think of this as something like Reverse Polish Notation: you have to set your start- and end-position parameters before applying the delete operation.

It would be the same on pretty any editor that doesn’t have Vim’s endearing quirks.

(Disclaimer: I’ve been editing with Vi and Vim for about twenty years, on nearly every system I use, so I know it and depend on it - it’s my editor of choice. Sublime is the first non-modal editor I’ve found which I enjoy using as much.)

I’m sure there’s some set of operations which are much quicker in Sublime than in Vim, but at the moment I’m finding it difficult to think of any, apart from Paste and Indent and Toggle Comment.

0 Likes