use of vim signs

158 views
Skip to first unread message

sinbad

unread,
May 28, 2013, 2:17:44 AM5/28/13
to vim...@googlegroups.com
i want to use vim signs feature in my day-to-day
use of vim, besides the typical use of showing
break-points or errors in code compliation what
other things can be done. For example how are
you using it.

-sinbad

Jeroen Budts

unread,
May 28, 2013, 3:34:56 AM5/28/13
to vim...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
I use the quickfixsigns plugin to show markers as signs as well as
changes I made to the file compared to the version under version
control (git).

http://www.vim.org/scripts/script.php?script_id=2584

Jeroen

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQIcBAEBCAAGBQJRpF4fAAoJEBrqc/v4ufiM5FgP/379t1o2OX0HccEmq3wo6l63
HBmHurmjMmRqUoaaxluu1Ej09yh+J2PL68ZnQJUeqlKEy31FLXrkPetGoUQnwk/D
qWJkr8Kjyk8qvRmZIR295r56YPkLgrhvQ2ae5zJp3+Lw90LWthBIHI7N05K3CU7h
qr+w+sJdsW4hWsU1oneP01v2qOlVszcuePBXkeOhrJ1kK/jIrDuKNLAl8yaMccdz
i8yiMnaGoYMZGmdvCgzWTQsqKXMVtRWd8f3xgX5FWQOtDvGjOihxf1/vOmfp/DW9
iI1l76M1ZQbWBGPD52RvohkwE4Laxj3oSb9JOLlV00E30HmpLyuvFIhJ6RB/16pR
MOxmnxE80UjSY/zTG2ZqCD8GQnVMBIzJI5jrskH7MbRexvu/4htwRNh8gElDrxpX
QfyuMogVEASY/XS2NEKxvjAin65j/Ezbd4FxrYX2TwQEn117AXrz+AGWoLt1Jdq1
gBFcpw3t+7QGXen7IowGcWO6GzdYRIjSchi7Cmx0u4mORO2zWG3SgkncXf9LGufp
9HSTCPoF3ztXM0N9/+e4tlKQOGq7/8S80qBcQXRL0CLI44CkJ2eINcnbHYb2+z7S
gB9QOBAGEoiYPJeeltcDnd3T18obN5QfM0Arfz7RKiiivb80PH43ETVY1KdvrP6V
0Vb4yWbrbc7mjwkRhMRW
=pMHp
-----END PGP SIGNATURE-----

Charles Campbell

