Skip to content

Instantly share code, notes, and snippets.

@ankopainting
Created October 8, 2010 00:33
Show Gist options
  • Save ankopainting/616171 to your computer and use it in GitHub Desktop.
Save ankopainting/616171 to your computer and use it in GitHub Desktop.
class MoveNextLineCommand < DocumentCommand
def execute
doc = tab.edit_view.document
line_ix = doc.line_at_offset(doc.cursor_offset)
if line_ix == doc.line_count - 1
doc.cursor_offset = doc.length
else
doc.cursor_offset = doc.offset_at_line(line_ix + 1) - doc.delim.length
end
doc.ensure_visible(doc.cursor_offset)
doc.insert(doc.cursor_offset, "\n")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment