What is the way to configure VI to autocomplete and format the files in a standardized way according to each language?

Asked

Viewed 501 times

2

I’ve been using VI for some years, I think about 20 years, at the time still in XCO Unix and Xenix, but I never took the initiative to make my environment fully parameterized to program in languages like C/C++, PHP and Java.

I would like to prepare my VI to be successful in the use of these languages, I still have situations that I need to connect to remote servers and recompile programs, so it is necessary to edit the files urgently and VI is the best choice for me.

How to configure it to autocomplete and format the files in a standardized way according to each language?

2 answers

1


There is the possibility of autocompleting existing words in your code from the vim 7 . You can use this function using the combination CTRL + n .

To autocomplete reserved words of some already available languages, use the commands below (for php)

:set omnifunc=phpcomplete#CompletePHP

Or add the line below in your ~/.vimrc:

autocmd FileType php set omnifunc=phpcomplete#CompletePHP

Utilize CTRL + x , CTRL + o to complete.

If I am not mistaken, there is no autocomplete for java and C++, then you will have to install a plugin separately. I suggest the vjde and the following link to install it: http://blog.vinceliu.com/2007/08/vim-tips-for-java-3-use-omni-completion.html

Another thing I think is cool is automatic indentation (sw is the amount of white spaces. add to ~/.vimrc),

set sw=4
set autoindent

and the plugins tabe and NERDTree.

0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.