Home Download Buy Blog Forum Support

Is there an analogue of my favorite Vim feature?

Is there an analogue of my favorite Vim feature?

Postby ilyagr on Wed Aug 15, 2012 5:57 am

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.
ilyagr
 
Posts: 3
Joined: Wed Aug 15, 2012 5:48 am

Re: Is there an analogue of my favorite Vim feature?

Postby svenax on Thu Aug 16, 2012 8:44 am

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.
svenax
 
Posts: 145
Joined: Tue Dec 20, 2011 12:47 pm

Re: Is there an analogue of my favorite Vim feature?

Postby ilyagr on Thu Aug 16, 2012 7:49 pm

The point is that the Vim method is fast. Setting the mark alone requires two different key combinations.
ilyagr
 
Posts: 3
Joined: Wed Aug 15, 2012 5:48 am

Re: Is there an analogue of my favorite Vim feature?

Postby svenax on Fri Aug 17, 2012 6:49 am

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


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.
svenax
 
Posts: 145
Joined: Tue Dec 20, 2011 12:47 pm

Re: Is there an analogue of my favorite Vim feature?

Postby ilyagr on Fri Aug 17, 2012 7:13 pm

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<CR>". I.e., I am an addict ;).

Thanks for the help!
ilyagr
 
Posts: 3
Joined: Wed Aug 15, 2012 5:48 am

Re: Is there an analogue of my favorite Vim feature?

Postby koalakong on Tue Sep 25, 2012 7:07 pm

I don't think it was a stupid question as I had the exact same one ;) 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.
koalakong
 
Posts: 1
Joined: Tue Sep 25, 2012 7:02 pm

Re: Is there an analogue of my favorite Vim feature?

Postby kuroir on Wed Sep 26, 2012 9:43 am

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.
kuroir
 
Posts: 71
Joined: Thu Sep 01, 2011 11:28 pm
Location: Mexico

Re: Is there an analogue of my favorite Vim feature?

Postby njd on Wed Oct 03, 2012 11:41 am

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 <verb><motion> 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.
njd
 
Posts: 1
Joined: Wed Oct 03, 2012 11:04 am


Return to General Discussion

Who is online

Users browsing this forum: Google Feedfetcher, memomo, Yahoo [Bot] and 29 guests