diff --git a/doc_src/bind.txt b/doc_src/bind.txt index 813026c3b..9b1f34a09 100644 --- a/doc_src/bind.txt +++ b/doc_src/bind.txt @@ -75,6 +75,8 @@ The following special input functions are available: - `beginning-of-line`, move to the beginning of the line +- `begin-selection`, start selecting text + - `capitalize-word`, make the current word begin with a capital letter - `complete`, guess the remainder of the current token @@ -93,6 +95,8 @@ The following special input functions are available: - `end-of-line`, move to the end of the line +- `end-selection`, end selecting text + - `explain`, print a description of possible problems with the current command - `forward-bigword`, move one whitespace-delimited word to the right @@ -109,12 +113,16 @@ The following special input functions are available: - `kill-line`, move everything from the cursor to the end of the line to the killring +- `kill-selection`, move the selected text to the killring + - `kill-whole-line`, move the line to the killring - `kill-word`, move the next word to the killring - `suppress-autosuggestion`, remove the current autosuggestion +- `swap-selection-start-stop`, go to the other end of the highlighted text without changing the selection + - `transpose-chars`, transpose two characters to the left of the cursor - `transpose-words`, transpose two words to the left of the cursor diff --git a/share/functions/fish_vi_key_bindings.fish b/share/functions/fish_vi_key_bindings.fish index 10551832f..de0f8bd6e 100644 --- a/share/functions/fish_vi_key_bindings.fish +++ b/share/functions/fish_vi_key_bindings.fish @@ -200,6 +200,7 @@ function fish_vi_key_bindings --description 'vi-like key bindings for fish' bind -M visual W forward-bigword bind -M visual e forward-word bind -M visual E forward-bigword + bind -M visual o swap-selection-start-stop force-repaint for key in $eol_keys bind -M visual $key end-of-line diff --git a/src/input.cpp b/src/input.cpp index c3e26815b..b4277724b 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -132,6 +132,7 @@ static const wchar_t * const name_arr[] = L"suppress-autosuggestion", L"accept-autosuggestion", L"begin-selection", + L"swap-selection-start-stop", L"end-selection", L"kill-selection", L"forward-jump", @@ -242,6 +243,7 @@ static const wchar_t code_arr[] = R_SUPPRESS_AUTOSUGGESTION, R_ACCEPT_AUTOSUGGESTION, R_BEGIN_SELECTION, + R_SWAP_SELECTION_START_STOP, R_END_SELECTION, R_KILL_SELECTION, R_FORWARD_JUMP, diff --git a/src/input_common.h b/src/input_common.h index e605d18b7..8f4cdd52a 100644 --- a/src/input_common.h +++ b/src/input_common.h @@ -68,6 +68,7 @@ enum R_SUPPRESS_AUTOSUGGESTION, R_ACCEPT_AUTOSUGGESTION, R_BEGIN_SELECTION, + R_SWAP_SELECTION_START_STOP, R_END_SELECTION, R_KILL_SELECTION, R_FORWARD_JUMP, diff --git a/src/reader.cpp b/src/reader.cpp index a7e8ec7e5..50c8c93d4 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -4026,6 +4026,17 @@ const wchar_t *reader_readline(int nchars) break; } + case R_SWAP_SELECTION_START_STOP: + { + if (!data->sel_active) break; + size_t tmp = data->sel_begin_pos; + data->sel_begin_pos = data->command_line.position; + data->sel_start_pos = data->command_line.position; + editable_line_t *el = data->active_edit_line(); + update_buff_pos(el, tmp); + break; + } + case R_END_SELECTION: { data->sel_active = false;