A very basic example of elisp, from a hundred and one dotfiles:
(defun dos2unix ()
  (interactive)
    (goto-char (point-min))
      (while (search-forward "\r" nil t) (replace-match "")))
This strips DOS line breaks from a file - I use it a lot in Unix/Linux to edit HTML files which people have created in Windows. You can then add another line of elisp:
(global-set-key [f9] 'dos2unix)
...which sets up Emacs so you can use the f9 function key to perform this function. Or you can specify that DOS files have the function applied to them as soon as they're loaded.
This is about as simple an Elisp function as you could get, but hopefully it hints at the flexibility Emacs provides. Yes, you can do this with
:1,$s/\r//g
in vi, but this is just the tip of the iceberg...

Log in or register to write something here or to contact authors.