You are not logged in.

#1 2012-05-31 07:34:02

/dev/zero
Member
From: Melbourne, Australia
Registered: 2011-10-20
Posts: 1,247

Vim ignores statusline setting in vimrc [Solved]

Dear Archers,

I'm trying to modify my vim statusline. At this stage, my goal is to get vim to recognise any kind of statusline modification made in the vimrc, because at the moment no such modification appears to be recognised whatsoever.

I tried both a sample vimrc from the wiki and a blank vimrc containing nothing but the line,

set statusline=%t

For both vimrcs, the statusline setting was ignored. When I'm in vim, I can manually run the command,

:set statusline=%t

and the effect is apparent and immediate. All my other vimrc settings appear to be parsed in the correct manner; only this one specific setting seems to be ignored (but without warnings/errors).

I also did general googling on such topics as

Me Googling wrote:

"vimrc" "ignores" "statusline"

and found this Stack Overflow thread which suggests using ruler instead of statusline, but still I couldn't get it to work.

If anyone can point out what I'm doing wrong, I would really appreciate it.

Last edited by /dev/zero (2012-05-31 22:15:49)

Offline

#2 2012-05-31 07:55:15

JackH79
Member
From: Australia
Registered: 2009-06-18
Posts: 663
Website

Re: Vim ignores statusline setting in vimrc [Solved]

Didi you

set noruler
set laststatus=2

to remove the ruler and permanently display the stausline?

Last edited by JackH79 (2012-05-31 08:00:44)

Offline

#3 2012-05-31 08:02:52

/dev/zero
Member
From: Melbourne, Australia
Registered: 2011-10-20
Posts: 1,247

Re: Vim ignores statusline setting in vimrc [Solved]

JackH79 wrote:

Didi you

set laststatus=2

to permanently display the stausline?

I did try various combinations with that setting.

I tried again just now with a vimrc containing nothing but,

set laststatus=2
set statusline=%t

but still when I afterwards type, vim .vimrc, it's clear that the statusline hasn't changed; running

set statusline?

show it's instead (still) on

statusline=%-f%r %2*%m%*    %1*%{TagInStatusLine()}%*%=[%l:%c]    [buf %n
]

Offline

#4 2012-05-31 08:05:46

JackH79
Member
From: Australia
Registered: 2009-06-18
Posts: 663
Website

Re: Vim ignores statusline setting in vimrc [Solved]

Sorry, I was too slow with the edit.
I think you have to remove the ruler as well (see first post).

Offline

#5 2012-05-31 08:10:56

/dev/zero
Member
From: Melbourne, Australia
Registered: 2011-10-20
Posts: 1,247

Re: Vim ignores statusline setting in vimrc [Solved]

JackH79 wrote:

Sorry, I was too slow with the edit.
I think you have to remove the ruler as well (see first post).

No worries. I've added noruler:

set noruler
set laststatus=2
set statusline=%t

Still no love. (But when I run those commands manually from within vim, yes, they work.)

Offline

#6 2012-05-31 08:15:10

JackH79
Member
From: Australia
Registered: 2009-06-18
Posts: 663
Website

Re: Vim ignores statusline setting in vimrc [Solved]

Strange. Is vim at least using any other modifications in your vimrc?
If no, then I'd say that maybe it doesn't use the same vimrc you're working with.
If it does, then I'm out of ideas for the moment.

Edit: Maybe check this.

Last edited by JackH79 (2012-05-31 08:16:42)

Offline

#7 2012-05-31 08:34:16

/dev/zero
Member
From: Melbourne, Australia
Registered: 2011-10-20
Posts: 1,247

Re: Vim ignores statusline setting in vimrc [Solved]

JackH79 wrote:

Strange. Is vim at least using any other modifications in your vimrc?
If no, then I'd say that maybe it doesn't use the same vimrc you're working with.
If it does, then I'm out of ideas for the moment.

Edit: Maybe check this.

Thanks for your help. I noticed this problem while trying to modify my existing vimrc, which is much larger. That pre-existing vimrc works quite well, with or without these changes to the statusline settings. The changes just get ignored. This leads me to think that $HOME/.vimrc isn't being ignored entirely. For some reason, only the statusline part seems to be ignored.

The output of

:version

within vim appears identical to

vim --version

within bash, and so:

$ vim --version | grep vimrc
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
  system gvimrc file: "/etc/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"

I could suppose that some error is making vim fall back on /etc/vimrc - but wouldn't this also make an error message appear, and make the colorscheme fall back to default as well? If there's a problem, then shouldn't the commands fail to work when I run them manually, and shouldn't a warning or error be issued?

I could post my normal vimrc, but I think at this stage it would just muddy the waters. I'd like to focus on getting the given minimal vimrc to work first. After that, I will see whether the solution works in a more realistic vimrc.

Offline

#8 2012-05-31 09:02:31

JackH79
Member
From: Australia
Registered: 2009-06-18
Posts: 663
Website

Re: Vim ignores statusline setting in vimrc [Solved]

Why don't you post your minimal vimrc. Maybe someone picks up a vital part that is needed but not present.

Edit: just came home to sit in front of an actual vim. I tried to edit my statusline and it works perfectly.
Also tested it with this minmal .vimrc:

set nocompatible
set noruler
set statusline=%t
set laststatus=2

Last edited by JackH79 (2012-05-31 09:46:19)

Offline

#9 2012-05-31 10:15:48

/dev/zero
Member
From: Melbourne, Australia
Registered: 2011-10-20
Posts: 1,247

Re: Vim ignores statusline setting in vimrc [Solved]

My minimal vimrc was this one:

set noruler
set laststatus=2
set statusline=%t

I also tried your suggested one, with the extra nocompatible set. A shot of what I'm getting either way:
aU71l.png

Offline

#10 2012-05-31 10:20:37

JackH79
Member
From: Australia
Registered: 2009-06-18
Posts: 663
Website

Re: Vim ignores statusline setting in vimrc [Solved]

Just to make sure, is that vim or gvim? Just because of the titlebar.

Apart from that, I'm a bit out of ideas. Sorry.

Last edited by JackH79 (2012-05-31 10:22:51)

Offline

#11 2012-05-31 10:32:27

/dev/zero
Member
From: Melbourne, Australia
Registered: 2011-10-20
Posts: 1,247

Re: Vim ignores statusline setting in vimrc [Solved]

JackH79 wrote:

Just to make sure, is that vim or gvim? Just because of the titlebar.

Just plain vim. I don't like gvim. My window manager (wmii) puts titlebars on windows; when I exit out of vim, that titlebar reverts to '~' to show the console's current directory.


JackH79 wrote:

Apart from that, I'm a bit out of ideas. Sorry.

Haha, okay, thanks for your efforts anyway smile.

Offline

#12 2012-05-31 10:34:41

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: Vim ignores statusline setting in vimrc [Solved]

Can't think of anything to fix the statusline, except trying a forced reinstall, and to check you don't have any vim packages installed that may affect it.

But you could try, as a workaround, to set rulerformat and set ruler.
I nicked this example from the vim site, as I think the format's different to statusline.

set ruler
set rulerformat=%55(%{strftime('%a\ %b\ %e\ %I:%M\ %p')}\ %5l,%-6(%c%V%)\ %P%)

"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#13 2012-05-31 10:47:24

JackH79
Member
From: Australia
Registered: 2009-06-18
Posts: 663
Website

Re: Vim ignores statusline setting in vimrc [Solved]

Well, the thing is that it clearly ignores your .vimrc, as it still displays the ruler, even though you explicitly set noruler.

Could you try and force vim to use your minimal vimrc?

vim -u /home/devzero/minimalvimrc

Does that make it work?

Offline

#14 2012-05-31 10:47:28

/dev/zero
Member
From: Melbourne, Australia
Registered: 2011-10-20
Posts: 1,247

Re: Vim ignores statusline setting in vimrc [Solved]

skanky wrote:

Can't think of anything to fix the statusline, except trying a forced reinstall, and to check you don't have any vim packages installed that may affect it.

But you could try, as a workaround, to set rulerformat and set ruler.
I nicked this example from the vim site, as I think the format's different to statusline.

set ruler
set rulerformat=%55(%{strftime('%a\ %b\ %e\ %I:%M\ %p')}\ %5l,%-6(%c%V%)\ %P%)

Okay, I try

set nocompatible
set statusline=%t
set laststatus=2

set ruler
set rulerformat=%55(%{strftime('%a\ %b\ %e\ %I:%M\ %p')}\ %5l,%-6(%c%V%)\ %P%)

... yep, still the same.

I'm going to bed. Hopefully as different parts of the planet rotate into sunlight, people will awaken and offer more ideas smile.

Offline

#15 2012-05-31 10:59:22

JackH79
Member
From: Australia
Registered: 2009-06-18
Posts: 663
Website

Re: Vim ignores statusline setting in vimrc [Solved]

Damn, we should've done that in a chat room. Simultaneous editing of forum threads is confusing.
If you're awake and had your coffe, maybe try my suggestion in post #13 to see if it's actually using your vimrc.

Anyway, hope you had a good night. :-)

Offline

#16 2012-05-31 11:47:48

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: Vim ignores statusline setting in vimrc [Solved]

JackH79 wrote:

Damn, we should've done that in a chat room. Simultaneous editing of forum threads is confusing.
If you're awake and had your coffe, maybe try my suggestion in post #13 to see if it's actually using your vimrc.

Anyway, hope you had a good night. :-)

Yeah, that's the next thing to try. smile

Edit: could also try putting the commands in the /etc file as well.

Last edited by skanky (2012-05-31 11:49:10)


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#17 2012-05-31 21:22:35

/dev/zero
Member
From: Melbourne, Australia
Registered: 2011-10-20
Posts: 1,247

Re: Vim ignores statusline setting in vimrc [Solved]

JackH79 wrote:

maybe try my suggestion in post #13 to see if it's actually using your vimrc.

Sorry, I missed that post last night. I tried your suggestion about forcing which vimrc to use. Vim quite clearly appears to be using the minimal vimrc because it respects commands about syntax highlighting:
mHYHF.png

I also tried looking in /etc/vimrc; it has a single line

runtime! archlinux.vim

I then run locate archlinux.vim, which gives a result /usr/share/vim/vimfiles/archlinux.vim

Offline

#18 2012-05-31 22:14:57

/dev/zero
Member
From: Melbourne, Australia
Registered: 2011-10-20
Posts: 1,247

Re: Vim ignores statusline setting in vimrc [Solved]

Okay, solved it.

First I ran vim in debug mode: vim -D. This showed me that my vimrc was being processed correctly. This suggested that something was undoing the vimrc settings later, i.e. plugins, so I grepped my plugins directory for "status\|ruler" and found the culprit: a plugin I never even use, called pythonhandler.vim. Removing that plugin solves the problem!

Thanks for your help smile.

Offline

Board footer

Powered by FluxBB