Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automate writing for loop in vim?

Tags:

linux

vim

I keep writing for loops today. All of them have the format :

for(size_t szI = X; szI < Y; ++szI)
{
   //Something
} 

And I know there are ways to record actions in vim. If X and Y can change, can I do something in vim to write a for loop once I supply X and Y somehow?

like image 969
nakiya Avatar asked Dec 28 '22 02:12

nakiya


1 Answers

You can use a plugin like snipMate to store snippets, which you can then store a for snippet in.

In fact, it already comes with a lot of predefined snippets, a lot of which may prove useful.

like image 120
Sebastian Paaske Tørholm Avatar answered Jan 05 '23 17:01

Sebastian Paaske Tørholm