Created
November 22, 2014 09:53
-
-
Save 1024jp/c49ef0c37097f528f1bd to your computer and use it in GitHub Desktop.
Insert new line below 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 below 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 after selection | |
set contents of selection to (contents of selection & "\n") | |
-- reset selection | |
set range of selection to {loc, len} | |
end tell | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment