/README.md

https://github.com/ddrscott/vim-side-search · Markdown · 89 lines · 67 code · 22 blank · 0 comment · 0 complexity · 66605603accb6b941ea742e46d00fcfd MD5 · raw file

  1. ## Overview
  2. The `quickfix` window is great, but it would be nice to get some context around
  3. our searches. This plugin adds `rg` output to a side buffer with quick
  4. navigation mappings using comfortable Vim conventions.
  5. ![Simple Demo](side-search-demo.gif)
  6. ## Features
  7. - step through `rg` output instead of `quickfix` output
  8. - syntax highlighting of `rg` output
  9. - mappable to search current word under the cursor
  10. - configurable `g:side_search_prg` similar to `grepprg`
  11. - vertical or horizontal split output via `g:side_search_splitter`
  12. ## Buffer Mappings
  13. ```
  14. n/N - Cursor to next/prev
  15. <C-n>/<C-p> - Open next/prev
  16. <CR>|<DblClick> - Open at cursor
  17. <C-w><CR> - Open and jump to window
  18. qf - :grep! to Quickfix
  19. ```
  20. ## Prerequisites
  21. We rely on [The Silver Searcher](https://github.com/ggreer/the_silver_searcher)
  22. to perform our file/text searches for us. Theoretically, any program which has
  23. the same output could also work, but that we only test using `rg` output.
  24. To install `rg` command on OSX:
  25. ```sh
  26. brew install ripgrep
  27. ```
  28. Refer to [Ripgrep](https://github.com/BurntSushi/ripgrep) for more instructions.
  29. ## Global Configuration
  30. ```vim
  31. " How should we execute the search?
  32. " --heading and --stats are required!
  33. let g:side_search_prg = 'rg --word-regexp'
  34. \. " --ignore='*.js.map'"
  35. \. " --heading --stats -B 1 -A 4"
  36. \. " --case-sensitive"
  37. \. " --line-number"
  38. " Can use `vnew` or `new`
  39. let g:side_search_splitter = 'vnew'
  40. " I like 40% splits, change it if you don't
  41. let g:side_search_split_pct = 0.4
  42. ```
  43. ## Suggested Mapping
  44. ```vim
  45. " SideSearch current word and return to original window
  46. nnoremap <Leader>ss :SideSearch <C-r><C-w><CR> | wincmd p
  47. " Create an shorter `SS` command
  48. command! -complete=file -nargs=+ SS execute 'SideSearch <args>'
  49. " or command abbreviation
  50. cabbrev SS SideSearch
  51. ```
  52. ## FAQ
  53. > How to search for multi-word terms?
  54. Surround terms with double quotes
  55. ```
  56. :SideSearch "cats and dogs"
  57. ```
  58. > How to pass extra args to `rg`?
  59. Just do it :)
  60. ```
  61. :SideSearch -t js MyAwesomeComponent
  62. ```
  63. > What happened to using The Silver Searcher?
  64. The `ag` program was deprecated back in 2016. https://github.com/rking/ag.vim/issues/124
  65. We moved to `ripgrep` as a modern alternative.
  66. Ultimately, any program can be used by setting `g:side_search_prg` and has output matching out syntax highlighter should
  67. work.