Hi Vimmers, 

I recently became a full hog vim guy.  I use it on the terminal  a lot and I 
wanted to make it so the cursor line number had its own syntax highlighting.  
This is because on a Linux terminal there isn't a subtle way of emphasizing the 
current line.  As a result I created this patch. The patch creates a 
CursorLineNr highlighting group.  It is only active if cursorline is set.  But 
it allows the user to change the line number highlighting independently of the 
rest of the line. 

The following would shut off highlighting on the text, but set the line number 
color to 3.
      
:syntax on
:set cursorline
:hi CursorLine cterm=none
:hi CursorLineNr ctermfg=3

Bram suggested I submit my patch on this list, and as a result I include it 
here.  I hope you try it and like it.  


Thanks for your consideration,
LHB jr.
p.s. I also attach the same file in case the mail system corrupts the patch.



------------------------
diff -r f530aef0d959 src/option.c
--- a/src/option.c    Wed Oct 12 22:02:14 2011 +0200
+++ b/src/option.c    Wed Oct 19 21:21:16 2011 -0400
@@ -460,9 +460,9 @@
 #if defined(FEAT_DIFF) || defined(FEAT_FOLDING) || defined(FEAT_SPELL) \
     || defined(FEAT_VERTSPLIT) || defined(FEAT_CLIPBOARD) \
     || defined(FEAT_INS_EXPAND) || defined(FEAT_SYN_HL) || 
defined(FEAT_CONCEAL)
-# define HIGHLIGHT_INIT 
"8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn"
-#else
-# define HIGHLIGHT_INIT 
"8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,r:Question,s:StatusLine,S:StatusLineNC,t:Title,v:Visual,w:WarningMsg,W:WildMenu,>:SignColumn,*:TabLine,#:TabLineSel,_:TabLineFill"
+# define HIGHLIGHT_INIT 
"8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn"
+#else
+# define HIGHLIGHT_INIT 
"8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,t:Title,v:Visual,w:WarningMsg,W:WildMenu,>:SignColumn,*:TabLine,#:TabLineSel,_:TabLineFill"
 #endif
 
 /*
diff -r f530aef0d959 src/screen.c
--- a/src/screen.c    Wed Oct 12 22:02:14 2011 +0200
+++ b/src/screen.c    Wed Oct 19 21:21:16 2011 -0400
@@ -3499,7 +3499,12 @@
             /* When 'cursorline' is set highlight the line number of
              * the current line differently. */
             if (wp->w_p_cul && lnum == wp->w_cursor.lnum)
-            char_attr = hl_combine_attr(hl_attr(HLF_CUL), char_attr);
+/*--------------------------------------------------
+*  Change this so that current line number has its own attr separate from 
+*  current line, so that it may be changed independently.
+*  LHB
+*--------------------------------------------------*/
+            char_attr = hl_attr(HLF_CLN);
 #endif
         }
         }
diff -r f530aef0d959 src/syntax.c
--- a/src/syntax.c    Wed Oct 12 22:02:14 2011 +0200
+++ b/src/syntax.c    Wed Oct 19 21:21:16 2011 -0400
@@ -6540,6 +6540,8 @@
          "Directory term=bold ctermfg=DarkBlue guifg=Blue"),
     CENT("LineNr term=underline ctermfg=Brown",
          "LineNr term=underline ctermfg=Brown guifg=Brown"),
+    CENT("CursorLineNr term=bold ctermfg=Brown",
+         "CursorLineNr term=bold ctermfg=Brown guifg=Brown"),
     CENT("MoreMsg term=bold ctermfg=DarkGreen",
          "MoreMsg term=bold ctermfg=DarkGreen gui=bold guifg=SeaGreen"),
     CENT("Question term=standout ctermfg=DarkGreen",
@@ -6626,6 +6628,8 @@
          "Directory term=bold ctermfg=LightCyan guifg=Cyan"),
     CENT("LineNr term=underline ctermfg=Yellow",
          "LineNr term=underline ctermfg=Yellow guifg=Yellow"),
+    CENT("CursorLineNr term=bold ctermfg=Yellow",
+         "CursorLineNr term=bold ctermfg=Yellow guifg=Yellow"),
     CENT("MoreMsg term=bold ctermfg=LightGreen",
          "MoreMsg term=bold ctermfg=LightGreen gui=bold guifg=SeaGreen"),
     CENT("Question term=standout ctermfg=LightGreen",
diff -r f530aef0d959 src/vim.h
--- a/src/vim.h    Wed Oct 12 22:02:14 2011 +0200
+++ b/src/vim.h    Wed Oct 19 21:21:16 2011 -0400
@@ -1317,6 +1317,7 @@
     , HLF_M        /* "--More--" message */
     , HLF_CM        /* Mode (e.g., "-- INSERT --") */
     , HLF_N        /* line number for ":number" and ":#" commands */
+    , HLF_CLN        /* current line number */
     , HLF_R        /* return to continue message and yes/no questions */
     , HLF_S        /* status lines */
     , HLF_SNC        /* status lines of not-current windows */
@@ -1354,7 +1355,7 @@
 /* The HL_FLAGS must be in the same order as the HLF_ enums!
  * When changing this also adjust the default for 'highlight'. */
 #define HL_FLAGS {'8', '@', 'd', 'e', 'h', 'i', 'l', 'm', 'M', \
-          'n', 'r', 's', 'S', 'c', 't', 'v', 'V', 'w', 'W', \
+          'n', 'N', 'r', 's', 'S', 'c', 't', 'v', 'V', 'w', 'W', \
           'f', 'F', 'A', 'C', 'D', 'T', '-', '>', \
           'B', 'P', 'R', 'L', \
           '+', '=', 'x', 'X', '*', '#', '_', '!', '.', 'o'}


-- 
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
diff -r f530aef0d959 src/option.c
--- a/src/option.c	Wed Oct 12 22:02:14 2011 +0200
+++ b/src/option.c	Wed Oct 19 21:21:16 2011 -0400
@@ -460,9 +460,9 @@
 #if defined(FEAT_DIFF) || defined(FEAT_FOLDING) || defined(FEAT_SPELL) \
 	|| defined(FEAT_VERTSPLIT) || defined(FEAT_CLIPBOARD) \
 	|| defined(FEAT_INS_EXPAND) || defined(FEAT_SYN_HL) || defined(FEAT_CONCEAL)
-# define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn"
-#else
-# define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,r:Question,s:StatusLine,S:StatusLineNC,t:Title,v:Visual,w:WarningMsg,W:WildMenu,>:SignColumn,*:TabLine,#:TabLineSel,_:TabLineFill"
+# define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn"
+#else
+# define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,t:Title,v:Visual,w:WarningMsg,W:WildMenu,>:SignColumn,*:TabLine,#:TabLineSel,_:TabLineFill"
 #endif
 
 /*
diff -r f530aef0d959 src/screen.c
--- a/src/screen.c	Wed Oct 12 22:02:14 2011 +0200
+++ b/src/screen.c	Wed Oct 19 21:21:16 2011 -0400
@@ -3499,7 +3499,12 @@
 		    /* When 'cursorline' is set highlight the line number of
 		     * the current line differently. */
 		    if (wp->w_p_cul && lnum == wp->w_cursor.lnum)
-			char_attr = hl_combine_attr(hl_attr(HLF_CUL), char_attr);
+/*--------------------------------------------------
+*  Change this so that current line number has its own attr separate from 
+*  current line, so that it may be changed independently.
+*  LHB
+*--------------------------------------------------*/
+			char_attr = hl_attr(HLF_CLN);
 #endif
 		}
 	    }
diff -r f530aef0d959 src/syntax.c
--- a/src/syntax.c	Wed Oct 12 22:02:14 2011 +0200
+++ b/src/syntax.c	Wed Oct 19 21:21:16 2011 -0400
@@ -6540,6 +6540,8 @@
 	     "Directory term=bold ctermfg=DarkBlue guifg=Blue"),
 	CENT("LineNr term=underline ctermfg=Brown",
 	     "LineNr term=underline ctermfg=Brown guifg=Brown"),
+	CENT("CursorLineNr term=bold ctermfg=Brown",
+	     "CursorLineNr term=bold ctermfg=Brown guifg=Brown"),
 	CENT("MoreMsg term=bold ctermfg=DarkGreen",
 	     "MoreMsg term=bold ctermfg=DarkGreen gui=bold guifg=SeaGreen"),
 	CENT("Question term=standout ctermfg=DarkGreen",
@@ -6626,6 +6628,8 @@
 	     "Directory term=bold ctermfg=LightCyan guifg=Cyan"),
 	CENT("LineNr term=underline ctermfg=Yellow",
 	     "LineNr term=underline ctermfg=Yellow guifg=Yellow"),
+	CENT("CursorLineNr term=bold ctermfg=Yellow",
+	     "CursorLineNr term=bold ctermfg=Yellow guifg=Yellow"),
 	CENT("MoreMsg term=bold ctermfg=LightGreen",
 	     "MoreMsg term=bold ctermfg=LightGreen gui=bold guifg=SeaGreen"),
 	CENT("Question term=standout ctermfg=LightGreen",
diff -r f530aef0d959 src/vim.h
--- a/src/vim.h	Wed Oct 12 22:02:14 2011 +0200
+++ b/src/vim.h	Wed Oct 19 21:21:16 2011 -0400
@@ -1317,6 +1317,7 @@
     , HLF_M	    /* "--More--" message */
     , HLF_CM	    /* Mode (e.g., "-- INSERT --") */
     , HLF_N	    /* line number for ":number" and ":#" commands */
+    , HLF_CLN	    /* current line number */
     , HLF_R	    /* return to continue message and yes/no questions */
     , HLF_S	    /* status lines */
     , HLF_SNC	    /* status lines of not-current windows */
@@ -1354,7 +1355,7 @@
 /* The HL_FLAGS must be in the same order as the HLF_ enums!
  * When changing this also adjust the default for 'highlight'. */
 #define HL_FLAGS {'8', '@', 'd', 'e', 'h', 'i', 'l', 'm', 'M', \
-		  'n', 'r', 's', 'S', 'c', 't', 'v', 'V', 'w', 'W', \
+		  'n', 'N', 'r', 's', 'S', 'c', 't', 'v', 'V', 'w', 'W', \
 		  'f', 'F', 'A', 'C', 'D', 'T', '-', '>', \
 		  'B', 'P', 'R', 'L', \
 		  '+', '=', 'x', 'X', '*', '#', '_', '!', '.', 'o'}

Raspunde prin e-mail lui