Skip to content

Commit

Permalink
Partially fixed G command.
Browse files Browse the repository at this point in the history
  • Loading branch information
nakagami committed Jul 7, 2024
1 parent a79c2f0 commit 15a4deb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pyvim/key_bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,18 @@ def to_parent_directory(event):
new_path, show_in_current_window=True)
editor.sync_with_prompt_toolkit()

@kb.add("G", filter=vi_navigation_mode)
def to_nth_line(event):
# I don't know why, but the default behaviour of the prompt toolkit is that <number>G does not work well.
# With this implementation, 1G same as G and moves to the end of the line.
# I don't know how to fix it, so please use gg instead of 1G when moving to the first line
buf = event.current_buffer
count = (buf.document.line_count if event.arg == 1 else event.arg -1) - buf.document.cursor_position_row
if count > 0:
buf.auto_down(count=count, go_to_start_of_line_if_history_changes=True)
elif count < 0:
buf.auto_up(count=-count, go_to_start_of_line_if_history_changes=True)

return kb


Expand Down

0 comments on commit 15a4deb

Please sign in to comment.