help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get the ~ functionality of vi


From: Emanuel Berg
Subject: Re: How to get the ~ functionality of vi
Date: Fri, 27 May 2016 03:15:48 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Cecil Westerhof <address@hidden> writes:

> In vi you can use ~ to flip the case of
> a character. Does Emacs has something
> like that?

Try this:

    (defun flip-case ()
      (interactive)
      (let ((c (string-to-char (thing-at-point 'char t))))
        (delete-char 1)
        (cond ((and (>= c ?A) (<= c ?Z)) (insert-char (downcase c)))
              ((and (>= c ?a) (<= c ?z)) (insert-char (upcase   c)))
              (t                         (insert-char c)))) )
    (global-set-key "\C-cf" #'flip-case)

-- 
underground experts united .... http://user.it.uu.se/~embe8573
Emacs Gnus Blogomatic ......... http://user.it.uu.se/~embe8573/blogomatic
                   - so far: 42 Blogomatic articles -                   


reply via email to

[Prev in Thread] Current Thread [Next in Thread]