unread,
May 28, 2013, 11:00:25 AM5/28/13
to vim...@googlegroups.com
Jeroen Budts wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> On 05/28/2013 08:17 AM, sinbad wrote:
>> i want to use vim signs feature in my day-to-day use of vim,
>> besides the typical use of showing break-points or errors in code
>> compliation what other things can be done. For example how are you
>> using it.
>>
> I use the quickfixsigns plugin to show markers as signs as well as
> changes I made to the file compared to the version under version
> control (git).
>
I use showmarks occasionally. (script#152)

gdbmgr shows breakpoints using signs (script#4104) (gdb, shows
breakpoints and temporary breakpoints using signs).

RltvNmbr (script#2351) shows relative-numbering using signs (I don't
like the absolute line number of the current line being shown as is done
currently with the relativenumber option, and there appears to be no
standard way to restore its former relative-numbering only performance).

I have an indentation guide plugin (IndGuide.vim) that is available at
my website (http://www.drchip.org/astronaut/vim/index.html#INDGUIDE).

I use Skriblovsky's errsign plugin (script#1027) with my personal
.vim/compiler/gcc.vim to flag lines with compilation errors with an
appropriate sign.

Regards,
C Campbell





Yann Thomas-Gérard

unread,
May 28, 2013, 11:26:06 AM5/28/13
to vim...@googlegroups.com, jer...@lightyear.be
Nice plugin. I've just installed it and use it for a couple of hours. Here are my settings in the vimrc file:

" quickfixsigns
let g:quickfixsigns_classes = ['qfl', 'loc', 'vcsdiff']
" Show the signs column even if it is empty
autocmd BufEnter * sign define dummy
autocmd BufEnter * execute 'sign place 9999 line=1 name=dummy buffer=' . bufnr('')

Marc Weber

unread,
May 28, 2013, 11:43:41 AM5/28/13
to vim_use
Bram once recommended one habit:
- watch yourself
- identify what you spend most time on
- try to optimize that

In which way is your workflow "what can signs be used for" help?
I don't want to judge your question - just illustrate a different way
of thinking about Vim and tools in general.

vim-addon-async is using markers to tell te user till where the file has
been executed. But that's a special case, and it does not really make a
difference.

Marc Weber

tooth pik

unread,
May 28, 2013, 12:48:13 PM5/28/13
to vim...@googlegroups.com
On Tue, May 28, 2013 at 11:00:25AM -0400, Charles Campbell wrote:
> Jeroen Budts wrote:
> >On 05/28/2013 08:17 AM, sinbad wrote:
[snip]

> RltvNmbr (script#2351) shows relative-numbering using signs (I don't
> like the absolute line number of the current line being shown as is
> done currently with the relativenumber option, and there appears to
> be no standard way to restore its former relative-numbering only
> performance).

I don't either, and we are not alone. There's at least one other
person who finds that redundant, distracting current line number a
nuisance. His complaint was that it makes the number column much
wider than it needs to be when you're far down in a large file. Mine
is that it's distracting and ugly.

I'm sorry I wasn't really paying attention when this addition to
relativenumber was being first discussed.

So I guess it's time for me to roll up my sleeves and produce a new
option in a patch and submit for approval?

If nobody wants yet another option, maybe a configuration option?

--
_|_ _ __|_|_ ._ o|
|_(_)(_)|_| ||_)||<
|

Marc Weber

unread,
May 28, 2013, 1:02:02 PM5/28/13
to vim_use
Excerpts from tooth pik's message of Tue May 28 18:48:13 +0200 2013:
> So I guess it's time for me to roll up my sleeves and produce a new
> option in a patch and submit for approval?
Hurry up, Bram said he'll accept patches till Friday

Do you know about this alternative solution? SmartGotoLine ?

https://github.com/MarcWeber/vim-addon-other/blob/master/autoload/vim_addon_other.vim#L28
Its enough to type the last X digits of a number. Eg 80 will jump to
2080 if cursor is nearby 2100

Marc Weber

Gary Johnson

unread,
May 28, 2013, 1:03:10 PM5/28/13
to vim...@googlegroups.com
On 2013-05-28, tooth pik wrote:

> I don't either, and we are not alone. There's at least one other
> person who finds that redundant, distracting current line number a
> nuisance. His complaint was that it makes the number column much
> wider than it needs to be when you're far down in a large file. Mine
> is that it's distracting and ugly.

> If nobody wants yet another option, maybe a configuration option?

A configuration option may be fine if you are the only user, but it
doesn't work well for the case of a multiuser system where several
users may be sharing the same Vim binary or for the case of a
pre-built Vim binary packaged for a Linux distribution or made
available as is Vim without Cream for Windows.

I have no valid opinion on the line-number issue as I tried
'relativenumber' once and it drove me nuts--too distracting as I
moved the cursor.

Regards,
Gary

glts

unread,
May 28, 2013, 2:22:35 PM5/28/13
to vim...@googlegroups.com
On Tuesday, May 28, 2013 6:48:13 PM UTC+2, toothpik wrote:
> I don't either, and we are not alone. There's at least one other
> person who finds that redundant, distracting current line number a
> nuisance. His complaint was that it makes the number column much
> wider than it needs to be when you're far down in a large file. Mine
> is that it's distracting and ugly.
>
> I'm sorry I wasn't really paying attention when this addition to
> relativenumber was being first discussed.

You have my vote too.

The single absolute number isn't useful to me as I have a statusline
with that information. What's bothering me though is that it's an
aesthetic irregularity, an irritation that distracts from the sidelines.
To my eyes it _looks_ like a bug!

I'd very much prefer the old tidy line of right-aligned numbers.

> If nobody wants yet another option, maybe a configuration option?

I have an idea.

'nonumber' 'number' 'nonumber' 'number'
'nornu' 'nornu' 'rnu' 'rnu'

|apple | 1 apple | 2 apple | 2 apple
|pear | 2 pear | 1 pear | 1 pear
|nobod[y] | 3 nobod[y] | 0 nobod[y] |3 nobod[y]
|there | 4 there | 1 there | 1 there

Thus,
- ":set nonu nornu" means: I don't want any line numbers;
- ":set nu nornu" means: I want to see only absolute numbers;
- ":set nonu rnu" means: I want to see only relative numbers;
- ":set nu rnu" means: I want to have the best of both worlds.

Marc Weber

unread,
May 28, 2013, 2:43:49 PM5/28/13
to vim_use
Excerpts from glts's message of Tue May 28 20:22:35 +0200 2013:
> - ":set nonu nornu" means: I don't want any line numbers;
> - ":set nu nornu" means: I want to see only absolute numbers;
> - ":set nonu rnu" means: I want to see only relative numbers;
> - ":set nu rnu" means: I want to have the best of both worlds.
fun myfun(absolute_number, cursor_pos)
return format(.. whatever you want)
endfun

Why not 'line_number_fun=myfun()'

The it would be you being able to control contents of the bar, whatever
you want to be there ..

Marc Weber

ZyX ZyX

unread,
May 28, 2013, 4:23:02 PM5/28/13
to vim...@googlegroups.com

If you want to be generic, it would be better to use

    set columnfunctions=myfun1,myfun2,myfun3

. All functions should return a 2-tuple (hl group, text). This way you don't need to choose whether you want a error marker or a change marker from the plugin described earlier. This suggestion is mainly a replacement for signs, but it is just as good for numbers.

> Marc Weber
>
> --
> --
> 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+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Christian Brabandt

unread,
May 28, 2013, 4:57:25 PM5/28/13
to vim...@googlegroups.com
On Di, 28 Mai 2013, glts wrote:

> On Tuesday, May 28, 2013 6:48:13 PM UTC+2, toothpik wrote:
> > I don't either, and we are not alone. There's at least one other
> > person who finds that redundant, distracting current line number a
> > nuisance. His complaint was that it makes the number column much
> > wider than it needs to be when you're far down in a large file. Mine
> > is that it's distracting and ugly.
> >
> > I'm sorry I wasn't really paying attention when this addition to
> > relativenumber was being first discussed.
>
> You have my vote too.
>
> The single absolute number isn't useful to me as I have a statusline
> with that information. What's bothering me though is that it's an
> aesthetic irregularity, an irritation that distracts from the sidelines.
> To my eyes it _looks_ like a bug!
>
> I'd very much prefer the old tidy line of right-aligned numbers.

While I don't have an opinion on that behaviour, I think Nazri Ramliy
proposed a patch¹, that adds a linenumber option to control that
behviour.

>
> > If nobody wants yet another option, maybe a configuration option?
>
> I have an idea.
>
> 'nonumber' 'number' 'nonumber' 'number'
> 'nornu' 'nornu' 'rnu' 'rnu'
>
> |apple | 1 apple | 2 apple | 2 apple
> |pear | 2 pear | 1 pear | 1 pear
> |nobod[y] | 3 nobod[y] | 0 nobod[y] |3 nobod[y]
> |there | 4 there | 1 there | 1 there
>
> Thus,
> - ":set nonu nornu" means: I don't want any line numbers;
> - ":set nu nornu" means: I want to see only absolute numbers;
> - ":set nonu rnu" means: I want to see only relative numbers;
> - ":set nu rnu" means: I want to have the best of both worlds.

Please don't.

¹) https://groups.google.com/group/vim_dev/msg/194c62c57ddf9ee9?hl=de

