Skip to content

Instantly share code, notes, and snippets.

@hidsh
Created March 21, 2012 07:39
Show Gist options
  • Save hidsh/2145496 to your computer and use it in GitHub Desktop.
Save hidsh/2145496 to your computer and use it in GitHub Desktop.
xyzzy: replace '/' <--> '\' at current line (for path string win and linux)
(defun slash-to-backslash-line ()
"replace '/' <--> '\' at current line. (toggle)"
(interactive)
(save-excursion
(let ((eol (progn (goto-eol) (point)))
(bol (progn (goto-bol) (point))))
(save-restriction
(narrow-to-region bol eol)
(let (from to)
(cond ((looking-for "\\") (setq from "\\")
(setq to "/"))
((looking-for "/") (setq from "/")
(setq to "\\")))
(when from
(replace-buffer from to)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment