Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose if there's a last used pattern #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

somini
Copy link

@somini somini commented Aug 8, 2015

Define a function to check if Tabularize has been called yet,
meaning that executing :Tabularize will reuse the last pattern.

The use-case for this is defining a single mapping that either calls Tabularize directly if there's a saved pattern, or prompts you for a pattern. Like this:

function TabularizeThisN()
    if exists('g:tabular_loaded')
        let l:cmd = ':Tabularize'
        if exists('*TabularizeHasPattern') && TabularizeHasPattern()
            " Reuse the last Tabularize command
            let l:cmd .= "\<CR>"
        else
            let l:cmd .= "\<Space>"
        endif
        return l:cmd
    endif
endfunction
nnoremap <expr> <LocalLeader><Tab> TabularizeThisN()

Define a function to check if Tabularize has been called yet,
meaning that executing `:Tabularize` will reuse the last pattern.
@somini
Copy link
Author

somini commented May 7, 2016

Rebased this to the latest master.

@scottchiefbaker
Copy link

I like this... sounds like a great addition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants