A quick vim tip

27 Oct 2011

At work I often have to work on large complex mysql queries, not wanting to leave vim when I don't have to I have this great little shortcut that allows me to execute queries directly from vim. All I need do is name the file the same as the database I want to execute the query against, save it (I use the .sql file extension - though it doesn't require it), then hit leader m. Assuming your setup properly, it will ssh into my dev-server and execute the query in mysql.

Just put this in your ~/.vimrc

nmap <silent> <Leader>m :!ssh dev-server mysql %:r < %<CR>
comments powered by Disqus