Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding custom items to intellisense in Visual studio 2013

I have some requirements in making the intellisense customizable. Is this possible?

I want to add a custom item into the dropdown that gets triggered when "." (period) is pressed.
Also any information regarding code completion would be very much appreciated.

Basically, i'm looking for something like:
A doubletab press after typing "for" would generate the following code:

for (int i = 0; i < length; i++)
        {

        }.

Can we have custom items to insert different code snippets as above?

like image 513
Karthik Bhat Avatar asked Nov 25 '25 17:11

Karthik Bhat


1 Answers

Yes, that is possible. Have a look at this MSDN Link.

Here a little Example:

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Hello World</Title>
      <Author>Myself</Author>
      <Description>Says a string to the world.</Description>
      <Shortcut>hello</Shortcut> <!-- This is your intellisense Shortcut -->
    </Header>
    <Snippet>
      <Declarations>
        <Literal>
          <ID>sayValue</ID>
          <ToolTip>Replaced with what you want.</ToolTip>
          <Default>"Hello"</Default>
        </Literal>
      </Declarations>
      <Code Language="CSharp">
        <![CDATA[
          valueToSay = $sayValue$;
          Console.WriteLine(valueToSay);
        ]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>

How to install:

  1. Save this somewhere
  2. Go in your VS to Tools -> Code Snipptes Manager
  3. Choose Import
  4. Choose your (in Step 1 saved) file
like image 157
Mischa Avatar answered Nov 28 '25 15:11

Mischa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!