Auto code completion in VIM? - linux

Can VIM do auto code completion like what Eclipse does? Usually I connect to my Linux developing server through Putty from my Windows laptop. So, I hope I can find a plugin for VIM which can do drop-down menu like auto completion when I can type variable names in Putty, is this possible?
Thanks!

Yes, in a sense - Vim has Completion commands that can help you automatically find the completion text for partial variable names.
In a nutshell, type a partial variable name and then press CtrlP to search for a matching name.

Yes, it's possible. Vim already features that general style of code completion built-in, under the name of Omni completion.
The default installation doesn't allow for auto-invocation, but if you install this script, that allows it to happen.
Note that, depending on the language you'll be working with, you may need additional scripts to handle auto-completion for that language, and may even need to change the auto-invoke script to recognize when to invoke the completion. Since you haven't said what programming language you'll want to work with, it's a bit hard to say if you need more than this, but I recommend checking the help file.

Try to use http://eclim.org/ - using eclipse core with VIM via plugins.
To not start the complete ecplise core but have a C/C++ member completion, try
http://www.vim.org/scripts/script.php?script_id=1520
- Complete namespaces, classes, structs and union members.
- Complete inherited members for classes and structs
(single and multiple inheritance).
- Complete attribute members eg: myObject->_child->_child etc...

Currently vim has no of plugins for the auto code completion feature, I am using youcompleteme plugin, combined with vim-snippets, ultisnips and supertab plugins. You can tab complete the code using snippets (a small text which can be expanded for full code), and a large number of languages are supported.
For simple text files also a drop down menu comes for the words you have typed earlier.

Related

Sublime 3 autocomplete recommends vague internal functions in Julia

So I'm using Sublime Text 3 w/ Julia, and I have mixed feelings about the autocomplete. A lot of the time it recommends these vague internal functions that aren't even close to the word I'm typing in. For example:
http://puu.sh/iWyrB/7293a9928f.png
Even if I've used dict_t as a variable before, I have to type in most of the word before it recommends dict_t; it seems to happen once it runs out of internal functions to recommend.
So it seems like this is coming from the IJulia package. I like using that package, but moments like the picture above are frustrating. Any advice?
Edit:
To disable "insert completion on tab" add this to you User Preferences:
// By default, auto complete will commit the current completion on enter.
// This setting can be used to make it complete on tab instead.
// Completing on tab is generally a superior option, as it removes
// ambiguity between committing the completion and inserting a newline.
"auto_complete_commit_on_tab": false,
To disable the auto-complete popup (but still be able to insert completion on tab):
// Enable auto complete to be triggered automatically when typing.
"auto_complete": true,
I'm afraid you cannot remove only the completions coming from Sublime-IJulia and keeping all default completions without changing any code in the Sublime-IJulia package.
If what you need is genera Julia support for sublime (syntax highlighting, auto-indent etc), I recommend switching from Sublime-IJulia to Julia-sublime. Sublime-IJulia had it's last commit in January 2015 while Julia-sublime is actively maintained. Most notably in this case, Julia-sublime does not give autocomplete for all standard functions.
Note that Julia-sublime, like other syntax packages in sublime, does not not strive to be an IDE substitute. These features should be separated, not all users wants both.
For running Julia code from within Sublime with IDE-like functionality there is currently no good alternative, the packages I've found are outdated and have quite a few issues.
When it comes to developing and testing code, I like keep a REPL open in the terminal and just re-include() my code in there. I find this to be flexible and efficient. More on this in the Julia FAQ: http://docs.julialang.org/en/release-0.4/manual/faq/#how-can-i-modify-the-declaration-of-a-type-immutable-in-my-session).
Disclosure: I am the maintainer of Julia-sublime. If you encounter issues or feel that something can be improved, I encourage you open an issue.

Define personal autocomplete library

I regularly have to program small applications for several very specific situations.
My mother language is Dutch so I define my variables in Dutch.
When I write this programs I try to use VIM.
In most of my programs I use the same syntax, so I wanted to make my own auto complete library. But because I have to switch regularly between language (from lisp to latex for example). Specifically I want to be able to load a library after I started vim.
I don't have a clue about how this library should look, but the easiest thing I could come up with is a word on every line.
set complete+=k
set dict+=~/path/to/dict
The cool thing about VIM is autocomplete happens from any open buffer. In my opinion, you can load an "autocomplete file" in a buffer, then open your source file that you're going to work on, which will open in in another buffer, and you will get all your autocomplete goodness. This will allow you to open and close whatever buffers you want autocomplete to recognize. Effectively customizing your autocomplete for that particular session.

C++ Cross Ref for VIM similar to Source Insight

I wanted a cross reference navigation similar to Source Insight.
Lets take simple example:
classA::MethodB()
{
...
m_variable = value;
}
In this example if I use Ctags / Cscope, then when I try to find m_variable, it will show me all the available m_variable. I need to go through each and then find which one is required.
Where as in Source Insight, it clearly gives me the Class delectation.
Is there any such Cross ref tools available for Vim?
Vim is not an IDE, it's a text editor.
You can't reasonably expect it to understand your code as well or as deeply as an IDE.
IDEs typically keep a dynamic internal representation of your code which makes them able to track declaration and usage even when you have dozens of methods or variables with the same name. Vim, like most text editors, is not able to do that on its own: it must rely on external tools for indexing/navigating through your code. Now, because of architectural constraints, Vim is incapable of running any background process which is the absolute prerequisite for a real "code intelligence" to be added to Vim.
Given all that, you are left with code indexers like ctags, cscope or GLOBAL. These tools do their best trying to give you accurate results but they are not as smart and as specific as the tools used in IDEs.
To compensate, Vim has a bunch of different commands like :tselect or g] which open a list of possible tags to chose from. Read :h tags, :h ctags and :h cscope for how to deal with those limitations.
I've not tried this myself. But sounds like eclim is what you're looking for. http://eclim.org/
It provides eclipse features to be accessible from Vim, including code searching and auto-completion.

VIM as an IDE - Suggestions

I am looking for recommendations on using VIM as an IDE. I generally code in a number of programming languages, including C, C++, assembler, MATLAB, Maple, BASH scripts, to name a few.
In general, I like to use a single IDE for the bulk of my projects for the sake of consistency, and I have found that I perform about 90% of all my coding in VIM, and occasionally use Eclipse instead for certain projects in C/C++ (ie: projects people have already put together as an Eclipse project, or PIC24/32 projects from www.microchip.com).
I am already very familiar with the basic functionality of VIM (windows vs buffers, text manipulation, scripting), and would like to use it as my primary IDE. I have already taken a few tips from here:
http://vim.wikia.com/wiki/Use_Vim_like_an_IDE#Writing_Code
I already use the nerdTree plugin for directory browsing in a project, etc, but I need to do something about code completion and symbol resolution, as those are my two greatest concerns.
Symbol resolution
I have some limited experience in the use of C-tags, and wanted a suggestion on what I should use if I am working with a VERY large code-base that changes frequently. The projects I work on typically are pulling in header files from at least a dozen other projects, and I would like to be able to jump to the file where a function, constant, or macro is defined quickly (ie: like the CTRL-G feature in Eclipse, "jump to definition"), as well as rapidly get a list of all calls/references to a function/macro/constant/etc (ie: like the CTRL-SHIFT-G feature in Eclipse, "Show all references in project or current working directory").
Tab completion
One of the features I really like in Visual Studio and Eclipse, for example, is when I type in a variable name (ie: pointer to struct) and it resolves the names and types of all structure members and gives me a tab completion list to choose the appropriate member. They also point out when I've incorrectly used "." vs "->" for member access. I've tried superTab in VIM, but I just couldn't get it working. I also want the tab-completion feature to use the same C-tags as generated by the symbol resolution plugin
Handling build output
The final concern of mine is having an auto-generated list of build warnings and build errors. When I, for example, just run "make all" at the command-line prompt, it is a pain to have to read through code listings to manually find all build warnings.
I realize this is a lot to ask, and that I could always just fall-back to Visual Studio or Eclipse, but I really want just a simple cross-platform console-capable modal editor for all my development needs, and none of the major IDE's out there fill this need.
Thank you all in advance.
http://eclim.org/ - bring Eclipse functionality to the Vim editor
https://github.com/scrooloose/syntastic - syntax checker warnings in quickfix list
I think (but haven't checked) that Eclim satisfies #1 and #2 while I'm sure that Syntastic satisfies #3. More things of interest:
https://github.com/Lokaltog/vim-powerline - just nice
https://github.com/kien/ctrlp.vim - quick file finder
https://github.com/tpope/vim-pathogen - plugin manager (to install the others)
And are you aware of omnicompletion via Ctrl-p and Ctrl-n (prev and next) in insert mode? That's not code completion, but frequently does the job.
For the auto-completion part (point 2), I am proficiently using clang_complete.
For a quick setup and reference, try this page: http://zwiener.org/vimautocomplete.html
EDIT: this is for C, C++ and Objective-C only.
I use the following configuration in vim:
zipped file
It has autocomplete based on tag list, ctags, nerd commenter and some more plugins.
Hope it helps.. :)
I have been using Vim as an IDE for about a year now. All of my customization is online at github.
That said, I don't think a Vim beginner should start using vim like this; rather I think the Vim beginner should learn vim incrementally. The only changes that I think are so essential I would make them from the very beginning are:
Remap ESC to jk
Switch : and ;
Set leader key to ,

Vim: How to set up an efficient autocomplete configuration?

I've been using Vim for a while now and love it, but one thing I've noticed when I use other editors is that I've never really got autocomplete working with much efficiency. I have supertab & snipmate working, I have tags for whatever language I'm using set up, but somehow it seems a little too cumbersome to use all that much, and apart from long method names I typically just avoid autocomplete.
Does anyone have fast, comprehensive autocomplete funcitonality set up in vim? Specifically:
At the moment, I hit "tab" to autocomplete class/method/variable names & generate snippets, but Ctrl+X+O for inbuilt langauge commands. I'd rather press tab for everything.
The ordering doesn't seem to be too intelligent. Very common stuff is often hidden in the middle of a bunch of rarely-used commands.
I've set up autocomplpop to show potential autocompletes as I'm typing, but I have to hit tab twice to accept the first entry. One much rather single-tab it.
So, any tips on setting up an efficient, comprehensive autocomplete configuration in vim? I know this question is a little vague - but if anyone has an overview of how they autocomplete well, and/or a link to a guide, it would be much appreciated.
Just thought I'd come back and mention that I finally found something I like: A customised version of NeoComplCache. Nice auto popup, everything integrated pleasantly into 'tab', and with a bit of customisation plays nice with snippets.
http://www.vim.org/scripts/script.php?script_id=2620
This is very dependant on your working domain. Vim is a text editor with the ability to interface with intelligent text-aware mechanisms.
If you are using java there is eclim, which is the eclipse backend together with a vim plugin for the frontend.
For C or C++ there is the plugin OmniCppComplete
It works by scanning the headers in the paths you have set up in vim (see :h path), and works very well imo.
If you have to press Ctrl-X_Ctrl-O for omnicompleteion, then your supertab config seems a bit broken. It should try omni or filename completion first, and then fall back to word completion.
YouCompleteMe plugin by Valloric is a very decent plugins for autocomplete and suggestion.
It contains support for all the major languages and you can extend the feature with setting up different engine .
it also comes with syntax checker so u don't have to use Syntastic separately
For setup details visit this link
https://github.com/Valloric/YouCompleteMe

Resources