In reply to ``Using :let to view a wildcard of variables''
sent 17 September 2011, Saturday by David Fishburn

> Will display all variables currently defined in Vim.
> 
> One thing I have always wanted to do is:
> :let my_prefix.*
    let d={}
    for [var, d.val] in filter(items(g:), 'v:val[0]=~#"\\v^my_prefix"')
        echo var."\t" d.val
    endfor
. You can also use t:, w:, b:, v: dictionaries, or even create a command:
    let s:scopes=split('g b v w t')
    let s:types={type(''): 's',
                \type(0) : 'n',
                \type({}): 'd',
                \type([]): 'l',
                \       2: 'r',}
    if has('float')
        let s:types[type(0.0)]='f'
    endif
    function s:FindVars(regex)
        let vars=[]
        for scope in s:scopes
            let vars+=map(filter(keys({scope}:), 'v:val =~# a:regex'),
                        \ 'scope.":".v:val')
        endfor
        let maxvarlen=max(map(copy(vars), 'len(v:val)'))
        for var in vars
            echo printf('%-*s', maxvarlen, var) s:types[type({var})] {var}
        endfor
    endfunction
    command -nargs=1 FindVars :call s:FindVars(<q-args>)

The regex will be used to search for variable name without a scope. If you 
want to search for variable name with scope, exchange `map(' and `filter(' in 
`let vars+=' line (and their second arguments, of course).

Original text:
> Vim 7.3.315
> 
> My plugins all use naming conventions for variables.
> 
> :let
> 
> Will display all variables currently defined in Vim.
> 
> One thing I have always wanted to do is:
> :let my_prefix.*
> 
> Or something like that to show all variables beginning with my_prefix.
> 
> The only way I have come up with a way to do this is:
> :new
> :redir @a
> :let
> :redir end
> 
> "ap
> 
> :v/^my_prefix/d
> 
> Which essentially does want I want, but is a real pushup.
> 
> Can any Vimmers suggest a more streamlined approach?
> 
> Thanks,
> Dave

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to