Sublime Forum

Deep autocompletion, smarter code refactor?

#1

Hello,
I’ve been searching (but I failed) for auto completion like eclipse or code::blocks have: it shows me all methods and fields not only from files around and currently edited one, but those inside every STL class and those .h files that are included in my file. The best option would be if it show also template arguments as eclipse does. Eg. typing
vector v;
v.si
would immediately suggest me size() etc.

Next feature that I really miss is lack of smart refactoring variables/functions/etc feature. When I do it in eclipse it changes any name in every file included in folder, but it does not touch shadowing variables, words in comments and macro names (it’s case sensitive), but sublime solves the problem just by find/replace method…

Are there any good plugins/settings to regulate that? I really like sublime but I miss the power of eclipse while coding.

Edit: I use mainly C++

0 Likes

#2

I think you are talking about C, so maybe have a look to https://packagecontrol.io/packages/ClangAutoComplete .

0 Likes

#3

Thanks for reply! I’ve tried clang but it does nothing… I cannot find any way to run it. It works perfectly with linter however. Does it work for single files?

0 Likes

#4

It works on single file, just make sure you have CLang installed correctly and the path to the binary is either in your path or set correctly in the clangAutoComplete.sublime-settings file

0 Likes

#5

YouCompleteMe is pretty good as well, but you need ycmd installed first

0 Likes

#6

IMO YouCompleteMe is better than plugins which take in a compile_commands.json file. Where I work, projects are large enough to make generating and parsing compile_commands.json prohibitively slow. YCM instead uses a python script to get the compile flags for a file, This is nice because you can hook it up directly with your build system which can produce this information much faster than parsing compile_commands.json. Also with YCM you can use compile_commands.json if you want to, the default python script provided by YCM does exactly that.

0 Likes

#7

I’ve finally run clang auto-complete, but it does not search inside include, even since I have added /usr/include path to clang settings. Any ideas?

But what about refactoring the code? I don’t mean replacing text, cause it will make huge mess at e.g.:
int a; void method(){ for(int i : container){ int a = this->a; do_something(a); }

0 Likes