Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

emacs equivalent of ct

Tags:

emacs

looking for an equivalent cut and paste strategy that would replicate vim's 'cut til'. I'm sure this is googleable if I actually knew what it was called in vim, but heres what i'm looking for:

if i have a block of text like so:

foo bar (baz)

and I was at the beginning of the line and i wanted to cut until the first paren, in visual mode, I'd do:

 ct (

I think there is probably a way to look back and i think you can pass more specific regular expressions. But anyway, looking for some emacs equivalents to doing this kind of text replacement. Thanks.

like image 673
Jed Schneider Avatar asked Dec 05 '22 17:12

Jed Schneider


1 Answers

Here are three ways:

  1. Just type M-dM-d to delete two words. This will leave the final space, so you'll have to delete it yourself and then add it back if you paste the two words back elsewhere.
  2. M-z is zap-to-char, which deletes text from the cursor up to and including a character you specify. In this case you'd have to do something like M-2M-zSPC to zap up to and including the second space character.
  3. Type C-SPC to set the mark, then go into incremental search with C-s, type a space to jump to the first space, then C-s to search forward for the next space, RET to terminate the search, and finally C-w to kill the text you selected.

Personally I'd generally go with #1.

like image 58
Sean Avatar answered Dec 31 '22 10:12

Sean