From a1200aacad1c2c7df49c43dd9848268255262ae8 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 22 Nov 2011 14:24:50 +0000 Subject: [PATCH] Add alt-j command to join lines --- src/main.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main.cc b/src/main.cc index 9fa9cd69..f92df9f8 100644 --- a/src/main.cc +++ b/src/main.cc @@ -537,6 +537,16 @@ void do_split_regex(Window& window, int count) catch (prompt_aborted&) {} } +void do_join(Window& window, int count) +{ + window.multi_select(select_whole_lines); + window.select(select_to_eol, true); + window.multi_select(std::bind(select_all_matches, _1, "\n\\h*")); + window.replace(" "); + window.clear_selections(); + window.move_cursor({0, -1}); +} + std::unordered_map> keymap = { { 'h', [](Window& window, int count) { window.move_cursor(DisplayCoord(0, -std::max(count,1))); } }, @@ -614,6 +624,8 @@ std::unordered_map> alt_ke { 'H', [](Window& window, int count) { do { window.select(select_to_eol_reverse, true); } while(--count > 0); } }, { 's', do_split_regex }, + + { 'j', do_join }, }; int main(int argc, char* argv[])