views:

483

answers:

8

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!

+1  A: 

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: http://bit.ly/6KSDz5

mfeingold
Fair enough, but this really shouldn't need to involve intellisense at all. That is, I don't need "code completion," just simple text completion based on words I've typed previously so I don't need to type them again. (Also note that this must be available in addition to standard intellisense; I'm not looking to replace code completion altogether.)
J Cooper
I understand what you want, and I do not know whether anything of the sort is already out there, What I am trying to say is it would be pretty easy to implement your own version, including the very valid point of your code completion complementing (not replacing) the existing one(s). The point here is no matter how easy and obvious 'text completion' sounds to you, the next person will have his own idea on how it has to work
mfeingold
You'd still need to hook up into editor's IntelliSense APIs because that's what provides the completion list etc... but making it list all other words in the buffer is fairly trivial. Especially if you target VS2010 with its much saner new editor extensibility APIs.
Pavel Minaev
+1  A: 

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.

luvieere
I'm already using ViEmu, actually :)
J Cooper
A: 

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.

ShuggyCoUk
+5  A: 

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...

Benoit Miller
+1  A: 

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.

Ronald
+1  A: 

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.

ErvinS
+1  A: 

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.

Brett Veenstra
A: 

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"&gt;
  <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>
Scott P