在 2013年1月30日星期三UTC+8上午5时33分42秒,Bram Moolenaar写道:
> Nazri Ramliy wrote:
> 
> 
> 
> > On Tue, Jan 29, 2013 at 6:21 PM, Paul Ruane  wrote:
> 
> > > Whilst it is not that hard to scan the status line, I find that I hit
> 
> > > this glitch in my workflow many, many times a day: when I want to know
> 
> > > what line I am on, I intuitively scan the gutter for the line number.
> 
> > > I then realise that relativenumber is on so I redirect my attention to
> 
> > > the status line and then have to parse the number from the other
> 
> > > fields down there.
> 
> > 
> 
> > The following patch does what you want. After trying it out for a few 
> > minutes
> 
> > it does feel easier to find out the current line number. I normally
> 
> > have the line
> 
> > number in my statusline, and on the occasion where the statusline is not 
> > shown
> 
> > I've trained my fingers to hit Ctrl+G and scan the bottom line for the
> 
> > line number.
> 
> > 
> 
> > Having the current line number, instead of a '0' shown at the current
> 
> > line seems more useful. For better distinction the current line number
> 
> > ca be left-aligned (for left-to-right text orientation) to make it
> 
> > look different than the relative-line-numbers (I made no attempt at
> 
> > this in the patch below).
> 
> > 
> 
> > Others might find it weird.
> 
> 
> 
> I think the information is useful.  Who is against showing the current
> 
> line number instead of zero?
> 
> 
> 
> Is the width of the column a problem?
> 
> 
> 
> -- 
> 
> "Hegel was right when he said that we learn from history that man can
> 
> never learn anything from history."       (George Bernard Shaw)
> 
> 
> 
>  /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
> 
> ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
> 
> \\\  an exciting new programming language -- http://www.Zimbu.org        ///
> 
>  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

Here is a patch that adds an option 'rnucurrent'/'rnuc' to control the current 
line number style: left-align, absolute line number.

-- 
-- 
You received this message from the "vim_dev" 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_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


diff -r 30b3b1da0350 src/option.c
--- a/src/option.c	Thu Jan 31 21:09:15 2013 +0100
+++ b/src/option.c	Wed Feb 06 17:29:05 2013 +0800
@@ -2107,6 +2107,9 @@
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
 			    SCRIPTID_INIT},
+    {"rnucurrent", "rnuc",  P_STRING|P_VIM|P_VI_DEF|P_COMMA|P_NODUP|P_RALL,
+			    (char_u *)&p_rnuc, PV_NONE,
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"ruler",	    "ru",   P_BOOL|P_VI_DEF|P_VIM|P_RSTAT,
 #ifdef FEAT_CMDL_INFO
 			    (char_u *)&p_ru, PV_NONE,
@@ -2983,6 +2986,7 @@
 #ifdef FEAT_INS_EXPAND
 static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", NULL};
 #endif
+static char *(p_rnuc_values[]) = {"absolute", "left", NULL};
 
 static void set_option_default __ARGS((int, int opt_flags, int compatible));
 static void set_options_default __ARGS((int opt_flags));
@@ -3566,6 +3570,7 @@
 #ifdef FEAT_EVAL
     set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
 #endif
+    p_rnuc_n = 0;
 }
 
 /*
@@ -6930,6 +6935,21 @@
     }
 #endif
 
+    /* 'rnucurrent' */
+    else if (varp == &p_rnuc)
+    {
+	if (check_opt_strings(p_rnuc, p_rnuc_values, TRUE) != OK)
+	    errmsg = e_invarg;
+	else
+	{
+	    p_rnuc_n = 0;
+	    if (strstr((char *)p_rnuc, "absolute") != NULL)
+		p_rnuc_n |= RNUC_ABSOLUTE;
+	    if (strstr((char *)p_rnuc, "left") != NULL)
+		p_rnuc_n |= RNUC_LEFT;
+	}
+    }
+
 #if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
     else if (varp == &p_csqf)
     {
diff -r 30b3b1da0350 src/option.h
--- a/src/option.h	Thu Jan 31 21:09:15 2013 +0100
+++ b/src/option.h	Wed Feb 06 17:29:05 2013 +0800
@@ -663,6 +663,10 @@
 EXTERN int	p_ari;		/* 'allowrevins' */
 EXTERN int	p_ri;		/* 'revins' */
 #endif
+#define RNUC_ABSOLUTE	0x1
+#define RNUC_LEFT	0x2
+EXTERN char_u	*p_rnuc;	/* 'rnucurrent */
+EXTERN int	p_rnuc_n;
 #ifdef FEAT_CMDL_INFO
 EXTERN int	p_ru;		/* 'ruler' */
 #endif
diff -r 30b3b1da0350 src/screen.c
--- a/src/screen.c	Thu Jan 31 21:09:15 2013 +0100
+++ b/src/screen.c	Wed Feb 06 17:29:05 2013 +0800
@@ -2333,8 +2333,10 @@
 		num = labs((long)get_cursor_rel_lnum(wp, lnum));
 		if (num == 0)
 		{
-		    num = lnum;
-		    fmt = "%-*ld ";
+		    if (p_rnuc_n & RNUC_ABSOLUTE)
+			num = lnum;
+		    if (p_rnuc_n & RNUC_LEFT)
+			fmt = "%-*ld ";
 		}
 	    }
 
@@ -3503,8 +3505,10 @@
 			    num = labs((long)get_cursor_rel_lnum(wp, lnum));
 			    if (num == 0)
 			    {
-				num = lnum;
-				fmt = "%-*ld ";
+				if  (p_rnuc_n & RNUC_ABSOLUTE)
+				    num = lnum;
+				if (p_rnuc_n & RNUC_LEFT)
+				    fmt = "%-*ld ";
 			    }
 			}
 
@@ -3529,8 +3533,9 @@
 		     * the current line differently.
 		     * TODO: Can we use CursorLine instead of CursorLineNr
 		     * when CursorLineNr isn't set? */
-		    if ((wp->w_p_cul || wp->w_p_rnu)
-						 && lnum == wp->w_cursor.lnum)
+		    if (lnum == wp->w_cursor.lnum
+			&& (wp->w_p_cul
+			    || (wp->w_p_rnu && (p_rnuc_n & RNUC_ABSOLUTE))))
 			char_attr = hl_attr(HLF_CLN);
 #endif
 		}
@@ -10255,7 +10260,10 @@
     int		n;
     linenr_T	lnum;
 
-    lnum = wp->w_buffer->b_ml.ml_line_count;
+    if (wp->w_p_nu || (wp->w_p_rnu && (p_rnuc_n & RNUC_ABSOLUTE)))
+	lnum = wp->w_buffer->b_ml.ml_line_count;
+    else
+	lnum = wp->w_height;
 
     if (lnum == wp->w_nrwidth_line_count)
 	return wp->w_nrwidth_width;

Raspunde prin e-mail lui