tpope / vim-repeat

repeat.vim: enable repeating supported plugin maps with "."
http://www.vim.org/scripts/script.php?script_id=2136
2.59k stars 81 forks source link

tabularize #18

Closed myster-t closed 10 years ago

myster-t commented 10 years ago

This is a great plugin. I use it often!

Can you show me how to enable this for the tabularize plugin? I currently have these maps:

if exists(":Tabularize")
    nmap <Leader>aa :Tabularize /=<CR>
    vmap <Leader>aa :Tabularize /=<CR>
    nmap <Leader>a= :Tabularize /=<CR>
    vmap <Leader>a= :Tabularize /=<CR>
    nmap <Leader>a: :Tabularize /:\zs<CR>
    vmap <Leader>a: :Tabularize /:\zs<CR>
endif
qstrahl commented 10 years ago

The maintainer of tabularize has to add support for vim-repeat into the plugin itself. You could open an issue for tabularize and request it.

tpope commented 10 years ago

Actually, . usually only repeats maps, not functions, so adding it to the map is pretty reasonable. The basic case should be little more than :call repeat#set(":Tabularize...\<CR>") afterwards.

qstrahl commented 10 years ago

Yet again I make the mistake of not assuming tpope's plugin is as awesome as possible.

myster-t commented 10 years ago

Thanks @tpope, but I still can't seem to figure it out. Would one of my command become:

nmap <Leader>aa :Tabularize /=<CR> repeat#set(":Tabularize \=\<CR>")

I tried that and it didn't work.

graywh commented 10 years ago

@phaitour You need to append exactly what @tpope told you. You're currently missing the :call.

myster-t commented 10 years ago

So like this @graywh?

nmap aa :Tabularize /= :call repeat#set(":Tabularize /=")

That didn't seem to work either.

graywh commented 10 years ago

nmap <Leader>aa :Tabularize /=<CR>:call repeat#set(":Tabularize /=<Bslash><lt>CR>")<CR>

myster-t commented 10 years ago

Hmm, I got this back:

E114: Missing quote: ":Tabularize...\
E116: Invalid arguments for function repeat#set
Press ENTER or type command to continue
graywh commented 10 years ago

I've updated the mapping.

myster-t commented 10 years ago

Still doesn't work, but definitely seems to be on the right track! Instead of performing the repeat action, it just says this on the command line

:Tabularize /=<CR>

So, if I start typing asdf, it becomes :Tabularize /=<CR>asdf

However, if I hit backspace and delete the <CR> part of the command and hit <enter>, then it'll work.

If I modify the mapping to be:

nmap <Leader>aa :Tabularize /=<CR>:call repeat#set(":Tabularize /=")<CR>

Then it has the right command, but it just hangs on the command line. I have to hit <enter> for it to run.

graywh commented 10 years ago

Yeah, I left out the . Try again.

myster-t commented 10 years ago

Woohoo!! It works. Thanks for helping me figure this out!!