Created
June 3, 2012 09:58
-
-
Save maio/2862867 to your computer and use it in GitHub Desktop.
Smart semi-colon in Emacs (and Vim)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Port of Coderush's smart semi-colon feature to Emacs | |
;; | |
;; When I hit semi-colon anywhere, Emacs will move cursor to the end of current | |
;; line and insert semi-colon (if it's not already there). | |
;; | |
;; Idea from last @CoderetreatCZ - HK | |
(defun maio/electric-semicolon () | |
(interactive) | |
(end-of-line) | |
(when (not (looking-back ";")) | |
(insert ";"))) | |
(define-key cperl-mode-map ";" 'maio/electric-semicolon) | |
(define-key php-mode-map ";" 'maio/electric-semicolon) | |
;; or key-chord | |
(key-chord-define cperl-mode-map ";;" 'maio/electric-semicolon) | |
... | |
;; Vim version (that doesn't check if ; is already there) - ~/.vim/ftplugin/perl.vim | |
inoremap ; <ESC>A; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment