Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Does emacs have the equivalent of VIMs ci" command? Basically I want to replace the text inside a set of quotation marks.

In vim I can ci) or ci] or ci} to "change inner *"...

share|improve this question
add comment

6 Answers

up vote 10 down vote accepted

Off the top of my head, the closest command is M-z " which deletes everything from point to the next occurance of the " character.

There is also C-M-k, aka "kill balanced expression", which will delete a full parenthesized statement or double quoted string etc. based on the current modes definition of "balanced expression" and the character currently under point (ie. it only works if the cursor is on the opening '"' or '(' etc.).

share|improve this answer
add comment

I'm afraid I don't know about VIM's ci feature, but have you looked at Emacs regexp replace? I can't speak to the exact semantics or how easy it is to use in comparison, but it's what I would use for what I think you want.

share|improve this answer
    
emacs regexp replace is the equivalent of vi :s/regex/replacement/, what he wants is a keypress to delete and replace the current balanced expression at point. –  Justin Smith Mar 26 '10 at 12:53
add comment

Similarly to Justin's suggestion C-M-SPACE gives you "mark-sexp" which will select to the balancing paren, quote, etc. and then you can C-w or whatever to make it go away. In case you want to SEE what you're about to delete before you delete it...

share|improve this answer
add comment

Yes! The equivalent of VIMs ci" command in Emacs is... ci" :-)
http://www.emacswiki.org/emacs-de/Vimpulse

share|improve this answer
add comment

Just stumbled upon this question; here is a custom solution that's worked for me:

(defun seek-backward-to-char (chr)
  "Seek backwards to a character"
  (interactive "cSeek back to char: ")
  (while (not (= (char-after) chr))
    (forward-char -1)))


(defun delete-between-pair (char)
  "Delete in between the given pair"
  (interactive "cDelete between char: ")
  (seek-backward-to-char char)
  (forward-char 1)
  (zap-to-char 1 char)
  (insert char)
  (forward-char -1))

Then bind delete-between-pair to whatever key you like. For me, I have it bound on C-z i.

share|improve this answer
add comment

I've made a minor mode which provides some of those Vim facilities called Markit.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.