I would like to find a plugin, what can do the following in normal mode of vim:

  • Parameter initialization
  • Parameter substitution into text based on templates

Suppose we have many sql query where country_code can change but the other conditions are always the same :

select * from customers c where c.id= ... c.country_code=36 
select * from product p where p.name= ... p.country_code=36
.... several other query with ... country_code=36

So, the plugin can replace the :cc to 36 and result can be on the clipboard, or buffer but I dont want to touch the original queries, i want to keep them as templates.

Thanks in advance.

  • Why don't you simply write your file to another one (if you don't want to modify the original) and simply use a substitution command (e.g. %s/country_code=/\036) and then simply yank the desired line? You don't even have to write your file to a temporary one you can simply do the substitution, yank your command and then quit vim without saving your file.
    – statox
    Jan 21 '18 at 18:52
  • I think vim can solve it in one page with buffers, thats why I think there should be a plugin.
    – user647314
    Jan 22 '18 at 9:18
  • But I think I gave you a solution in my previous comment which doesn't need a plugin. What you want to do sounds pretty specific so I'm not sure someone already wrote a plugin which will do exactly what you want. You'd be better using built-in functions.
    – statox
    Jan 22 '18 at 9:22
  • What do you want to do with the result after the plugin places it in the clipboard/new buffer?
    – Rich
    Jan 22 '18 at 11:27
  • the result can be run in the commad prompt with !, so I can use parameterized command line commands. e.g not long before my colleagues and me type the following sql query min 20 times per day : select * from foo where port=62017 and date=2017-10-01 and .... but other conditions were the same. e.g Squirrel SQL client knows this feature. I want do this in more generalized form. I can do this kind of parameterizing with bash script as well, but I dont want to hide the details into function
    – user647314
    Jan 22 '18 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.