Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Automatic Content Assist in Eclipse and MS Visual Studio C++


  • Please log in to reply
2 replies to this topic
bluebird
  • Members
  • 6 posts
  • Last active: Aug 25 2010 11:17 AM
  • Joined: 12 Apr 2010
I find Content Assist in Eclipse, resp. Intellisense in MS Visual Studio C/C++ really useful. However it opens only after certain "events" (eg. pressing ".", "->", "(", ")") or when the user presses Ctrl+Space. In MS Visual Studio C# and Notepad++, however, it opens on every keystroke, which I really prefer.

Since there is no built-in option to do this, I decided to write a simple ahk-script, which does exactly what I wanted:

Visual Studio C/C++:
; automatically call control+space for intellisense in Visual Studio C/C++
#IfWinActive ahk_class wndclass_desked_gsk

    ~a::
    ~b::
    ~c::
    ~d::
    ~e::
    ~f::
    ~g::
    ~h::
    ~i::
    ~j::
    ~k::
    ~l::
    ~m::
    ~n::
    ~o::
    ~p::
    ~q::
    ~r::
    ~s::
    ~t::
    ~u::
    ~v::
    ~w::
    ~x::
    ~y::
    ~z::

    ~0::
    ~1::
    ~2::
    ~3::
    ~4::
    ~5::
    ~6::
    ~7::
    ~8::
    ~9::

    ~_::

        Send ^{space}
return

Eclipse:
; automatically call control+space for Content Assist in Eclipse
#IfWinActive ahk_class SWT_Window0

    ~a::
    ~b::
    ~c::
    ~d::
    ~e::
    ~f::
    ~g::
    ~h::
    ~i::
    ~j::
    ~k::
    ~l::
    ~m::
    ~n::
    ~o::
    ~p::
    ~q::
    ~r::
    ~s::
    ~t::
    ~u::
    ~v::
    ~w::
    ~x::
    ~y::
    ~z::

    ~0::
    ~1::
    ~2::
    ~3::
    ~4::
    ~5::
    ~6::
    ~7::
    ~8::
    ~9::

    ~_::

        Send ^{space}
return


Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
That's an interesting idea. I find that IntelliSense for C++ is generally too slow to use effectively in this manner. Anyway, here's a condensed version which also adds support for uppercase (or lowercase if you've got capslock on):
GroupAdd AutoAssist, ahk_class wndclass_desked_gsk  ; Visual Studio
GroupAdd AutoAssist, ahk_class SWT_Window0          ; Eclipse
Hotkey IfWinActive, ahk_group AutoAssist            ; either
Loop 26 { ; a-z and A-Z
    Hotkey % "~"  . Chr(A_Index+96), ~_
    Hotkey % "~+" . Chr(A_Index+96), ~_
}
Loop 10 ; 0-9
    Hotkey % "~" . A_Index-1, ~_
return ; (not really necessary since there's a hotkey below)
~_::Send ^{Space}  ; ~_ also acts as a label for the Hotkey command
One major problem I see (at least in VC++ 2010 beta and SciTE) is that if there's only one match, it is chosen automatically. This makes it difficult to type anything that IntelliSense doesn't recognize.

Saleh
  • Guests
  • Last active:
  • Joined: --
In the toolbar menu select
Window -> Preferences
search for "Content Assist" or
you can find it under "Java" -> "Editor" -> Content Assist
(note: you can replace "Java" by any language supported by Eclipse)

In the options Panel (on the right) you'll find Auto Activation under which you'll find the "Auto Activation Triggers for Java" option.

enter all the alphabets and .

Now anytime you type a character it will trigger content assist to appear.