I'm unable to override indentexpr

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

I'm unable to override indentexpr

Steve Litt
Hi all,

I'm using Vim 7.3 in Xubuntu 12.10. When editing my html files, this
happens when I set indentexpr?:

indentexpr=HtmlIndentGet(v:lnum)

That's no good because HtmlIndentGet(v:lnum) does a horrible job of
indenting: I'd rather have no indentation at all. No prob -- I'll just
set indentexpr=, thereby getting rid of Vim-furnished indentation. So,
in ~/.vim/after/ftplugin/html.vim, I put indentexpr=. It changes
nothing. verb set indentexpr? says:

 indentexpr=HtmlIndentGet(v:lnum)
        Last set from /usr/share/vim/vim73/indent/html.vim

I put a set indentexpr? and a 2sleep in ~/.vim/after/ftplugin/html.vim
after setting indentexpr to nothing, and I indeed got it to stop when
loading an html file, and show me indentexpr wasn't set.

I did the same thing with tw, setting it to 43 in
~/.vim/after/ftplugin/html.vim and 99
in /usr/share/vim/vim73/indent/html.vim, and in the editing session it
was set to 99.

I did a :set rtp?, and here's what I got:

runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim73,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after

The preceding might wrap, but suffice it to say that ~/.vim/after is
the last thing on it.

The only thing I could find to make indentexpr go away was to comment
it out of /usr/share/vim/vim73/indent/html.vim, but that's not a good
solution.

I've obviously skipped a step. I've proven that ~/.vim/after is the
last thing on the runtime path. I've proven that
~/.vim/after/ftplugin/html.vim actually gets run, and that before it
exits indentexpr is unset. I've proven that the thing setting
indentexpr is indeed /usr/share/vim/vim73/indent/html.vim, and nothing
else is setting it.

I feel like I'm staring into a black box and there's some dark corner
I'm not seeing. How can I narrow this down just one more time?

By the way, thank you to all the people on the #vim IRC channel who
have already helped me with this problem so I could get as far as I
have.

Thanks,

SteveT

Steve Litt                *  http://www.troubleshooters.com/
Troubleshooting Training  *  Human Performance

--
--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: I'm unable to override indentexpr

Gary Johnson-4
On 2013-06-04, Steve Litt wrote:

> Hi all,
>
> I'm using Vim 7.3 in Xubuntu 12.10. When editing my html files, this
> happens when I set indentexpr?:
>
> indentexpr=HtmlIndentGet(v:lnum)
>
> That's no good because HtmlIndentGet(v:lnum) does a horrible job of
> indenting: I'd rather have no indentation at all. No prob -- I'll just
> set indentexpr=, thereby getting rid of Vim-furnished indentation. So,
> in ~/.vim/after/ftplugin/html.vim, I put indentexpr=. It changes
> nothing. verb set indentexpr? says:
>
>  indentexpr=HtmlIndentGet(v:lnum)
>         Last set from /usr/share/vim/vim73/indent/html.vim

To override indent settings, you must put your settings in
~/.vim/after/indent/html.vim.
             ^^^^^^

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

---
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: I'm unable to override indentexpr

Steve Litt
On Tue, 4 Jun 2013 19:11:19 -0700
Gary Johnson <[hidden email]> wrote:

> On 2013-06-04, Steve Litt wrote:
> > Hi all,
> >
> > I'm using Vim 7.3 in Xubuntu 12.10. When editing my html files, this
> > happens when I set indentexpr?:
> >
> > indentexpr=HtmlIndentGet(v:lnum)
> >
> > That's no good because HtmlIndentGet(v:lnum) does a horrible job of
> > indenting: I'd rather have no indentation at all. No prob -- I'll
> > just set indentexpr=, thereby getting rid of Vim-furnished
> > indentation. So, in ~/.vim/after/ftplugin/html.vim, I put
> > indentexpr=. It changes nothing. verb set indentexpr? says:
> >
> >  indentexpr=HtmlIndentGet(v:lnum)
> >         Last set from /usr/share/vim/vim73/indent/html.vim
>
> To override indent settings, you must put your settings in
> ~/.vim/after/indent/html.vim.
>              ^^^^^^

Thanks Gary,

You're right. I confirmed it by making ~/.vim/after/indent/html.vim,
putting in indentexpr=, and running Vim again. I can toggle indentexpr
by commenting and uncommenting that line in
~/.vim/after/indent/html.vim, so you're for sure right.

