From 4b7e77ae000083ad0eb2400e03738ebe7453db14 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 3 Sep 2018 22:15:28 +1000 Subject: [PATCH] Change line editing bindings to match readline's In the end, no better solution materialized so far, and custom Kakoune line editing bindings are hard to remember. Using well known readline bindings seems just more convenient. Closes #800, although it does not contain all the binding proposed by it (I might accept a few additional ones, such as , but not too much, I still see that as a hack pending a nicer solution). --- doc/pages/keys.asciidoc | 24 ++++++++++++------------ src/input_handler.cc | 24 ++++++++++++------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/doc/pages/keys.asciidoc b/doc/pages/keys.asciidoc index f55b58428..7f66d3d50 100644 --- a/doc/pages/keys.asciidoc +++ b/doc/pages/keys.asciidoc @@ -679,40 +679,40 @@ The following keys are recognized by this mode to help with editing (See <*:: abandon without -**, **:: +**, **:: move cursor to previous character -**, **:: +**, **:: move cursor to next character -**:: +**, **:: move cursor to first character -**:: +**, *:: move cursor past the last character -**, **:: +**, **:: erase character before cursor -**, **:: +**, **:: erase character under cursor -**:: +**:: advance to next word begin -**:: +**:: advance to next WORD begin -**:: +**:: go back to previous word begin -**:: +**:: go back to previous WORD begin -**:: +**:: advance to next word end -**:: +**:: advance to next word end **, **:: diff --git a/src/input_handler.cc b/src/input_handler.cc index 260dbf308..df63933c8 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -437,21 +437,21 @@ public: void handle_key(Key key) { - if (key == Key::Left or key == alt('h')) + if (key == Key::Left or key == ctrl('b')) { if (m_cursor_pos > 0) --m_cursor_pos; } - else if (key == Key::Right or key == alt('l')) + else if (key == Key::Right or key == ctrl('f')) { if (m_cursor_pos < m_line.char_length()) ++m_cursor_pos; } - else if (key == Key::Home) + else if (key == Key::Home or key == ctrl('a')) m_cursor_pos = 0; - else if (key == Key::End) + else if (key == Key::End or key == ctrl('e')) m_cursor_pos = m_line.char_length(); - else if (key == Key::Backspace or key == alt('x')) + else if (key == Key::Backspace or key == ctrl('h')) { if (m_cursor_pos != 0) { @@ -461,23 +461,23 @@ public: --m_cursor_pos; } } - else if (key == Key::Delete or key == alt('d')) + else if (key == Key::Delete or key == ctrl('d')) { if (m_cursor_pos != m_line.char_length()) m_line = m_line.substr(0, m_cursor_pos) + m_line.substr(m_cursor_pos+1); } - else if (key == ctrl('w')) + else if (key == alt('f')) to_next_word_begin(m_cursor_pos, m_line); - else if (key == ctrl(alt('w'))) + else if (key == alt('W')) to_next_word_begin(m_cursor_pos, m_line); - else if (key == ctrl('b')) + else if (key == alt('b')) to_prev_word_begin(m_cursor_pos, m_line); - else if (key == ctrl(alt('b'))) + else if (key == alt('B')) to_prev_word_begin(m_cursor_pos, m_line); - else if (key == ctrl('e')) + else if (key == alt('e')) to_next_word_end(m_cursor_pos, m_line); - else if (key == ctrl(alt('e'))) + else if (key == alt('E')) to_next_word_end(m_cursor_pos, m_line); else if (key == ctrl('k')) m_line = m_line.substr(0_char, m_cursor_pos).str();