LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   VIM auto completion (https://www.linuxquestions.org/questions/linux-newbie-8/vim-auto-completion-873111/)

possum 04-05-2011 09:02 AM

VIM auto completion
 
Hello,

I am using Vim 7.2 and trying to get autocompletion to work when writing bash scripts in RHEL 6. According to the VIM documentation, any language that offers syntax highlighting should be supported.

Is this really supported in VIM?

brownie_cookie 04-05-2011 09:11 AM

don't know if this is what you need, but try it

In 'compatible' mode, e.g. if you have no vimrc, the autocomplete key is
by default not Tab but Ctrl-E

See :help 'wildchar'

tronayne 04-05-2011 09:23 AM

Should be -- take a look at http://www.techrecipes.net/applicati...auto-complete? and give it a try.

Something useful you can do with all ex-based editors (vi and vim are viual modes of ex) is create a file, .exrc in your home directory with content like this
Code:

cat .exrc
set autoindent showmode showmatch

which will, automagically, set those options (autoindent keeps tabs aligned when you're doing indented code, you go backwards with CTL-D, showmode display what mode you're in, showmatch keeps parens ( ( ) ), braces ( { } ) and brackets honest -- when you type a closing paren, brace or bracket the cursor will flip back to the matching opening one).

You can see what you can set if, in vim, you type :set.

Hope this helps some.

possum 04-23-2011 01:29 PM

Just getting back to this....Thanks for all the tips.

I've been using the supertab plugin as I've found the native auto-complete key combinations to be a little difficult to master. I call it within my .VIMRC using:

Quote:

let g:SuperTabDefaultCompletionType = "context"
Indenting is not something I've configured yet, but for handling matching bracket pairs, etc., the autoclose plugin does a pretty good job.I'll give the indenting setting a try.

Confirming what I am seeing when VIM editing a bash script, the above article states how (depending on the language) auto-complete only prompts based on words which already exist in the document. To do more requires further configuration.

This statement however requires further qualification....because in reality, support for auto-complete is language dependent.

An example of this is HTML, where by default the language is fully supported and auto-complete provides a comprehensive list of all possible options, regardless of how many words already exist in the document.

So it looks like the answer is:

By default, some languages are fully supported. Whereas other languages (at least BASH, PHP, Python, etc.) are only partially supported (which means VIM requires supplication to fully support them).

This begs the question...why native full support for HTML only? Auto-complete seems a bit half-baked in this regard.


All times are GMT -5. The time now is 12:53 AM.