Search: save last search to '/' register and bind n to repeat last search
This commit is contained in:
parent
1f0b06a855
commit
53c9021857
15
src/main.cc
15
src/main.cc
|
@ -348,11 +348,25 @@ void do_search(Window& window)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::string ex = prompt("/");
|
std::string ex = prompt("/");
|
||||||
|
if (ex.empty())
|
||||||
|
ex = RegisterManager::instance()['/'];
|
||||||
|
else
|
||||||
|
RegisterManager::instance()['/'] = ex;
|
||||||
|
|
||||||
window.select(false, RegexSelector(ex));
|
window.select(false, RegexSelector(ex));
|
||||||
}
|
}
|
||||||
catch (prompt_aborted&) {}
|
catch (prompt_aborted&) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void do_search_next(Window& window)
|
||||||
|
{
|
||||||
|
std::string& ex = RegisterManager::instance()['/'];
|
||||||
|
if (not ex.empty())
|
||||||
|
window.select(false, RegexSelector(ex));
|
||||||
|
else
|
||||||
|
print_status("no search pattern");
|
||||||
|
}
|
||||||
|
|
||||||
void do_yank(Window& window, int count)
|
void do_yank(Window& window, int count)
|
||||||
{
|
{
|
||||||
RegisterManager::instance()['"'] = window.selection_content();
|
RegisterManager::instance()['"'] = window.selection_content();
|
||||||
|
@ -405,6 +419,7 @@ std::unordered_map<char, std::function<void (Window& window, int count)>> keymap
|
||||||
{ 'm', [](Window& window, int count) { window.select(false, select_matching); } },
|
{ 'm', [](Window& window, int count) { window.select(false, select_matching); } },
|
||||||
{ 'M', [](Window& window, int count) { window.select(true, select_matching); } },
|
{ 'M', [](Window& window, int count) { window.select(true, select_matching); } },
|
||||||
{ '/', [](Window& window, int count) { do_search(window); } },
|
{ '/', [](Window& window, int count) { do_search(window); } },
|
||||||
|
{ 'n', [](Window& window, int count) { do_search_next(window); } },
|
||||||
{ 'u', [](Window& window, int count) { do { if (not window.undo()) { print_status("nothing left to undo"); break; } } while(--count > 0); } },
|
{ 'u', [](Window& window, int count) { do { if (not window.undo()) { print_status("nothing left to undo"); break; } } while(--count > 0); } },
|
||||||
{ 'U', [](Window& window, int count) { do { if (not window.redo()) { print_status("nothing left to redo"); break; } } while(--count > 0); } },
|
{ 'U', [](Window& window, int count) { do { if (not window.redo()) { print_status("nothing left to redo"); break; } } while(--count > 0); } },
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user