Skip to content

Commit d197be7

Browse files
C for vi mode (#472)
1 parent d3a324d commit d197be7

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lib/reline/line_editor.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2563,6 +2563,13 @@ def finish
25632563
end
25642564
alias_method :kill_line, :ed_kill_line
25652565

2566+
# Editline:: +vi_change_to_eol+ (vi command: +C+) + Kill and change from the cursor to the end of the line.
2567+
private def vi_change_to_eol(key)
2568+
ed_kill_line(key)
2569+
2570+
@config.editing_mode = :vi_insert
2571+
end
2572+
25662573
# Editline:: +vi-kill-line-prev+ (vi: +Ctrl-U+) Delete the string from the
25672574
# beginning of the edit buffer to the cursor and save it to the
25682575
# cut buffer.

test/reline/test_key_actor_vi.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,16 @@ def test_vi_kill_line_prev
14551455
assert_line('c')
14561456
end
14571457

1458+
def test_vi_change_to_eol
1459+
input_keys("abcdef\C-[2hC")
1460+
assert_line("abc")
1461+
input_keys("\C-[0C")
1462+
assert_line("")
1463+
assert_cursor(0)
1464+
assert_cursor_max(0)
1465+
assert_instance_of(Reline::KeyActor::ViInsert, @config.editing_mode)
1466+
end
1467+
14581468
def test_vi_motion_operators
14591469
assert_instance_of(Reline::KeyActor::ViInsert, @config.editing_mode)
14601470

0 commit comments

Comments
 (0)