LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   VIM: Can't see Certain keywords (https://www.linuxquestions.org/questions/programming-9/vim-cant-see-certain-keywords-4175593381/)

andrew.comly 11-12-2016 05:52 AM

VIM: Can't see Certain keywords
 
Search Terms:
UTG: Unidentified Text Group
IDE, group, keywords, colorscheme, visibility
________________________________________________________________________

I am on Lubuntu 14.04 using VIM - Vi IMproved 7.4 through xterm.

I would like to see certain text in both "morning" and "shiny" color themes. Both of these themes have a bright near white background, and there are certain keywords, in bright yellow, which is extremely hard to see with a white background.

Examples:
Quote:

if elif, else, fi, for, do, done, echo, etc...
I wonder if this is the "NonText" group?

I search for "yellow" in both the /etc/vim/vimrc and /usr/share/vim/vim74/colors/am.vim, but simply nothing is set to "yellow".

The following attempts are solutions I found online.

_____________________________________________
Attempt 01:
I tried the first 4 examples work:
Code:

highlight Comment ctermbg=DarkGray
highlight Constant ctermbg=Blue
highlight Normal ctermbg=Black
highlight Special ctermbg=DarkMagenta
highlight NonText ctermbg=Black

Unfortunately, the last command (NonText) has no effect:

I try other foreground colors, but nothing works.

_____________________________________________
Attempt 02: '

Previously I had some problems with my cursor background/foreground color being the same as the general background color (as in "morning" and "shiny" colorschemes) and thanks to Astrogeek, I was able to fix it with a termcap conditional clause. I found a codename for NonText on sourceforge. Thus I tried altering that same clause to fit that of NonText in my colorscheme (am.vim) file:
Code:

if &term =~ "xterm\\|rxvt"
" use an red cursor in insert mode
let &hl-NonText = "\<Esc>]12;red\x7"
silent !echo -ne "\033]12;red\007"
" reset cursor when vim exits
autocmd VimLeave * silent !echo -ne "\033]112\007"
" use \003]12;gray\007 for gnome-terminal                       
endif

This merely produces a few error codes, and all the same words are still in yellow.

This is not a very high priority, since my workaround is to use GVim (no problems adjusting this by attempt 01 above!!) and not xterm.

I also tried an older post LQ which provides a working Vim config with a "nontext" color definition, but nothing worked for me either.

Does anyone know how to change the aforesaid word color to foreground = black? Have I guessed correctly in saying that these words are of the group named "NonText"?

norobro 11-12-2016 03:57 PM

Quote:

Have I guessed correctly in saying that these words are of the group named "NonText"?
Try changing the "Statement" group color to black. From the link that astrogeek provided in your previous thread: http://vimdoc.sourceforge.net/htmldo...tml#group-name

astrogeek 11-12-2016 10:49 PM

Quote:

Originally Posted by andrew.comly (Post 5629678)
I would like to see certain text in both "morning" and "shiny" color themes. Both of these themes have a bright near white background, and there are certain keywords, in bright yellow, which is extremely hard to see with a white background.

Examples:

Code:

if elif, else, fi, for, do, done, echo, etc...
I wonder if this is the "NonText" group?

...

Does anyone know how to change the aforesaid word color to foreground = black? Have I guessed correctly in saying that these words are of the group named "NonText"?

No those are not in the NonText group. From the docs:

Code:

NonText  '~' and '@' at the end of the window, characters from
                'showbreak' and other characters that do not really exist in
                the text (e.g., ">" displayed when a double-wide character
                doesn't fit at the end of the line).

Looking for a NonText solution has trapped us in an XY problem since your thread about Vim cursor colors!

For completeness, the above NonText examples are almost certainly working for the NonText characters described above, but those are not what you are looking at for evidence of change.

For if elif, else, fi, for, do, done, echo, etc., you want the Conditional sub-group of the Statement group, as indicated by norobro. So, something like this would affect those keywords, choose your colors as required:

Code:

highlight Conditional ctermbg=Black
highlight Conditional ctermfg=White

In looking further into this I have gotten a needed refresher on Vim syntax hilighting myself, so here are some additional notes that should be helpful in answering these and other questions...

The docs: The previously linked Vimdocs on Sourceforge are always handy, but you probably have the same docs for your Vim package available on your system. Look under /usr/share/vim/vim74/docs/ or wherever your distro places shared docs, and learn your way around them.

The basics of syntax hilighting: The complete reference on Vim syntax hilighting from those docs, simply start at the top and read down - it is complete! In particular, follow the link to the Syntax page for a very good overview of how the syntax hilighting files are found and loaded.

It all works as advertised, when we identify and ask the right question!

Hope this helps!

andrew.comly 11-17-2016 03:21 AM

Solved
 
Quote:

Originally Posted by astrogeek (Post 5629990)
No those are not in the NonText group. From the docs:

Code:

NonText  '~' and '@' at the end of the window, characters from
                'showbreak' and other characters that do not really exist in
                the text (e.g., ">" displayed when a double-wide character
                doesn't fit at the end of the line).

...
The basics of syntax hilighting: The complete reference on Vim syntax hilighting from those docs, simply start at the top and read down - it is complete! In particular, follow the link to the Syntax page for a very good overview of how the syntax hilighting files are found and loaded.
...


Astrogeek & norobro,

I found just what I needed on your and norobro's Syntax Page, more specifically:
Code:

        Statement          any statement
        Conditional        if, then, else, endif, switch, etc.
        Repeat                        for, do, while, etc.

However, their description for "Statement" is a bit vague. This helped me with words (LaTeX) like
Code:

Preamble:
        \usepackage
Functions:
        \arcsin, \qquad, \int, \frac, \sqrt, ^
Formatting:
        \begin{align}, \end{align}

Thanks Again Astrogeek and norobro!

Hope this helps anyone who has this problem in the future.


All times are GMT -5. The time now is 07:25 AM.