1

When in mysql command prompt, the edit command which uses $EDITOR variable will result in a VIM environment without any color scheme.

Each time I create a new query, I must type ':set syntax=mysql'. This is because the temporary file name mysql create has no .sql extension. Here is an example of the name mysql can choose : /tmp/sql97H2iA.

How can I get vim to set mysql syntax without my intervention?

mysql Ver 14.14 Distrib 5.6.27, for debian-linux-gnu (x86_64) using EditLine wrapper VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Dec 9 2014 17:36:18) Included patches: 1-488 Ubuntu 15.04

1 Answer 1

2

Adding the lines below to your vimrc will tell Vim to set the correct filetype of every buffer with a name starting with sql under /tmp/:

augroup sql
    autocmd!
    autocmd BufNew,BufEnter /tmp/sql* setlocal filetype=sql
augroup END
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.