Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Tab to do code completion in the Editor #696

Closed
spyder-bot opened this issue Feb 17, 2015 · 10 comments
Closed

Use Tab to do code completion in the Editor #696

spyder-bot opened this issue Feb 17, 2015 · 10 comments

Comments

@spyder-bot
Copy link
Collaborator

From loc...@gmail.com on 2011-06-24T04:18:51Z

Dear Developers,

It would be nice to be able to use the tab key for calling code completion in the code editor. Pressing tab to call code completion and tab also to choose from completion list reduces keyboard work.

Now (2.0.12) it is impossible to set up this configuration via keyboard shortcuts.

One could ask, what if the programmer presses tab in order to indent and not to complete code?
Answer: when tab is pressed and only white spaces are previous to the
cursor, an indentation should be made instead of code completion. If
any not white space character stands previous to the cursor, code
completion should be called.

The following code is only a first approach (ignores keyboard shortcut settings) but does the trick:

$ diff codeeditor.py /d/Python/python-2.7/Lib/site-packages/spyderlib/widgets/sourcecode/codeeditor.py
1662c1662,1667
< self.indent_or_replace()


        # self.indent_or_replace()
        line = unicode(self.textCursor().block().text())
        if not line[:self.textCursor().positionInBlock()].strip():
            self.indent_or_replace()
        else:
            self.emit(SIGNAL('trigger_code_completion(bool)'), True)

Result of diff -u codeeditor.py /d/Python/python-2.7/Lib/site-packages/spyderlib/widgets/sourcecode/codeeditor.py is attached to the issue.

Regards,
Roland

Attachment: code-completion-on-tab.patch

Original issue: http://code.google.com/p/spyderlib/issues/detail?id=696

@spyder-bot
Copy link
Collaborator Author

From steve.f....@gmail.com on 2011-07-05T14:04:20Z

This feature would break the editor for my use. I frequently use the tab key to indent code in these circumstances. With these rules I'm suddenly trying to code complete instead of indent as desired. There is already a built in shortcut (ctrl+space) to perform code completion. This is a common shortcut in the majority of editors I've used. This seems like a custom feature for a very small subset of users. If this is implemented there should be a global enable/disable flag to prevent breaking current functionality.

@spyder-bot
Copy link
Collaborator Author

From pierre.raybaut on 2011-07-10T06:45:11Z

Thanks for your kind proposition, Roland.

I'm quite reluctant to implement this feature as is.
I understand your point of view, Steve, and I mostly agree with it. I shall also add that this feature would be conflicting with the "Tab always indent feature".

So the only way that I see to implement this is to add another option, say "Tab triggers code completion when cursor is at end of line" - still the conflict mentioned above will remain and adding another option like this is not as trivial as it may seem.

Status: ContributorNeeded
Labels: -Type-Defect Type-Enhancement Cat-Editor

@spyder-bot
Copy link
Collaborator Author

From pierre.raybaut on 2011-07-10T06:45:31Z

Summary: Code completion / Tab shortcut

@spyder-bot
Copy link
Collaborator Author

From pierre.raybaut on 2012-03-18T14:10:20Z

Status: HelpNeeded
Labels: -Type-Enhancement Type-Enh

@spyder-bot
Copy link
Collaborator Author

From alexchan...@gmail.com on 2013-01-09T16:50:58Z

The eclipse command is Control+Space, and this would work here.

But this is an important issue, and it should be added regardless of the key command.

In fact, it could be added in the preference, without a default key binding.

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2014-01-02T07:18:17Z

Summary: Use Tab to do code completion in the Editor (was: Code completion / Tab shortcut)
Status: Accepted
Labels: MS-v2.3

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2014-01-06T13:03:55Z

This issue was updated by revision c334981bcef6 .

Status: Fixed

@spyder-bot
Copy link
Collaborator Author

From roxfox...@gmail.com on 2014-02-04T19:41:11Z

This is rather useful for those coming from a shell or IPython perspective or background. Hitting the tab key for an auto completion and/or calltips behavior is almost instinctual for me after working with IPython for so long. With this keystroke configurable, this means less changes in workflow for folks on both sides of the aisle, those who come from say Eclips IDE or IPython.
Thanks.

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2014-02-07T05:14:07Z

Yep, that was idea: to minimize friction and increase productivity. Even I am getting accustomed to it after using Ctrl+Space for so long.

@spyder-bot
Copy link
Collaborator Author

From steve.f....@gmail.com on 2014-02-10T11:54:38Z

Yeah, I take back my prior comment on this. I like tab as auto complete when in the middle of the line always. I switched to mac osx and started using sublime text. For some reason spyder is having various issues that I haven't cared to take the time to debug...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant