Date: Sat, 6 Sep 2014 06:43:49 +0200 From: Polytropon <freebsd@edvax.de> To: Alex Stangl <alex@stangl.us> Cc: freebsd-questions@freebsd.org Subject: Re: Column ruler (like line numbers) in vi / vim / gvim Message-ID: <20140906064349.32e55425.freebsd@edvax.de> In-Reply-To: <20140906022658.GA19618@scout.stangl.us> References: <20140906012327.3320bd39.freebsd@edvax.de> <20140906022658.GA19618@scout.stangl.us>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 5 Sep 2014 21:26:58 -0500, Alex Stangl wrote: > Hi Polytropen, > > Check out > http://vim.1045645.n5.nabble.com/Horizontal-Ruler-in-interface-td5590000.html > > I just tried the last suggestion on that page (from Christian Brabrandt) > and it works great, and can be easily adapted to any of the formats you > like. To make the ruler go away, you can type Ctrl-W o I had already found this, but it didn't work as intended. I found it in my local ~/.vim/plugin/ directory (deactivated). But it was an inspiration, so I came up with this idea which is 99% of what I was searching for: 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 First I had the original call setline(1,repeat('....+....|',20)) line (modified from 2nd to 1st line of the buffer) and then had a replacement orgy :1s/|/1/1 :1s/|/2/2 :1s/|/3/3 :1s/|/4/4 :1s/|/5/5 :1s/|/6/6 :1s/|/7/7 :1s/|/8/8 :1s/|/9/9 to replace the 1st | with 1, the 2nd with 2 and so on (up to 9). But then I thought: I can do this manually, it would be easier. :-) Maybe there's an expression for "search for the pattern P, and replace P with the number n, where n corresponds to the n-th instance of the pattern found". Maybe a regex wizard can tell me if this is possible? The spaces infront of the manually defined ruler represent the indentation for line numbers (which the buffer should not have). The spacing is for up to 999 lines, this is what vim aligns the numbers to (as in "%3d"). As you can see, the buffer also has an override for "set cursorline" which I have in my ~/.vimrc. Cosmetically I haven't found a way yet to remove the empty line between the buffer and the file to edit. Currently it looks like this (vim /usr/include/stdio.h): ....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+. 1 /*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. > It's not clear how you want the ruler to work in wrap mode, > so maybe that doesn't work as you like. I didn't want the ruler in wrap mode - it wouldn't work. :-) Instead I had to "set nowrap" for any content edited which works nicely with the above solution: when scrolling the file horizontally, the buffers scrolls along. There is still one problem: The "wincmd p" doesn't seem to be executed, I have to manually use Ctrl+W p to be able to work with a file (instead with the ruler). Oh, and an additional quit command is to be used for the ruler (:q :q or :qa!), except I use the window manager's key combination to close the window (possible with gvim, but for vim inside a terminal, the whole terminal is closed). -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140906064349.32e55425.freebsd>