Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

use vim's search pattern in Tabularize #19

Open
wants to merge 1 commit into from

2 participants

@jceb
  • also set vim's search pattern when a pattern was provided to Tabularize
  • this makes :Tabularize behave more like a tightly integrated vim feature, e.g. :g
@jceb jceb use vim's search pattern if no pattern is specified
- also set vim's search pattern when a pattern was provided to Tabularize
- this makes :Tabularize behave more like a tightly integrated vim feature, e.g. :g
72d9197
@godlygeek
Owner

I'm considering this. I'm not sure if this is the right place to put this change - s:ParsePattern() is called from 2 places, AddTabularPattern() and Tabularize(). This logic might make sense for :Tabularize, but I'm not sure about :AddTabularPattern - in particular, whether :AddTabularPattern foo /bar/ should change @/.

This would be a pretty big behavior change - people may have existing maps, etc that don't change affect their search pattern today but would if we made this change. The other concern is that there's a (maybe undocumented?) feature of :Tabular - if you run :Tab foo, the 'foo' is remembered, so the next time you run :Tab with no arguments, 'foo' gets reused. This would break that feature, at least for tabular pipelines.

That said there are definitely some strong arguments to be made for integrating tabular with @/ - I'll need to think about this a bit more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 11, 2013
  1. @jceb

    use vim's search pattern if no pattern is specified

    jceb authored
    - also set vim's search pattern when a pattern was provided to Tabularize
    - this makes :Tabularize behave more like a tightly integrated vim feature, e.g. :g
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 1 deletion.
  1. +12 −1 plugin/Tabular.vim
View
13 plugin/Tabular.vim
@@ -90,9 +90,12 @@ function! s:ChooseCommandMap(commandline)
endfunction
" Parse '/pattern/format' into separate pattern and format parts. {{{2
+" If pattern is not present, use current search pattern
" If parsing fails, return [ '', '' ]
function! s:ParsePattern(string)
- if a:string[0] != '/'
+ if empty(a:string)
+ return [@/,'']
+ elseif a:string[0] != '/'
return ['','']
endif
@@ -105,6 +108,14 @@ function! s:ParsePattern(string)
let pattern = a:string[1 : -1]
endif
+ if empty(pattern)
+ let pattern = @/
+ else
+ " assign pattern as search pattern to act like with other highly integrated
+ " commands, e.g. :g
+ let @/ = pattern
+ endif
+
return [pattern, format]
endfunction
Something went wrong with that request. Please try again.