Created
February 28, 2020 23:03
-
-
Save ruliana/196c87b97f69d6dd82ed59043840ce31 to your computer and use it in GitHub Desktop.
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
(defvar ronie/god-tab-mode-map (make-sparse-keymap)) | |
(define-minor-mode ronie/god-tab-mode | |
"Make <tab> a 'god key' for editing code, according to the context and my preferences ;p" | |
:lighter " GT" | |
:keymap ronie/god-tab-mode-map | |
(if (bound-and-true-p ronie/god-tab-mode) | |
(message "Jumper mode activated!") | |
(message "Jumper mode deactivated!"))) | |
(evil-define-key '(insert normal) ronie/god-tab-mode-map (kbd "<tab>") 'ronie/jump-forward) | |
(evil-define-key '(insert normal) ronie/god-tab-mode-map (kbd "S-<tab>") 'ronie/jump-backward) | |
(evil-define-key 'visual ronie/god-tab-mode-map (kbd "<tab>") 'ronie/indent-region) | |
(defun ronie/indent-region () | |
"Indent the selected region" | |
(interactive) | |
(indent-region (region-beginning) (region-end))) | |
(defun ronie/jump-forward () | |
"Jump out of nested parenthesis or after quotes and comas." | |
(interactive) | |
(cond ((and (bolp) (looking-at "[[:blank:]]*$")) | |
(indent-according-to-mode)) | |
((and (bolp) (looking-at "[[:blank:]]+[^[:blank:]]")) | |
(indent-according-to-mode)) | |
((and (looking-at "[[:blank:]]") (looking-back "[[:blank:]]+" (line-beginning-position))) | |
(indent-according-to-mode)) | |
(t | |
(re-search-forward "['\",]\\|[][)(}{]+")))) | |
(defun ronie/jump-backward () | |
"Jump out of nested parenthesis or before quotes and comas." | |
(interactive) | |
(re-search-backward "['\",]\\|[][)(}{]+")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment