Skip to content

Instantly share code, notes, and snippets.

@1024jp
Created November 22, 2014 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1024jp/c49ef0c37097f528f1bd to your computer and use it in GitHub Desktop.
Save 1024jp/c49ef0c37097f528f1bd to your computer and use it in GitHub Desktop.
Insert new line below current line
(*
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