J Cooper
J Cooper

Reputation: 17062

Dumb completion in Visual Studio

Intellisense is nice for what it does, but often I find myself longing for the "crude" text completion of editors like Vim. I can't seem to find a facility for being able to complete a word--perhaps in a string, anywhere really--and have VS try to complete it for me (based on stuff I've typed before in the current buffer, or in all open files, or however it wants to work).

Am I missing something? (Or if necessary, is there an extension to do this?) It seems like it would actually be tons easier to implement than Intellisense, but it really can save typing.

Thanks!

Upvotes: 11

Views: 1599

Answers (8)

mfeingold
mfeingold

Reputation: 7134

In VS2010 implementing intellisense is extremely easy - assuming that you have a ready answer for 2 questions:

  1. What should trigger the dialog
  2. What is the list of possible completions for the current word.

In my custom editor I spent 90% of time on making the NDjango parser give to me what I need and only 10% on actually "implementing" intellisense

Edit

The project s open source feel free to download the code and play with it.

Upvotes: 1

Scott P
Scott P

Reputation: 3772

If you have a handful of words you are looking to fill in, you can easily create some snippets to do that.

It's more than a bit of a hack, but it might be helpful.

Snippet xml:

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>retype</Title>
      <Shortcut>retype</Shortcut>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Code Language="csharp">
        <![CDATA[ThisIsTheTextIHateToRetype();$end$]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>

Upvotes: 0

Brett Veenstra
Brett Veenstra

Reputation: 48534

Resharper from Jetbrains also has completion that is very intelligent. CTRL+SHFIT+Space activates their "intelligent" code completion (beyond your normal CTRL+Space results), which is type and context-sensitive. I frequently find it is choosing appropriate names for me.

Upvotes: 0

ErvinS
ErvinS

Reputation: 1116

CodeRush show suggestions for completion of words in strings or everywhere else. They have a free version, but i don't know if it supports this feature.

Upvotes: 1

Ronald
Ronald

Reputation: 1815

As stated in other answers, Intellisense in Visual Studio 2010 has become much better. Not only the extensibility, but also implementation.

It now filters the list of members containing the typed name anywhere within them. This also works with classes and types, so you don't have to remember the full type or class name. And last be not least, you can filter the list using the Pascal Case naming pattern. This means less typing and less mistyping.

More information on the Intellisense improvements in VS2010 can be found on ScottGu's blog.

Upvotes: 1

Benoit Miller
Benoit Miller

Reputation: 399

You may want to look at the VisualAssist add-in. Its autocomplete is aware of the things you typed recently, so it selects the most recent match by default. It also works in more places than the standard IntelliSense (e.g. include paths).

A word of warning however, when you start using it, it's hard to go back...

Upvotes: 6

ShuggyCoUk
ShuggyCoUk

Reputation: 36486

The extensibility model in 2010 is much simpler but is (obviously) still a moving target.

It should be possible to get something simple using the intellisense part of this to supply an ICompletionSource which merges in whatever values you want to supply along with the existing implementations results.

Monitoring the current buffer for names should involve some playing around with the ITextView and ITextBuffer.

There is an example of modifying the presentation layer on codeplex but you should be able to use that as a base on which to try altering the data side of things.

Upvotes: 0

luvieere
luvieere

Reputation: 37534

Take a look at ViEmu, Vi/vim emulation for Visual Studio, Word, Outlook and SQL Server. If it still doesn't fulfill your needs, attempt at rolling your own. Check out the Visual Studio Extensibility Reference and this tutorial to help you get started on VS Add-Ins.

Upvotes: 1

Related Questions