Skip to content

Commit

Permalink
Add helper to go to the middle of a line (talonhub#1424)
Browse files Browse the repository at this point in the history
Adds a line command `[go] line mid` which is similar to vim's `gm` command and
moves the cursor to the middle of the line.

---------

Co-authored-by: Nicholas Riley <com-github@sabi.net>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 4, 2024
1 parent 235bba4 commit 47c2257
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions core/edit/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,11 @@ def delete_line_end():
"""Delete to end of current line"""
actions.user.select_line_end()
actions.edit.delete()

def line_middle():
"""Go to the middle of the line"""
actions.edit.select_line()
half_line_length = int(len(actions.edit.selected_text()) / 2)
actions.edit.left()
for i in range(0, half_line_length):
actions.edit.right()
2 changes: 2 additions & 0 deletions core/edit/edit.talon
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,5 @@ redo that: edit.redo()
# Save
file save: edit.save()
file save all: edit.save_all()

[go] line mid: user.line_middle()

0 comments on commit 47c2257

Please sign in to comment.