Last active
August 29, 2015 14:10
-
-
Save 1024jp/6f1a28df9c2caf0f0104 to your computer and use it in GitHub Desktop.
Insert new line above current line
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
(* | |
Insert new line above current line | |
[version] 1.0.0 | |
[release] 2014-11-22 | |
[author] 1024jp <http://wolfrosch.com/> | |
[licence] MIT License | |
*) | |
tell application "CotEditor" | |
if not (exists front document) then return | |
tell front document | |
-- get current selection range | |
set {loc, len} to range of selection | |
set {lineLoc, lineLen} to line range of selection | |
-- select whole line | |
set line range of selection to {lineLoc, lineLen} | |
-- insert a new line before selection | |
set contents of selection to ("\n" & contents of selection) | |
-- reset selection | |
set range of selection to {loc + 1, len} | |
end tell | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment