Wednesday, April 28, 2010

Re: How to fix broken automatic indentation in vim

Gary,

I do not have the same ~/.vimrc on both computers. In the first computer I
have a heavily modified .vimrc file. However, on the second computer I did a
fresh Vim 7.2 install. I actually went to www.vim.org and downloaded the vim
installer from there. Thus the .vimrc file on the second computer should be
the default.

However, I did try what you suggested. I executed "vim -N -u NONE", set the
"filetype plugin indent on" setting and loaded the example file. When I
issued the "gg=G" command the indentation worked fine.

However, I then tried to indent a VHDL file. This is a simple VHDL which I
put online. Hopefuly you can access it through:
http://old.nabble.com/file/p28386622/example.vhd example.vhd .

Again, I opened vim using "vim -N -u NONE", set "filetype indent plugin on"
and opened the file. I used the "gg=G" command and let vim indent the file.
Unfortunately I found that vim did not do a good job and that the
indentation was not good at all :-(

I saved and uploaded the file after indenting into
http://old.nabble.com/file/p28386622/example_indented.vhd
example_indented.vhd . If you can open it you will see that the "type
secondStruct" is not indented properly. Also, the comments (beginning with
"--") are not indented right and the final "END;" is not indented properly
either.

Could you give it a try and see if you have the same problem that I do?

I think that perhaps I originally had 2 problems. One was probably caused by
something on my .vimrc setup, but there seems to be something else.

Could there be some problem related to the format of the file? Some of these
files have been edited in Windows and in Linux. Could there be some mix of
line endings that could confuse vim somehow? When I open the file I do not
see any "^M" symbol on the line endings so I assumed that their format was
correct.

Thanks,

Didly

Gary Johnson-4 wrote:
>
> You have the same problem on both computers and you're using the
> same ~/.vimrc on both? Hmm.
>
> It works fine for me. I copied your example code into a file named
> foo.m. Then I started vim as
>
> vim -N -u NONE
>
> to avoid loading any configuration files at all. Within vim I
> executed
>
> :filetype plugin indent on
> :e foo.m
> gg=G
>
> The result was that both indented lines were re-indented by 8
> spaces, which makes sense since 'shiftwidth' defaults to 8.
>
> I don't know what's specifically wrong with your ~/.vimrc since I
> don't know what's in it. The indent plugin should override your
> 'cindent' and 'smartindent' settings, so those shouldn't be a
> problem. As I demonstrated above, you don't need anything in your
> ~/.vimrc other than
>
> filetype plugin indent on
>
> and
>
> set shiftwidth=4
>
> to get the indentation you want.
>
> HTH,
> Gary
>
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> Subscription settings:
> http://groups.google.com/group/vim_use/subscribe?hl=en
>
>

--
View this message in context: http://old.nabble.com/How-to-fix-broken-automatic-indentation-in-vim-tp28379120p28386622.html
Sent from the Vim - General mailing list archive at Nabble.com.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment