Skip to content

Commit

Permalink
C for vi mode (#472)
Browse files Browse the repository at this point in the history
  • Loading branch information
otavioschwanck authored Feb 11, 2024
1 parent d3a324d commit d197be7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2563,6 +2563,13 @@ def finish
end
alias_method :kill_line, :ed_kill_line

# Editline:: +vi_change_to_eol+ (vi command: +C+) + Kill and change from the cursor to the end of the line.
private def vi_change_to_eol(key)
ed_kill_line(key)

@config.editing_mode = :vi_insert
end

# Editline:: +vi-kill-line-prev+ (vi: +Ctrl-U+) Delete the string from the
# beginning of the edit buffer to the cursor and save it to the
# cut buffer.
Expand Down
10 changes: 10 additions & 0 deletions test/reline/test_key_actor_vi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1455,6 +1455,16 @@ def test_vi_kill_line_prev
assert_line('c')
end

def test_vi_change_to_eol
input_keys("abcdef\C-[2hC")
assert_line("abc")
input_keys("\C-[0C")
assert_line("")
assert_cursor(0)
assert_cursor_max(0)
assert_instance_of(Reline::KeyActor::ViInsert, @config.editing_mode)
end

def test_vi_motion_operators
assert_instance_of(Reline::KeyActor::ViInsert, @config.editing_mode)

Expand Down

0 comments on commit d197be7

Please sign in to comment.