开发者

Has anyone made a VS code snippet to base the 'item' in foreach on the camelCased collection?

I use the foreach shortcut all the time. In many cases I do the same thing and I think it would nice to save the last step.

The sequence follows, with the last step being what I'd like to have happen automatically.

My question is pretty much: has anyone already done this or is so good with a custom code snippet or so good that they could do it real quick?

I've read the docs on code snippetts more than once and it's one of those things that for some reason refuese to click for me.

I type:

foreach<tab><tab>

Result:

foreach (**var** item in collection)
{
}

I type:

<tab><tab>

Result:

foreach (var item in **collection**)
{
}

I type (using auto complete specific to my project): camp<tab>

Result:

foreach (var item in **campaignList**)
{
}

--> What开发者_运维问答 I would like to do is automatically make item turn into 'campaign' here based on campaignList being camel cased <--

Type: shift-<tab>shift-<tab>

foreach (var **item** in campaignList)
{
}

Type: campaign<enter>

foreach (var campaign in campaignList)
{

}


You can always write your own code snippets.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