From b457afe9c0fc54671ed56fb642c17681d48e095c Mon Sep 17 00:00:00 2001 From: Jonathan Dumaine Date: Sat, 8 Dec 2018 23:29:55 -0700 Subject: [PATCH] Add a tidbit about useful mapping function to README.md FAQ --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index 378fc3e3..2e9d389d 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,30 @@ the convention of Vim's built-in `:grep` and `:make` commands. [The Silver Searcher]: https://github.com/ggreer/the_silver_searcher [sadface]: https://github.com/mileszs/ack.vim/commit/d97090fb502d40229e6976dfec0e06636ba227d5#commitcomment-5771145 +#### How do I use this in a mapping? #### + +Call one of Ack.vim's defined functions from a map: + +```vim +map :Ack! +``` + +Or use + +```vim +function! Search () + if empty(@/) + call feedkeys(':Ack! ') + else + :AckFromSearch! + endif +endfunction + +map :call Search() +``` + +to automatically search for the highlighted text (the `@/` register contains highlighted text) or start a prompt for the text to search for. + ## Changelog Please see [the GitHub releases page][releases].