-
-
Save thiagoa/7d564b093f40db98cbcb4571c790a5dc to your computer and use it in GitHub Desktop.
Align function emacs
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
;; Align command !!! | |
;; from http://stackoverflow.com/questions/3633120/emacs-hotkey-to-align-equal-signs | |
;; another information: https://gist.github.com/700416 | |
;; use rx function http://www.emacswiki.org/emacs/rx | |
(defun align-to-colon (begin end) | |
"Align region to colon (:) signs" | |
(interactive "r") | |
(align-regexp begin end | |
(rx (group (zero-or-more (syntax whitespace))) ":") 1 1 )) | |
(defun align-to-comma (begin end) | |
"Align region to comma signs" | |
(interactive "r") | |
(align-regexp begin end | |
(rx "," (group (zero-or-more (syntax whitespace))) ) 1 1 )) | |
(defun align-to-equals (begin end) | |
"Align region to equal signs" | |
(interactive "r") | |
(align-regexp begin end | |
(rx (group (zero-or-more (syntax whitespace))) "=") 1 1 )) | |
(defun align-to-hash (begin end) | |
"Align region to hash ( => ) signs" | |
(interactive "r") | |
(align-regexp begin end | |
(rx (group (zero-or-more (syntax whitespace))) "=>") 1 1 )) | |
;; work with this | |
(defun align-to-comma-before (begin end) | |
"Align region to equal signs" | |
(interactive "r") | |
(align-regexp begin end | |
(rx (group (zero-or-more (syntax whitespace))) ",") 1 1 )) |
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
# Ruby example | |
# FROM: | |
class Demo | |
property :id, Ciao | |
property :demo, String | |
property :foo, Bar | |
end | |
# align-to-comma: | |
class Demo | |
property :id, Ciao | |
property :demo, String | |
property :foo, Bar | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment