mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-29 06:13:20 +00:00
Implement o and O bindings for vi mode
Credit to @joallard for the patch. Fixes #7442
This commit is contained in:
parent
7e7355bde1
commit
2d2efc8b2e
4 changed files with 26 additions and 0 deletions
|
@ -80,6 +80,8 @@ function fish_vi_key_bindings --description 'vi-like key bindings for fish'
|
|||
bind -s --preset -M default l forward-char
|
||||
bind -s --preset -m insert \n execute
|
||||
bind -s --preset -m insert \r execute
|
||||
bind -s --preset -m insert o insert-line-under repaint-mode
|
||||
bind -s --preset -m insert O insert-line-above repaint-mode
|
||||
bind -s --preset -m insert i repaint-mode
|
||||
bind -s --preset -m insert I beginning-of-line repaint-mode
|
||||
bind -s --preset -m insert a forward-single-char repaint-mode
|
||||
|
|
|
@ -140,6 +140,8 @@ static const input_function_metadata_t input_function_metadata[] = {
|
|||
{readline_cmd_t::swap_selection_start_stop, L"swap-selection-start-stop"},
|
||||
{readline_cmd_t::end_selection, L"end-selection"},
|
||||
{readline_cmd_t::kill_selection, L"kill-selection"},
|
||||
{readline_cmd_t::insert_line_under, L"insert-line-under"},
|
||||
{readline_cmd_t::insert_line_above, L"insert-line-above"},
|
||||
{readline_cmd_t::forward_jump, L"forward-jump"},
|
||||
{readline_cmd_t::backward_jump, L"backward-jump"},
|
||||
{readline_cmd_t::forward_jump_till, L"forward-jump-till"},
|
||||
|
|
|
@ -65,6 +65,8 @@ enum class readline_cmd_t {
|
|||
swap_selection_start_stop,
|
||||
end_selection,
|
||||
kill_selection,
|
||||
insert_line_under,
|
||||
insert_line_above,
|
||||
forward_jump,
|
||||
backward_jump,
|
||||
forward_jump_till,
|
||||
|
|
|
@ -3590,6 +3590,26 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
|
|||
}
|
||||
break;
|
||||
}
|
||||
case rl::insert_line_above: {
|
||||
editable_line_t *el = active_edit_line();
|
||||
while (el->position() > 0 && el->text().at(el->position() - 1) != L'\n') {
|
||||
update_buff_pos(el, el->position() - 1);
|
||||
}
|
||||
insert_char(el, L'\n');
|
||||
update_buff_pos(el, el->position() - 1);
|
||||
break;
|
||||
}
|
||||
case rl::insert_line_under: {
|
||||
editable_line_t *el = active_edit_line();
|
||||
if (el->position() < el->size()) {
|
||||
const wchar_t *buff = el->text().c_str();
|
||||
while (buff[el->position()] && buff[el->position()] != L'\n') {
|
||||
update_buff_pos(el, el->position() + 1);
|
||||
}
|
||||
}
|
||||
insert_char(el, L'\n');
|
||||
break;
|
||||
}
|
||||
case rl::forward_jump:
|
||||
case rl::backward_jump:
|
||||
case rl::forward_jump_till:
|
||||
|
|
Loading…
Reference in a new issue