+19
Textmate style word completion
Implement word completion as is done in Textmate. Explained best at the Textmate web site (http://manual.macromates.com/en/working_with_text#completion):
"TextMate has a simple yet effective completion function on ⎋ (escape). It will complete the current word based on matches in the current document. If there are multiple matches, you can cycle through these by pressing ⎋ continuously. It is also possible to cycle backwards using ⇧⎋.
The matches are sorted by distance from the caret, meaning candidates which are closer to the caret will be suggested before candidates farther away."
This is an improvement over the current tab-completion because:
- The tab key is also used for tabbing.
- It cycles continuously.
- It is based on nearest matches.
Kundesupport af UserEcho
Yes! The current behaviour of the insert_best_completion command is driving me crazy.
For example, if (in Ruby code) I have a variable named "column", I typically type "col" and hit the completion key. Sublime completes it with "collect { |e| }"!
This conflation of snippets and completion means that the completion function is completely unpredictable to the user, and I have to remember every snippet that exists so I don't accidently trigger one. TextMate gets it right — it has a one key (tab) for snippets, and another (escape) for completion. That's brilliant.
Now, I don't use snippets at all, as I don't find them productive, so being offered snippets all the time is simply an annoyance.
Being able to turn off snippets is step one.
The next step is being able to cycle completions. Right now, Sublime's autocompletion will iteratively autocomplete stuff. So given the source code:
thing = 1
thing_factory = ...
thunk_method()
If I type "th" and press the autocomplete key, it will first expand to "thing". But I wanted "thunk_method", so I hit the autocomplete key again. But now it will expand into "thing_factory", which is not what I wanted.
This is something TextMate is much better at.
Ctrl+space works better (although it still offers snippets), but it's not an efficient UI. I have to visually scan the list offered, which incurs a mental context switch.
I wrote a plugin that solves the problem for me:
https://github.com/alexstaubo/sublime_text_alternative_autocompletion
Found a problem with the current key bindings, updated the instructions in the readme.
Alexander S.,
thanks for making the sublime_text_alternative_autocompletion plugin available.
However, I don’t understand where to put the code to customize the key mapping, the stuff like
"{ "keys": ["escape"], "command": ..."
Sorry for asking stupidly, being new to ST2, coming from TextMate.
Thanks for helping me out.
Did you ever figure out where to put the code? I have the same question. thanks!
Philip,
actually I did. The code is to be put into the file
"Default (OSX).sublime-keymap"
(lives in ~/Library/Application Support/Sublime Text 2/Packages/User/)
You can access it directly from within ST2 via:
Preferences/Key Bindings - User
It then works immediately, like a charm.
Take care.
Cool! Thanks so much, I'll give it a shot.