From owner-freebsd-questions@FreeBSD.ORG Sat Sep 6 04:43:55 2014 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 12079261 for ; Sat, 6 Sep 2014 04:43:55 +0000 (UTC) Received: from mx02.qsc.de (mx02.qsc.de [213.148.130.14]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A2A7A1F76 for ; Sat, 6 Sep 2014 04:43:54 +0000 (UTC) Received: from r56.edvax.de (port-92-195-111-1.dynamic.qsc.de [92.195.111.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx02.qsc.de (Postfix) with ESMTPS id 817BB24816; Sat, 6 Sep 2014 06:43:50 +0200 (CEST) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id s864hn4e004518; Sat, 6 Sep 2014 06:43:50 +0200 (CEST) (envelope-from freebsd@edvax.de) Date: Sat, 6 Sep 2014 06:43:49 +0200 From: Polytropon To: Alex Stangl 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> Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Sep 2014 04:43:55 -0000 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, ...