regards,
Christian
--
Denkt an das fünfte Gebot: Schlagt die Zeit nicht tot.
-- Erich Kästner

Ben Fritz

unread,
May 29, 2013, 10:48:04 AM5/29/13
to vim...@googlegroups.com

I don't know, I think this looks like a decent idea.

It doesn't add ANOTHER configuration option, and while the play between the two might be somewhat complex, it can't be much worse than it currently is.

Marc Weber

unread,
May 29, 2013, 11:02:18 AM5/29/13
to vim_use
And what if there are people who find showing each line number is too
much, who only want to show every fifth?

1



5



10




15

...

Doesn't this look very pretty, too?
...

...

...


or what about having "hex" line numbers?

Think about adding a configurable function (like status line) and be
done forever.

My PHP debugging code also has a problem with signs, they move along
with the content, but the debugger does not know about it.
Eg breakpoint at line 10 will remain breakpoint at line 10.

Using such a function you could do much more eventually.

Having syntax support would be fun, too.

I don't use them much, so I don't care. Just trying to understand what
would make everybody happy easily.

my two cents
Marc Weber

skeept

unread,
May 29, 2013, 11:08:59 AM5/29/13
to vim...@googlegroups.com
>
> Think about adding a configurable function (like status line) and be
>
> done forever.
>
> Marc Weber

This should be the best way to go about it.

Jorge

tooth pik

unread,
May 29, 2013, 11:31:20 AM5/29/13
to vim...@googlegroups.com
ok, looking at the code it's a simple change in two places in screen.c
(lines 2339 and 3509) to get the current line number back to zero when
in relativity mode

and I THINK the simplest way to proceed would be to add one
independent option, relativenumbershowzero, abbreviated rnu0, which
would affect only relative numbers and not need to be toggled when
toggling number modes (but could be toggled by people who just love
tweaking things)

the reason for the long option name is to force it to be right next
relativenumber in the help module

my personal opinion would be to have the default for rnu0 to be on, but
we should vote on that, with Bram as the decider since most people won't
care or vote

(when I first expressed enthusiasm for relative numbers they showed the
zero, not some misaligned line number that's repeated in the ruler -- it
looks suspiciously like something that was snuck in my someone just
showing off (looky what I can do!))

Ben Fritz

unread,
May 29, 2013, 2:48:05 PM5/29/13
to vim...@googlegroups.com
On Wednesday, May 29, 2013 10:31:20 AM UTC-5, toothpik wrote:
>
>
> ok, looking at the code it's a simple change in two places in screen.c
>
> (lines 2339 and 3509) to get the current line number back to zero when
>
> in relativity mode
>
>

Maybe, but this was specifically added as a feature so I doubt it will get
reverted.

I certainly prefer the line number instead of zero.

>
> my personal opinion would be to have the default for rnu0 to be on, but
> we should vote on that, with Bram as the decider since most people won't
> care or vote
>

In the vim_dev thread Christian mentioned (
https://groups.google.com/group/vim_dev/msg/194c62c57ddf9ee9 ) Bram
already said explicitly that he didn't want another option for this.

>
> (when I first expressed enthusiasm for relative numbers they showed the
> zero, not some misaligned line number that's repeated in the ruler -- it
> looks suspiciously like something that was snuck in my someone just
> showing off (looky what I can do!))
>

It wasn't. It was a "the zero is useless; let's display some useful
information there instead" argument with lots of discussion.

Not everybody shows the line number in their status line or ruler, or
shows either of those things at all, and they may want to be able to see a
line number still. Or in my case, I may have so many open windows that the
line number in the status line is much harder to pick out than if I just
scan over to the left on my current line. Or maybe the statusline setting
is such that line numbers get truncated on narrow windows. Additionally,
when Vim doesn't have input focus (for referring to line numbers in an
email or something), you can't even ":set number" easily to see line
numbers in your window. My solution to this is a FocusLost autocmd but
that pre-dated the line number at the cursor line in relativenumber mode.
Perhaps I would have just used that (and mentally added or subtracted the
line number) were it available before I made my FocusGained/FocusLost
autocmds.

There are plenty of use cases where an absolute line number in the
relative column is very useful, and currently the only complaint is "it
makes my number column a few characters wider and I don't like that".

How about a different solution? We could modify the behavior of that
absolute number, to make it so that one absolute numbered line isn't
allowed to expand the line number column. If it won't fit, show zero or
truncate it with < like in the statusline or something. If a user wants to
show it anyway they can increase their 'numberwidth' option.

I was going to see what happens to the normal line number column when the
limit of width 10 is reached, but Vim has been chugging away for almost an
hour trying to load a 3GB file (I let a cmd.exe "for" loop run for a while
to create a huge file with nothing but DOS-style line endings); even with
no plugins, eventignore set to "all", undolevels set to -1, and using the
:view command to avoid a swap file. So I think I'll give up on waiting for
that.

tooth pik

unread,
May 29, 2013, 3:45:51 PM5/29/13
to vim...@googlegroups.com
On Wed, May 29, 2013 at 11:48:05AM -0700, Ben Fritz wrote:
> On Wednesday, May 29, 2013 10:31:20 AM UTC-5, toothpik wrote:
> >
> > ok, looking at the code it's a simple change in two places in screen.c
> > (lines 2339 and 3509) to get the current line number back to zero when
> > in relativity mode

> Maybe, but this was specifically added as a feature so I doubt it will get
> reverted.

> I certainly prefer the line number instead of zero.

> > my personal opinion would be to have the default for rnu0 to be on, but
> > we should vote on that, with Bram as the decider since most people won't
> > care or vote

> In the vim_dev thread Christian mentioned (
> https://groups.google.com/group/vim_dev/msg/194c62c57ddf9ee9 ) Bram
> already said explicitly that he didn't want another option for this.

well that's a show-stopper for me -- I was trying to share the "best"
solution with the community

going forward, I will keep my screen.c with my own mods for my taste,
along with my changes to feature.h -- the extent of my gift to the
community will have to be those line numbers in screen.c -- if you
feel as I do, go there and whack or comment those 5 lines (followed by
a commit, a merge to the previous head, and another commit)

> > (when I first expressed enthusiasm for relative numbers they showed the
> > zero, not some misaligned line number that's repeated in the ruler -- it
> > looks suspiciously like something that was snuck in my someone just
> > showing off (looky what I can do!))

> It wasn't. It was a "the zero is useless; let's display some useful
> information there instead" argument with lots of discussion.

I must have been asleep or distracted -- my bad -- to me the zero is
simply what belongs there

> Not everybody shows the line number in their status line or ruler, or
> shows either of those things at all, and they may want to be able to see a
> line number still. Or in my case, I may have so many open windows that the
> line number in the status line is much harder to pick out than if I just
> scan over to the left on my current line. Or maybe the statusline setting
> is such that line numbers get truncated on narrow windows. Additionally,
> when Vim doesn't have input focus (for referring to line numbers in an
> email or something), you can't even ":set number" easily to see line
> numbers in your window. My solution to this is a FocusLost autocmd but
> that pre-dated the line number at the cursor line in relativenumber mode.
> Perhaps I would have just used that (and mentally added or subtracted the
> line number) were it available before I made my FocusGained/FocusLost
> autocmds.

> There are plenty of use cases where an absolute line number in the
> relative column is very useful, and currently the only complaint is "it
> makes my number column a few characters wider and I don't like that".

I guess my 'redundant and distracting and mis-aligned' is chopped
liver

> How about a different solution? We could modify the behavior of that
> absolute number, to make it so that one absolute numbered line isn't
> allowed to expand the line number column. If it won't fit, show zero or
> truncate it with < like in the statusline or something. If a user wants to
> show it anyway they can increase their 'numberwidth' option.

my problem isn't with the width, and I think the code is complicated
enough -- if we're going to show the number, I think we should show
all of it

> I was going to see what happens to the normal line number column when the
> limit of width 10 is reached, but Vim has been chugging away for almost an
> hour trying to load a 3GB file (I let a cmd.exe "for" loop run for a while
> to create a huge file with nothing but DOS-style line endings); even with
> no plugins, eventignore set to "all", undolevels set to -1, and using the
> :view command to avoid a swap file. So I think I'll give up on waiting for
> that.

and I also will give up on my misguided attempt to modify vim for
everybody -- I will simply modify it for me

I apologize for the noise

Ben Fritz

unread,
May 29, 2013, 4:17:23 PM5/29/13
to vim...@googlegroups.com
On Wednesday, May 29, 2013 2:45:51 PM UTC-5, toothpik wrote:
> On Wed, May 29, 2013 at 11:48:05AM -0700, Ben Fritz wrote:
> > There are plenty of use cases where an absolute line number in the
> > relative column is very useful, and currently the only complaint is "it
> > makes my number column a few characters wider and I don't like that".
>
> I guess my 'redundant and distracting and mis-aligned' is chopped
> liver
>

No, it's useful feedback, but there are constraints on the solution:

1. Don't remove support for the line number in place of zero entirely
2. No new options specifically to control this feature

Personally I thought Bram pulled the trigger on than absolute line number thing before consensus was reached on how it should work. But patches speak louder than words either way.

I like the proposal by "glts" myself:

> - ":set nonu nornu" means: I don't want any line numbers;
> - ":set nu nornu" means: I want to see only absolute numbers;
> - ":set nonu rnu" means: I want to see only relative numbers;
> - ":set nu rnu" means: I want to have the best of both worlds.

Christian, what is the problem you have with this approach?

Christian Brabandt

unread,
May 29, 2013, 6:11:42 PM5/29/13
to vim...@googlegroups.com
On Mi, 29 Mai 2013, Ben Fritz wrote:

> I like the proposal by "glts" myself:
>
> > - ":set nonu nornu" means: I don't want any line numbers;
> > - ":set nu nornu" means: I want to see only absolute numbers;
> > - ":set nonu rnu" means: I want to see only relative numbers;
> > - ":set nu rnu" means: I want to have the best of both worlds.
>
> Christian, what is the problem you have with this approach?

I think, this is confusing. But as I said, I don't have a strong opinion
on that, so here is a patch to try out:

regards,
Christian
--
Wie man sein Kind nicht nennen sollte:
Bill Jard
number_relativenumber.diff

Grant

unread,
Jun 2, 2013, 1:07:06 PM6/2/13
to vim...@googlegroups.com

Stepping away from the relative number issue for a second (hopefully it will move to and not die in the vim_dev list), I wrote my own version of showmarks that is way simpler (does less stuff) and doesn't have the lag that showmarks does. At the moment I restrict attention to the lower-case letter marks, which are the only ones I care about. I've attached it.

It's real nice to have your marks show up in the signs column.

grantmarks.vim

Marc Weber

unread,
Jun 2, 2013, 1:15:22 PM6/2/13
to vim_use
I'd like to draw attention to github.com/MarcWeber/vim-addon-signs
It takes care of removing signs automatically. All you do is passing a
list of signs to be placed. The library takes care of keeping signs,
dropping signs and adding new ones.

Marc Weber
Reply all
Reply to author
Forward
0 new messages