diff --git a/doc/DOCUMENTATION.org b/doc/DOCUMENTATION.org index 5464fc5d1..eae28b800 100644 --- a/doc/DOCUMENTATION.org +++ b/doc/DOCUMENTATION.org @@ -168,6 +168,7 @@ - [[#paste-transient-state][Paste transient state]] - [[#auto-indent-pasted-text][Auto-indent pasted text]] - [[#text-manipulation-commands][Text manipulation commands]] + - [[#drag-stuff-transient-state][Drag stuff transient state]] - [[#text-insertion-commands][Text insertion commands]] - [[#smartparens-strict-mode][Smartparens Strict mode]] - [[#zooming][Zooming]] @@ -2970,6 +2971,7 @@ Text related commands (start with ~x~): | Key binding | Description | |---------------+---------------------------------------------------------------| +| ~SPC x .~ | enter the drag stuff transient state | | ~SPC x TAB~ | indent or dedent a region rigidly | | ~SPC x a &~ | align region at & | | ~SPC x a (~ | align region at ( | @@ -3012,8 +3014,8 @@ Text related commands (start with ~x~): | ~SPC x j l~ | set the justification to left | | ~SPC x j n~ | set the justification to none | | ~SPC x j r~ | set the justification to right | -| ~SPC x J~ | move down a line of text (enter transient state) | -| ~SPC x K~ | move up a line of text (enter transient state) | +| ~SPC x J~ | drag down a line of text (enter drag stuff transient state) | +| ~SPC x K~ | drag up a line of text (enter drag stuff transient state) | | ~SPC x l d~ | duplicate line or region | | ~SPC x l r~ | randomize lines in region | | ~SPC x l s~ | sort lines | @@ -3034,6 +3036,17 @@ Text related commands (start with ~x~): | ~SPC x y~ | use avy to copy a link in the frame | | ~SPC x Y~ | use avy to copy multiple links in the frame | +**** Drag stuff transient state +The drag stuff transient state is opened with ~SPC x .~: + + | Key binding | Description | + |-------------------+-----------------------------| + | ~k~, ~K~, ~Up~ | drag up | + | ~j~, ~J~, ~Down~ | drag down | + | ~h~, ~H~, ~Left~ | drag left (word or region) | + | ~l~, ~L~, ~Right~ | drag right (word or region) | + | ~q~ | quit transient state | + *** Text insertion commands Text insertion commands (start with ~i~): diff --git a/layers/+distributions/spacemacs-bootstrap/packages.el b/layers/+distributions/spacemacs-bootstrap/packages.el index 0a89adf74..0c4f83a7d 100644 --- a/layers/+distributions/spacemacs-bootstrap/packages.el +++ b/layers/+distributions/spacemacs-bootstrap/packages.el @@ -132,8 +132,8 @@ ;; move selection up and down (when vim-style-visual-line-move-text - (define-key evil-visual-state-map "J" (concat ":m '>+1" (kbd "RET") "gv=gv")) - (define-key evil-visual-state-map "K" (concat ":m '<-2" (kbd "RET") "gv=gv"))) + (define-key evil-visual-state-map "J" 'drag-stuff-down) + (define-key evil-visual-state-map "K" 'drag-stuff-up)) (evil-ex-define-cmd "enew" 'spacemacs/new-empty-buffer) diff --git a/layers/+spacemacs/spacemacs-editing/packages.el b/layers/+spacemacs/spacemacs-editing/packages.el index 66162e02c..04bb3f023 100644 --- a/layers/+spacemacs/spacemacs-editing/packages.el +++ b/layers/+spacemacs/spacemacs-editing/packages.el @@ -15,6 +15,7 @@ (bracketed-paste :toggle (version<= emacs-version "25.0.92")) (clean-aindent-mode :toggle dotspacemacs-use-clean-aindent-mode) dired-quick-sort + drag-stuff editorconfig eval-sexp-fu expand-region @@ -114,6 +115,35 @@ :config (evil-define-key 'normal dired-mode-map "s" 'hydra-dired-quick-sort/body))) +(defun spacemacs-editing/init-drag-stuff () + (use-package drag-stuff + :defer t + :init + (drag-stuff-mode t) + (spacemacs|define-transient-state drag-stuff + :title "Drag Stuff Transient State" + :doc " +[_k_/_K_] up [_h_/_H_] left [_q_] quit +[_j_/_J_] down [_l_/_L_] right" + :bindings + ("j" drag-stuff-down) + ("J" drag-stuff-down) + ("" drag-stuff-down) + ("k" drag-stuff-up) + ("K" drag-stuff-up) + ("" drag-stuff-up) + ("h" drag-stuff-left) + ("H" drag-stuff-left) + ("" drag-stuff-left) + ("l" drag-stuff-right) + ("L" drag-stuff-right) + ("" drag-stuff-right) + ("q" nil :exit t)) + (spacemacs/set-leader-keys + "x." 'spacemacs/drag-stuff-transient-state/body + "xK" 'spacemacs/drag-stuff-transient-state/drag-stuff-up + "xJ" 'spacemacs/drag-stuff-transient-state/drag-stuff-down))) + (defun spacemacs-editing/init-editorconfig () (use-package editorconfig :init @@ -226,18 +256,7 @@ "ilp" 'lorem-ipsum-insert-paragraphs "ils" 'lorem-ipsum-insert-sentences)))) -(defun spacemacs-editing/init-move-text () - (use-package move-text - :defer t - :init - (spacemacs|define-transient-state move-text - :title "Move Text Transient State" - :bindings - ("J" move-text-down "move down") - ("K" move-text-up "move up")) - (spacemacs/set-leader-keys - "xJ" 'spacemacs/move-text-transient-state/move-text-down - "xK" 'spacemacs/move-text-transient-state/move-text-up))) +(defun spacemacs-editing/init-move-text ()) (defun spacemacs-editing/init-origami () (use-package origami diff --git a/layers/+spacemacs/spacemacs-evil/local/evil-unimpaired/evil-unimpaired.el b/layers/+spacemacs/spacemacs-evil/local/evil-unimpaired/evil-unimpaired.el index 9146409bf..edf2a954c 100644 --- a/layers/+spacemacs/spacemacs-evil/local/evil-unimpaired/evil-unimpaired.el +++ b/layers/+spacemacs/spacemacs-evil/local/evil-unimpaired/evil-unimpaired.el @@ -85,12 +85,10 @@ 'evil-unimpaired/insert-space-above) (define-key evil-normal-state-map (kbd "] SPC") 'evil-unimpaired/insert-space-below) -(define-key evil-normal-state-map (kbd "[ e") 'move-text-up) -(define-key evil-normal-state-map (kbd "] e") 'move-text-down) -(define-key evil-visual-state-map (kbd "[ e") ":move'<--1") -(define-key evil-visual-state-map (kbd "] e") ":move'>+1") -;; (define-key evil-visual-state-map (kbd "[ e") 'move-text-up) -;; (define-key evil-visual-state-map (kbd "] e") 'move-text-down) +(define-key evil-normal-state-map (kbd "[ e") 'drag-stuff-up) +(define-key evil-normal-state-map (kbd "] e") 'drag-stuff-down) +(define-key evil-visual-state-map (kbd "[ e") 'drag-stuff-up) +(define-key evil-visual-state-map (kbd "] e") 'drag-stuff-down) ;; navigation (define-key evil-motion-state-map (kbd "[ b") 'previous-buffer) (define-key evil-motion-state-map (kbd "] b") 'next-buffer)