Reputation: 18511
Do I have something similiar to intelij's "ifn" and "inn" live template in ReSharper?
("if not null" and "if null" templates )
Thanks.
Upvotes: 1
Views: 241
Reputation: 18102
ReSharper doesn't have these built in, but you can easily write them yourself. Just go to ReSharper > Templates Explorer... > Surround Templates and add a new template with something like this:
if ($SELECTION$ == null)
{
throw new ArgumentNullException("$SELECTION$");
}
Then you can select something and hit Ctrl+E, U to surround the selection with your template:
In my case, I added it to the quicklist with the letter F.
If you want to be able to type ifn
and press Tab, you need to add a Live Template. This can be done in the Template Explorer, under Live Templates, but the content has to be different:
if ($ARGUMENT$ == null)
{
throw new ArgumentNullException("$ARGUMENT$");
}
or maybe:
if ($ARGUMENT$ == null)
{
$END$
}
Then you can write ifn
(if that was the shortcut you specified) and press Tab
Upvotes: 4