diff options
| author | Teddy Wing | 2018-04-07 15:06:28 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2018-04-07 15:06:28 +0200 | 
| commit | 436edddb3a60e654427ac37b4f426e533754af86 (patch) | |
| tree | 1ddd8a12bcc7b0a098b43dc3bbf1c4ab8669d1d3 /plugin | |
| download | vim-tabs-grep-436edddb3a60e654427ac37b4f426e533754af86.tar.bz2 | |
Initial ideas for TabsGrep
Repurposed some code from my LsGrep plugin. We grab output from `:tabs`
and run it through a filter to get only the matching file names.
We also want to include the "Tab page 1" lines, so these need to be
filtered specially.
Diffstat (limited to 'plugin')
| -rw-r--r-- | plugin/tabs_grep.vim | 27 | 
1 files changed, 27 insertions, 0 deletions
| diff --git a/plugin/tabs_grep.vim b/plugin/tabs_grep.vim new file mode 100644 index 0000000..8860ad1 --- /dev/null +++ b/plugin/tabs_grep.vim @@ -0,0 +1,27 @@ +" function! tabs_grep#TabsGrep(search) +function! TabsGrep(search) +	redir => tabs_output +	silent tabs +	redir END + +	let tabs = split(tabs_output) + +	call filter(tabs, function('s:MatchString', [a:search])) +	echo tabs + +	" let filtered_tabs = system( +	" 	\ 'echo ' +	" 	\ . shellescape(tabs_output) +	" 	\ . " | grep -i " +	" 	\ . shellescape(a:search) +	" \ ) +    " +	" echo filtered_tabs +endfunction + +function! s:MatchString(index, value, search) +	return match(a:value, a:search) != -1 || +		\ match(a:value, '\vTab page \d+') != -1 +endfunction + +command! -nargs=1 TabsGrep :call TabsGrep(<f-args>) | 
