mirror of
https://github.com/magnars/multiple-cursors.el.git
synced 2025-10-13 05:03:03 +00:00
Added vertical align commands
Squashed commit of the following: commit 243a14e69501bf938eea54449782f43be2084ef2 Author: Patrick Seebauer <patrick.seebuaer@web.de> Date: Fri Sep 5 18:06:19 2014 +0200 removed uniq line check and added warning in the docs about cursors on the same line. commit 438658ef0358b0a1540c2663aedba0253150a007 Author: Patrick Seebauer <patrick.seebuaer@web.de> Date: Fri Sep 5 17:59:55 2014 +0200 fixed tests for commands with character inputs commit c565969c6bb01e37ec42cfe311ada87643e38ccc Author: Patrick Seebauer <patrick.seebuaer@web.de> Date: Fri Sep 5 17:36:41 2014 +0200 renamed to vertical align, added non-whitespace option commit 941c40a319f571680017293681ff7d796ba4e1f4 Author: Patrick Seebauer <patrick.seebuaer@web.de> Date: Fri Sep 5 16:58:14 2014 +0200 added test commit d9a4a55ebde9b51c3f62b14948529759aaaa9bf6 Author: Patrick Seebauer <patrick.seebuaer@web.de> Date: Tue Sep 2 19:32:49 2014 +0200 added interactives, added abort if cursors are on the same line commit 12d01fe4db5109061533b0524d99177d1204eb85 Author: Patrick Seebauer <patrick.seebuaer@web.de> Date: Tue Sep 2 18:55:47 2014 +0200 some adjustments commit 9fddf98b6cd1bb68c334ab46fe1c9bcc08397796 Author: Patrick Seebauer <patrick.seebuaer@web.de> Date: Tue Sep 2 18:47:39 2014 +0200 rough sketch
This commit is contained in:
parent
f3daf86bd6
commit
7ddda8527b
27
features/vertical-align.feature
Normal file
27
features/vertical-align.feature
Normal file
@ -0,0 +1,27 @@
|
||||
Feature: Align cursors with whitespaces
|
||||
|
||||
Scenario: Vertical aligning with `x'
|
||||
Given I have cursors at "word" in :
|
||||
"""
|
||||
One word
|
||||
Another word
|
||||
"""
|
||||
And I press "<<mc/vertical-align>> \170"
|
||||
Then I should see:
|
||||
"""
|
||||
One xxxxword
|
||||
Another word
|
||||
"""
|
||||
|
||||
Scenario: Vertical aligning with space
|
||||
Given I have cursors at "word" in :
|
||||
"""
|
||||
One word
|
||||
Another word
|
||||
"""
|
||||
And I press "<<mc/vertical-align-with-space>>"
|
||||
Then I should see:
|
||||
"""
|
||||
One word
|
||||
Another word
|
||||
"""
|
@ -86,5 +86,37 @@
|
||||
(setq mc--strings-to-replace (sort (mc--ordered-region-strings) 'string<))
|
||||
(mc--replace-region-strings))
|
||||
|
||||
|
||||
;;;###autoload
|
||||
(defun mc/vertical-align (character)
|
||||
"Aligns all cursors vertically with a given CHARACTER to the one with the
|
||||
highest colum number (the rightest)
|
||||
Aborts if the some cursors are on the same line.
|
||||
Might not behave as intended if more than one cursors are on the same line."
|
||||
(interactive "c")
|
||||
(let ((rightest-column (current-column)))
|
||||
(mc/execute-command-for-all-cursors
|
||||
(lambda () "get the rightest cursor"
|
||||
(interactive)
|
||||
(setq rightest-column (max (current-column) rightest-column))
|
||||
))
|
||||
(mc/execute-command-for-all-cursors
|
||||
(lambda ()
|
||||
(interactive)
|
||||
(let ((missing-spaces (- rightest-column (current-column))))
|
||||
(save-excursion (insert (make-string missing-spaces character)))
|
||||
(forward-char missing-spaces)
|
||||
)
|
||||
))
|
||||
)
|
||||
)
|
||||
|
||||
;;;###autoload
|
||||
(defun mc/vertical-align-with-space ()
|
||||
"Aligns all cursors with whitespace like `mc/vertical-align' does"
|
||||
(interactive)
|
||||
(mc/vertical-align 32)
|
||||
)
|
||||
|
||||
(provide 'mc-separate-operations)
|
||||
;;; mc-separate-operations.el ends here
|
||||
|
Loading…
x
Reference in New Issue
Block a user