Wednesday, February 4, 2015

Re: Vim Indent

On Wednesday, 4 February 2015 21:59:41 UTC+5:30, Ben Fritz wrote:
> On Tuesday, February 3, 2015 at 9:52:36 PM UTC-6, Harisha Navilarekallu wrote:
> > On Tuesday, 3 February 2015 21:53:06 UTC+5:30, Ben Fritz wrote:
> > > On Tuesday, February 3, 2015 at 12:15:17 AM UTC-6, Harisha Navilarekallu wrote:
> > > > On Tuesday, 3 February 2015 11:09:11 UTC+5:30, Ben Fritz wrote:
> > > > > On Monday, February 2, 2015 at 9:21:39 PM UTC-6, Harisha Navilarekallu wrote:
> > > > > > On my new laptop, I have installed gvim7.4 on Win-7.
> > > > > > With this auto-indent is some how not working. I am not sure if any thing needs to be enabled / disabled.
> > > > > > I use only C/C++:
> > > > > >
> > > > > > Few of the problems I am facing are:
> > > > > >
> > > > > > if ( cond )
> > > > > > cond--; // Indent not working.
> > > > > >
> > > > > > The same code with Curly braces works fine:
> > > > > >
> > > > > > if ( cond ) {
> > > > > > cond--; // <----- Indentation working here!!!!
> > > > > > }
> > > > > >
> > > > > >
> > > > > > int foo( ARG1,
> > > > > > ARG2) // No indentation here!!!
> > > > > > {
> > > > > > }
> > > > > >
> > > > > > Note that the above is not corrected even if I force auto indent whole file using gg=G.
> > > > > >
> > > > > > I am not sure what is causing this problem.
> > > > > > Earlier version which I was using with old laptop is working fine.
> > > > > >
> > > > > > I have installed few plugins like : MultiSearch, Tab-Auto completion, which I think should not affect the Auto-indent by any way.
> > > > > >
> > > > > > Any idea how to resolve this?
> > > > > >
> > > > >
> > > > > Have you enabled filetype detection and indentation rules?
> > > > >
> > > > > I.e. does your .vimrc contain one of the following?
> > > > >
> > > > > filetype plugin indent on
> > > > > filetype indent on
> > > >
> > > >
> > > > I have added again - Nothing changes.
> > > >
> > > > I think its some thing to do with File type? The reason is when I try same thing in one of my older file, it perfectly works. I am not able to find the diff in file type.
> > > > When I checked the file type using file command in Unix, it says:
> > > > "test.cpp: ASCII C++ program text, with CRLF line terminators"
> > > >
> > > > When I try the old working file it says:
> > > > "./test.cpp: ASCII English text"
> > > >
> > > > I tried changing the dos format to unix without success.
> > >
> > > Vim *probably* handles Dos format just fine.
> > >
> > > What does Vim think this file is?
> > >
> > > Find out, with this command:
> > >
> > > :set filetype? fileformat?
> > >
> > > filetype should be cpp if your detection is enabled properly.
> > >
> > > If fileformat isn't DOS, then you'll want to check your 'fileformats' setting (note the 's' on the end of this one).
> >
> >
> > fileformat=unix
> > filemormats=dos,unix
> > filetype=cpp
>
> OK so filetype detection is working, but line ending style is apparently inconsistent in your file so Vim is detecting it wrongly. I doubt this is your issue, but you can look at these pages for help there:
>
> http://vim.wikia.com/wiki/File_format
> http://vim.wikia.com/wiki/Automatically_reload_files_with_mixed_line-endings_in_DOS_fileformat
>
> I'd suspect somehow your indent settings are not turned on. Can you confirm "filetype indent on" or "filetype indent plugin on" are in your .vimrc, and there are no following "filetype" commands to turn it back off?
>
> Also check the output of ":verbose set cindent?" to see whether the proper indentation rules for C++ got turned on by the cpp filetype indent plugin, or overwritten later.


Some thing about this specific file seems to be strange.
:verbose set cindent? --> "Last set from "c:\Program Files\Vim\Vim74\indent\cpp.vim"

One more thing observed in this file is "highlight CursorLine" is not working. Where as it work in other files.

For the purpose testing I used "set compatible" and it seems to be working with that. Now I am trying to see what all the things "set nocompatible" is doing.

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: