Function: viper-query-replace

viper-query-replace is an interactive and byte-compiled function defined in viper-cmd.el.gz.

Signature

(viper-query-replace)

Documentation

Query replace.

If a null string is supplied as the string to be replaced, the query replace mode will toggle between string replace and regexp replace.

As each match is found, the user must type a character saying what to do with it. Type SPC or y to replace the match, DEL or n to skip and go to the next match. For more directions, type <f1> (help-command) at that time.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/emulation/viper-cmd.el.gz
;; query replace

(defun viper-query-replace ()
  "Query replace.
If a null string is supplied as the string to be replaced,
the query replace mode will toggle between string replace
and regexp replace.

As each match is found, the user must type a character saying
what to do with it.  Type SPC or `y' to replace the match,
DEL or `n' to skip and go to the next match.  For more directions,
type \\[help-command] at that time."
  (interactive)
  (let (str)
    (setq str (viper-read-string-with-history
	       (if viper-re-query-replace "Query replace regexp: "
		 "Query replace: ")
	       nil  ; no initial
	       'viper-replace1-history
	       (car viper-replace1-history) ; default
	       ))
    (if (string= str "")
	(progn
	  (setq viper-re-query-replace (not viper-re-query-replace))
	  (message "Query replace mode changed to %s"
		   (if viper-re-query-replace "regexp replace"
		     "string replace")))
      (if viper-re-query-replace
	  (query-replace-regexp
	   str
	   (viper-read-string-with-history
	    (format-message "Query replace regexp `%s' with: " str)
	    nil  ; no initial
	    'viper-replace1-history
	    (car viper-replace1-history) ; default
	    ))
	(query-replace
	 str
	 (viper-read-string-with-history
	  (format-message "Query replace `%s' with: " str)
	  nil  ; no initial
	  'viper-replace1-history
	  (car viper-replace1-history) ; default
	  ))))))