codemirror / CodeMirror-v1

An editable-iframe based code editor in JavaScript. See https://github.com/marijnh/CodeMirror for the currently maintained version
http://codemirror.net/
Other
362 stars 63 forks source link

Autocomplete #30

Closed ghost closed 13 years ago

ghost commented 13 years ago

It would be great if the editor completed keywords, constructs, or common names.

It would also be great if parenthesis, brackets, and braces were also automatically terminated.

{ -> {}
[ -> []
( -> ()
< -> <>
marijnh commented 13 years ago

My position on autocomplete is that it won't be part of CodeMirror, but CodeMirror should provide the tools to implement it as an add-on. You can add an key event handler to the frame, use cursorCoords to find out where to position your drop-down, and use the API to insert code at the right place.

As for auto-paren-insertion, that's definitely not going to become a default feature (too annoying). If you want to add it as an option, feel free to submit a patch.

egeozcan commented 13 years ago

by the way, just an idea: that annoyance can be highly eliminated if the editor overwrites the next char if the typed char and the next char are both closing paranthesis. example: (helloworld-cursorishere-) => I type ")" => (helloworld)-cursorishere-

ghost commented 13 years ago

An example of how I would envision this being implemented is by how ActiveState's Komodo EDIT and IDE applications handle auto parens. It's both intuitive and non-invasive. And it could be turned off.

I'll look into creating a patch.

thomasandersen commented 13 years ago

quplo has added what they call The Common Sense Code Completion

Blog post, demo, and source can be found here:

http://blog.quplo.com/2010/06/common-sense-code-completion/