var sql = ''; sql += 'SELECT * FROM users '; sql += 'WHERE role = "admin" '; sql += 'AND permissions = "read" '; sql += 'LIMIT 10';
Mike Li's plugin is small: it basically uses
substitute to replace each line with quotes and
function! Stringify() range for linenum in range(a:firstline, a:lastline) let replaceSub = "'\\1'\ +" if a:lastline == linenum let replaceSub = "'\\1'" endif let newline = getline(linenum) " escape single quote " \\\\ is \ " \= means previous char is optional let newline = substitute(newline, "\\\\\\='", "\\\\\\\'", 'g') " add single quotes and plus let newline = substitute(newline,'\(\S.*\)', replaceSub ,'g') call setline(linenum, newline) endfor endfunction
You may want to map this to a
<Leader> mapping... Or perhaps not! There are apparently a lot of unused keys in Vim that you can use for convenient mappings. Some people are even saying
<Leader> is lame. For more on that, see Drew Neil's Follow my leader talk.