I'm looking for a way to highlight ^M(CR) in vim.
Make sure fileformat is set=unix or mac mine is:
set fileformats=unix,mac
If it is DOS you will not see it
I have a mapping in my .vimrc that will remove them, but this response here explains it best.
https://stackoverflow.com/a/3852892/2869058
You can view all terminal line endings and characters by enabling
:set list
one way you can highlight them is like this in your .vimrc:
syntax on
set list listchars=trail:_
set listchars=tab:·\ ,trail:·,extends:»,precedes:«
:highlight SpecialKey ctermfg=darkgrey ctermbg=yellow
Related
In vim, I want to:
highlight a single line (e.g. :hi CursorLine ctermbg=black)
AND
maintain syntax highlighting
AND
not set up any custom color themes or similar
(note: adding a few lines to .vimrc is fine)
I've tried setting via :hi CursorLine ctermbg=black, but this results in changing the cursor highlight color but not maintaining syntax coloring.
not highlighted, and has syntax coloring:
highlighted, but loses syntax coloring:
in above example, I would want the string word to stay purple, if word stay yellow, etc., even though line is highlighted.
I also tried toggling :syntax off :syntax on, and not surprisingly this had no effect.
This question (Syntax highlighting in vim) seems similar to what I'm asking, but it's not because 1) I don't want to change the background, 2) I don't want to change theme, 3) it seems like OP here was having trouble with existing syntax color scheme and just wanted to be able to see things.
This question (Custom syntax coloring vim) seems similar to what I'm asking, but it's not because 1) I don't want to change existing syntax coloring, I want to keep it, 2) I don't want to add arbitrary syntax highlighting, I just want CursorLine to be highlighted while also maintaining syntax coloring.
I got my desired behavior by running :hi CursorLine ctermbg=black term=none cterm=none.
And while out of scope of my original question, running :set cursorline is also needed for the line highlighting to be displayed.
This seemed to work for me ...
:hi CursorLine cterm=NONE guifg=NONE
I am trying to change the spellcheck highlight group. So in the end of my .vimrc
I add the following code
highlight clear SpellBad
highlight SpellBad cterm=underline
when I open a new file, it is still showing the old syntax highlighting. But if I run the same commands inside vim manually after opened the file, it will work as expected.
Any idea what is going wrong here? Thanks!
Tweaks to a colorscheme have to happen after the colorscheme has been set. Usually, if you have the :colorscheme in your ~/.vimrc, and put the :highlight commands after it, that should work.
Your case seems to be different (which could be caused by a plugin manager affecting the loading order, or you might even have a dynamically changing colorscheme). To handle such eventualities, you can instead hook into the ColorScheme event:
autocmd ColorScheme * highlight clear SpellBad
autocmd ColorScheme * highlight SpellBad cterm=underline
UPDATE 16-03-01:
I changed the highlight option to make text dark green, as you can see in the picture. Notice the cursor is on one of the parenthesis, making them both orange, but there's no cursor:
EDIT (SOLVED):
I just deleted the .vimrc file entirely and now the cursor is back so there was some typo or problem in there that messed with it.
ORIGINAL:
I don't have any cursor, box or line in vim. I'm using vim through the latest version of cmder. I'm new to vim but I couldn't find anyone else with a similar problem.
You can set cursorline using
set cursorline
in your ~/.vimrc file. But this looks clumsy with a long line
and you can remedied by highlighting cursorline
highlight CursorLine cterm=NONE ctermbg=NONE ctermfg=darkgreen
You can select your own colour, here I have used darkgreen.
where cterm is terminal colour, set to NONE
ctermbg back ground color of terminal. also set to NONE here
Please add the following to your ~/.vimrc
set nocompatible
set mouse=a
set cursorline
In a short, the behavior of VIM is configured by the ~/.vimrc file, you should add configurations in it for yourself.
On my system, I've aliased less to vim's less.sh macro (let's call it vless). For some reason, this macro doesn't fully import the line-highlighting settings in my .vimrc .
vless turns on highlighting, but uses underlining instead of bg+bold. In comparison, vim does exactly what I want. See pictures below. How do I fix this?
vimrc in vim:
Same file in (v)less:
Try using vimpager which is the successor to less.sh.
If you actually wanted to change the highlighting after less.sh did its own highlighting you could create the file ~/.vim/after/colors/<colorscheme_name>.vim with the following contents.
hi CursorLine term=bold cterm=bold ctermbg=Black
This should be sourced after less.sh does its own configuration.
Is there a way to set different colors for the command line color and the "Normal" text color in vim. When I use
:hi Normal guifg=orange
the command line and the normal text color become orange. I would like the command line at the bottom of the gui to be a different color however.
Nowadays NeoVim has the feature. MsgArea color group. e.g.
:hi MsgArea guifg=#03ff13
No, not that I know of.
Not without messing with Vim's source.
The command line is under Normal highlighting group.
This can be done with autocommands:
hi Normal=white guifg=white
au CmdLineEnter * hi Normal ctermfg=cyan guifg=cyan
au CmdLineLeave * hi Normal ctermfg=white guifg=white
Surprisingly to me, this only affects the CmdLine, not everything else.
I had expected all the normal text to change color immediately when entering the CmdLine. Without the CmdLineLeave, the change to the normal text everywhere happens, but only after getting out of the command line; which explains why it does what we want.
Note that I am using vim from a terminal, so I am using ctermfg instead of guifg; but I anticipate that it will work the same way with a gui version of vim.
You may also want to highlight the ModeMsg.
That can be done via new wincolor option that was introduced in Vim 8.2:
set wincolor=NormalAlt
autocmd WinEnter set wincolor=NormalAlt
hi Normal guifg=#CED1CF guibg=#000000 gui=NONE
hi NormalAlt guifg=#CED1CF guibg=#1B1D21 gui=NONE