Column ruler (like line numbers) in vi / vim / gvim

Polytropon freebsd at edvax.de
Sun Sep 7 04:23:35 UTC 2014


On Sat, 6 Sep 2014 13:41:37 -0400, Paul Kraus wrote:
> On Sep 5, 2014, at 19:23, Polytropon <freebsd at edvax.de> wrote:
> 
> > There is _one_ feature that I didn't find in vi / vim / gvim,
> > and especially in regards of column-oriented data files, this
> > would be really helpful: a real COLUMN RULER on top. I have
> > "set number" and "set ruler" already in ~/.vimrc, but this
> > involves too much "eye travel". I'd like to quickly see column
> > numbers (on top) like I can see line numbers (on the left).
> > 
> > As a grown-old mainframe person, I'm thinking about something
> > like this:
> > 
> > |...+....1....+....2....+....3....+....4....+....5....+….6
> 
> I have been cheating this for years, I use a line very much like
> the above as a comment and separator when I am writing scripts :-)
> 
> #————1————2————3————4————5————6————7————8

Well, I actually did the same in comment headers and templates,
but the disadvantage was that this ruler didn't "move with the
content". I've been using a similar approach for editing CSV files,
but again, with sufficient lines, the top ruler became invisible.
I then made a copy of it at the bottom of the file, handy for
adding data. But when having to change something within a 800
line file, each line 500 chars wide, this doesn't help much.

How I could even solve the ^Wp problem by a terrible idea:

setl scrollbind scrollopt+=hor
abo sp +enew
call setline(1,'    ....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+....|....+....|....+....|....+....|')
let &l:stl="%#Normal#".repeat(' ',winwidth(0))
res 1
setl scrollbind nomod buftype=nofile winfixheight nonumber nocursorline
wincmd p	" doesn't seem to work
call feedkeys("\<C-W>p", 't')

Yes, I send the keystrokes "manually". :-)

The "quit quicky" and the "not more than 999 lines" problem is
still present (with the last one solved by re-enabling line numers
for the one line in that buffer).

An advantage of the above solution is that it's easy to adapt to
other "format rulers", for example for custom CSV files, for
configuration files (column-oriented ones typically), or if you're
really really brave, for RPG. :-)



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...


More information about the freebsd-questions mailing list