But I don't understand how my ~/.vim/after/ftplugin/html.vim got
executed, yet didn't change indentexpr. Does Vim throw away certain
categories of changes depending on the directory? You told me the fix
for my problem, and I thank you profusely for that. Now I'd like to
understand the process Vim uses to set all this stuff.

Thanks,

SteveT

--
--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: I'm unable to override indentexpr

Gary Johnson-4
On 2013-06-04, Steve Litt wrote:

> Thanks Gary,
>
> You're right. I confirmed it by making ~/.vim/after/indent/html.vim,
> putting in indentexpr=, and running Vim again. I can toggle indentexpr
> by commenting and uncommenting that line in
> ~/.vim/after/indent/html.vim, so you're for sure right.
>
> But I don't understand how my ~/.vim/after/ftplugin/html.vim got
> executed, yet didn't change indentexpr. Does Vim throw away certain
> categories of changes depending on the directory? You told me the fix
> for my problem, and I thank you profusely for that. Now I'd like to
> understand the process Vim uses to set all this stuff.

I don't have all of the answer, but I can tell you how to find the
answer.

Vim uses various autocommands and scripts in $VIMRUNTIME to manage
plugins and the order of their execution.  The primary one is
filetype.vim.  It (and a few others such as scripts.vim and files in
ftdetect) sets the 'filetype' based on filename extensions and/or
contents.  The setting of the 'filetype' triggers the FileType event
and starts the execution of FileType autocommands, including the
loading of filetype plugins, indent plugins and syntax plugins.  The
loading of indent plugins is controlled by indent.vim.

So, if you follow the order of execution of the plugins by reading
filetype.vim, indent.vim, and perhaps a few other files in the
$VIMRUNTIME directory, you'll discover the sequence in which plugins
are sourced and the reason for the behavior you observed.

One nice thing about the way Bram put a lot of the plugin control in
scripts external to the Vim binary is that it is much simpler to
follow the execution of scripts than it would be to find and follow
source code in C.

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

---
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: I'm unable to override indentexpr

John Little-4
In reply to this post by Steve Litt
On Wednesday, June 5, 2013 2:57:52 PM UTC+12, stevelitt wrote:

> But I don't understand ...

:scriptnames

can aid understanding.  It shows scripts in the order they were sourced.

Regards, John Little

--
--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: I'm unable to override indentexpr

Bram Moolenaar
In reply to this post by Steve Litt

Steve Litt wrote:

> I'm using Vim 7.3 in Xubuntu 12.10. When editing my html files, this
> happens when I set indentexpr?:
>
> indentexpr=HtmlIndentGet(v:lnum)
>
> That's no good because HtmlIndentGet(v:lnum) does a horrible job of
> indenting: I'd rather have no indentation at all. No prob -- I'll just
> set indentexpr=, thereby getting rid of Vim-furnished indentation. So,
> in ~/.vim/after/ftplugin/html.vim, I put indentexpr=. It changes
> nothing. verb set indentexpr? says:

[...]

Are other people thinking the same way?  I quite often disable HTML
indenting, especially because it re-indents when changing an existing
line, which can be very annoying.

Perhaps there is another HTML indenter that would be preferred?
Or the defaults should be changed?

Johannes (the maintainer) has not been very responsive lately.


--
You are only young once, but you can stay immature indefinitely.

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--
--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: I'm unable to override indentexpr

Ben Fritz
On Wednesday, June 5, 2013 6:26:59 AM UTC-5, Bram Moolenaar wrote:

> Steve Litt wrote:
>
>
>
> > I'm using Vim 7.3 in Xubuntu 12.10. When editing my html files, this
>
> > happens when I set indentexpr?:
>
> >
>
> > indentexpr=HtmlIndentGet(v:lnum)
>
> >
>
> > That's no good because HtmlIndentGet(v:lnum) does a horrible job of
>
> > indenting: I'd rather have no indentation at all. No prob -- I'll just
>
> > set indentexpr=, thereby getting rid of Vim-furnished indentation. So,
>
> > in ~/.vim/after/ftplugin/html.vim, I put indentexpr=. It changes
>
> > nothing. verb set indentexpr? says:
>
>
>
> [...]
>
>
>
> Are other people thinking the same way?  I quite often disable HTML
>
> indenting, especially because it re-indents when changing an existing
>
> line, which can be very annoying.
>

I leave it enabled. It could certainly use some improvement...sometimes it seems to get lost, especially inside of <li> items, but I wouldn't go so far as saying I'd rather have NO automatic indenting. It does a reasonable job often enough I don't mind fixing it manually from time to time. I would prefer if I didn't need to fix it at all. I've toyed with the idea of using HTMLtidy as a formatprg/equalprg but it never bugged me enough to try setting it up.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: I'm unable to override indentexpr

stosss
In reply to this post by Bram Moolenaar
On Wed, Jun 5, 2013 at 7:26 AM, Bram Moolenaar <[hidden email]> wrote:

>
>
> Steve Litt wrote:
>
> > I'm using Vim 7.3 in Xubuntu 12.10. When editing my html files, this
> > happens when I set indentexpr?:
> >
> > indentexpr=HtmlIndentGet(v:lnum)
> >
> > That's no good because HtmlIndentGet(v:lnum) does a horrible job of
> > indenting: I'd rather have no indentation at all. No prob -- I'll just
> > set indentexpr=, thereby getting rid of Vim-furnished indentation. So,
> > in ~/.vim/after/ftplugin/html.vim, I put indentexpr=. It changes
> > nothing. verb set indentexpr? says:
>
> [...]
>
> Are other people thinking the same way?  I quite often disable HTML
> indenting, especially because it re-indents when changing an existing
> line, which can be very annoying.
>
> Perhaps there is another HTML indenter that would be preferred?
> Or the defaults should be changed?
>

I agree with Bram.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: I'm unable to override indentexpr

Andy Wokula
In reply to this post by Ben Fritz
Am 05.06.2013 16:35, schrieb Ben Fritz:

> On Wednesday, June 5, 2013 6:26:59 AM UTC-5, Bram Moolenaar wrote:
>> Steve Litt wrote:
>>
>>> I'm using Vim 7.3 in Xubuntu 12.10. When editing my html files, this
>>> happens when I set indentexpr?:
>>>
>>> indentexpr=HtmlIndentGet(v:lnum)
>>>
>>> That's no good because HtmlIndentGet(v:lnum) does a horrible job of
>>> indenting: I'd rather have no indentation at all. No prob -- I'll just
>>> set indentexpr=, thereby getting rid of Vim-furnished indentation. So,
>>> in ~/.vim/after/ftplugin/html.vim, I put indentexpr=. It changes
>>> nothing. verb set indentexpr? says:
>>
>> [...]
>>
>> Are other people thinking the same way?  I quite often disable HTML
>> indenting, especially because it re-indents when changing an existing
>> line, which can be very annoying.
>>
> I leave it enabled. It could certainly use some improvement...
> sometimes it seems to get lost, especially inside of <li> items, but I
> wouldn't go so far as saying I'd rather have NO automatic indenting.
> It does a reasonable job often enough I don't mind fixing it manually
> from time to time. I would prefer if I didn't need to fix it at all.
> I've toyed with the idea of using HTMLtidy as a formatprg/equalprg but
> it never bugged me enough to try setting it up.

You can try my script

indent/html.vim : alternative html indent script
http://vim.sourceforge.net/scripts/script.php?script_id=2075

Hint: It can be found by typing "html indent" into www.vim.org's search
field.

--
Andy

--
--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: I'm unable to override indentexpr

Steve Litt
In reply to this post by Bram Moolenaar
On Wed, 05 Jun 2013 13:26:59 +0200
Bram Moolenaar <[hidden email]> wrote:

>
> Steve Litt wrote:
>
> > I'm using Vim 7.3 in Xubuntu 12.10. When editing my html files, this
> > happens when I set indentexpr?:
> >
> > indentexpr=HtmlIndentGet(v:lnum)
> >
> > That's no good because HtmlIndentGet(v:lnum) does a horrible job of
> > indenting: I'd rather have no indentation at all. No prob -- I'll
> > just set indentexpr=, thereby getting rid of Vim-furnished
> > indentation. So, in ~/.vim/after/ftplugin/html.vim, I put
> > indentexpr=. It changes nothing. verb set indentexpr? says:
>
> [...]
>
> Are other people thinking the same way?  I quite often disable HTML
> indenting, especially because it re-indents when changing an existing
> line, which can be very annoying.
>
> Perhaps there is another HTML indenter that would be preferred?
> Or the defaults should be changed?

Hi Bram,

Almost any HTML indenter that works consistently would be preferable to
the current one, but, speaking for myself,  I think I might choose none
at all over even the best of indenters. Here's why...

First, the default behavior, and for all I know the only behavior, of
the tidy HTML checker is to output non-indented HTML. I use tidy both
to check my HTML and to make it consistent, combined with an Awk script
that adds blank lines at strategic places. So between tidy and my Awk
script, my HTML is fairly navigable, which is the big need.

Additionally, my HTML is purposed to write text content. A lot of text.
Here's just one example:

http://www.troubleshooters.com/lpm/200212/200212.htm

With documents that full of text, you don't want to waste line length
with indentation. It would be much different if I were working with
something DOM rich and text poor, but my stuff is DOM poor and text
rich.

To summarize, the current HTML formatter is horrible and worse yet
inconsistent, certainly a better formatter would be an improvement, but
in my case I'll probably continue writing HTML that starts in the first
column and has tw=72.

Bram, while I have your attention, thanks very much for Vim. Vim
singlehandedly enabled me to move to Linux and still get my work done.
When there was no decent outliner in Linux, Vim came to the rescue. Now
that all the decent Linux WYSIWYG HTML editors are problematic, Vim
comes to the rescue. When I need to do a dangerous mass deletion,
instead of being a cowboy and piping find into grep into xargs rm, I
redirect the file list into a file, Vim the file, turn it into a
shellscript, check it twice, and run it. When I need a quick and
dirty text processing program, especially one intended to be used
one time, instead of using Awk, Perl, Python, or Lua, I'll often do it
in Vim, or maybe make an ex program enabling Vim to do the work. When my
LyX files go really bad and I can't fix them, I put them in Vim and am
able to diagnose the problem. Oh yeah, and I write code with Vim too :-)

Thanks for Vim!

SteveT

Steve Litt                *  http://www.troubleshooters.com/
Troubleshooting Training  *  Human Performance

--
--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: I'm unable to override indentexpr

Bram Moolenaar
In reply to this post by Andy Wokula

Andy Wokula wrote:

> Am 05.06.2013 16:35, schrieb Ben Fritz:
> > On Wednesday, June 5, 2013 6:26:59 AM UTC-5, Bram Moolenaar wrote:
> >> Steve Litt wrote:
> >>
> >>> I'm using Vim 7.3 in Xubuntu 12.10. When editing my html files, this
> >>> happens when I set indentexpr?:
> >>>
> >>> indentexpr=HtmlIndentGet(v:lnum)
> >>>
> >>> That's no good because HtmlIndentGet(v:lnum) does a horrible job of
> >>> indenting: I'd rather have no indentation at all. No prob -- I'll just
> >>> set indentexpr=, thereby getting rid of Vim-furnished indentation. So,
> >>> in ~/.vim/after/ftplugin/html.vim, I put indentexpr=. It changes
> >>> nothing. verb set indentexpr? says:
> >>
> >> [...]
> >>
> >> Are other people thinking the same way?  I quite often disable HTML
> >> indenting, especially because it re-indents when changing an existing
> >> line, which can be very annoying.
> >>
> > I leave it enabled. It could certainly use some improvement...
> > sometimes it seems to get lost, especially inside of <li> items, but I
> > wouldn't go so far as saying I'd rather have NO automatic indenting.
> > It does a reasonable job often enough I don't mind fixing it manually
> > from time to time. I would prefer if I didn't need to fix it at all.
> > I've toyed with the idea of using HTMLtidy as a formatprg/equalprg but
> > it never bugged me enough to try setting it up.
>
> You can try my script
>
> indent/html.vim : alternative html indent script
> http://vim.sourceforge.net/scripts/script.php?script_id=2075
>
> Hint: It can be found by typing "html indent" into www.vim.org's search
> field.

Thanks.  Since the old indent script didn't get updated in 7 years I'll
include yours.

I have added the comments to the help file.

Please don't forget to email me a new version when you make
improvements.  I don't check the scripts for updates.

--
hundred-and-one symptoms of being an internet addict:
171. You invent another person and chat with yourself in empty chat rooms.

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--
--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.