From 1f2873c7e7632628f3f8ab3371ec6ed76f88a82c Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Fri, 23 Jun 2017 00:11:15 +0800 Subject: [PATCH] Add SPC s * mappings for searching --- autoload/SpaceVim/mapping/space.vim | 27 +++++++++++++++++++++++++++ config/plugins/unite.vim | 1 + docs/documentation.md | 18 ++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim index 36dfe842a..138f0702d 100644 --- a/autoload/SpaceVim/mapping/space.vim +++ b/autoload/SpaceVim/mapping/space.vim @@ -73,6 +73,33 @@ function! SpaceVim#mapping#space#init() abort call SpaceVim#mapping#space#def('nnoremap', ['b', 'b'], 'Unite buffer', 'buffer list', 1) call extend(g:_spacevim_mappings_prefixs['[SPC]'], get(g:, '_spacevim_mappings_space', {})) call SpaceVim#mapping#space#def('nnoremap', ['r', 'l'], 'Unite resume', 'resume unite buffer', 1) + + " Searching in current buffer + call SpaceVim#mapping#space#def('nnoremap', ['s', 's'], 'Unite line', 'grep in current buffer', 1) + call SpaceVim#mapping#space#def('nnoremap', ['s', 'S'], "execute 'Unite grep:%::' . expand(\"\") . ' -start-insert'", + \ 'grep cursor word in current buffer', 1) + " Searching in all loaded buffers + call SpaceVim#mapping#space#def('nnoremap', ['s', 'b'], 'Unite grep:$buffers', 'grep in all loaded buffers', 1) + call SpaceVim#mapping#space#def('nnoremap', ['s', 'B'], "execute 'Unite grep:$buffers::' . expand(\"\") . ' -start-insert'", + \ 'grep cursor word in all loaded buffers', 1) + " Searching in files in an arbitrary directory + call SpaceVim#mapping#space#def('nnoremap', ['s', 'f'], 'Unite grep', 'grep in arbitrary directory', 1) + call SpaceVim#mapping#space#def('nnoremap', ['s', 'F'], "execute 'Unite grep:::' . expand(\"\") . ' -start-insert'", + \ 'grep in arbitrary directory', 1) + " Searching in project + call SpaceVim#mapping#space#def('nnoremap', ['s', 'p'], 'Unite grep:.', 'grep in project', 1) + call SpaceVim#mapping#space#def('nnoremap', ['s', 'P'], "execute 'Unite grep:.::' . expand(\"\") . ' -start-insert'", + \ 'grep in project', 1) + + " Searching tools + " ag + let g:_spacevim_mappings_space.s.a = {'name' : '+ag'} + let g:_spacevim_mappings_space.s.g = {'name' : '+grep'} + let g:_spacevim_mappings_space.s.k = {'name' : '+ack'} + let g:_spacevim_mappings_space.s.r = {'name' : '+rg'} + let g:_spacevim_mappings_space.s.t = {'name' : '+pt'} + + endfunction function! SpaceVim#mapping#space#def(m, keys, cmd, desc, is_cmd) abort diff --git a/config/plugins/unite.vim b/config/plugins/unite.vim index 4e6e0fd57..1954096ee 100644 --- a/config/plugins/unite.vim +++ b/config/plugins/unite.vim @@ -306,6 +306,7 @@ augroup unite_buffer_feature augroup END function! s:unite_my_settings() " Overwrite settings. + setlocal nowrap " Play nice with supertab let b:SuperTabDisabled=1 diff --git a/docs/documentation.md b/docs/documentation.md index e9e0559ff..300d82dd6 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -70,6 +70,7 @@ title: "Documentation" * [With an external tool](#with-an-external-tool) * [Useful key bindings](#useful-key-bindings) * [Searching in current file](#searching-in-current-file) + * [Searching in all loaded buffers](#searching-in-all-loaded-buffers) * [Editing](#editing) * [Multi-Encodings](#multi-encodings) * [Errors handling](#errors-handling) @@ -980,6 +981,23 @@ Key Binding Description `SPC s r r` | rg `SPC s r R` | rg with default input +#### Searching in all loaded buffers + +Key Binding Description +-----------| ----------- +`SPC s b` | search with the first found tool +`SPC s B` | search with the first found tool with default input +`SPC s a b` | ag +`SPC s a B` | ag with default input +`SPC s g b` | grep +`SPC s g B` | grep with default input +`SPC s k b` | ack +`SPC s k B` | ack with default input +`SPC s r b` | rg +`SPC s r B` | rg with default input +`SPC s t b` | pt +`SPC s t B` | pt with default input + ### Editing #### Multi-Encodings