I'm trying to force vim to use en_gb as the default dictionary using my vimrc.
My goal is to have it at least for tex files. This is how it is right now.
set spell spelllang=en_gb
vim, unfortunately, can not tell me if color and colour is correct?
If you are just testing those words as the only word in the document, neither is correct: they will both be marked as SpellCap (word not capitalized). If you put in Colour and Color, or if you put another word before them, Colour will not be marked, and Color will be marked as SpellLocal (wrong spelling for selected region). You can see this for yourself using these:
hi SpellBad ctermfg=red
hi SpellCap ctermfg=blue
hi SpellRare ctermfg=green
hi SpellLocal ctermfg=yellow
By default, on many colourschemes, all of those just render the same way (underline), so you can't distinguish them.
You might also find that out by using z= (suggest word) on colour - you'd get Colour as a top correction.
Related
Is it possible to define a custom RGB colour for the background colour of VIM?
At the moment I use set background=dark in my .vimrc which assigns #5D5D5D for the background colour. However, I would prefer to have #3F3F3F for my background colour.
Normally your terminal will support only 256 colors, and they are numbered. If you want to use a particular color but don't know the number, the script gui2term.py will help you to find the most approximate one. Or you can just pick one from a table like this one.
If you are designing or modifying for your own color scheme for Vim, you can also use gui2term.py to translate those colors to the numbers.
Once you get the color number you'd like to use, you can edit your color scheme file. changing (or adding) the ctermbg value for the Normal and NonText group may be enough. E.g.:
highlight Normal guifg=#e0e0e0 guibg=#242424 gui=NONE ctermfg=254 ctermbg=235 cterm=NONE
highlight NonText guifg=#99968b guibg=#242424 gui=NONE ctermfg=246 ctermbg=235 cterm=NONE
There is a nice HTML Vim color scheme editor. You can try this to figure out which part uses which group and if you like, edit the colors visually (and run gui2term.py against the result file to make it support color terminals).
When there's a misspelling (with set spell), it highlights it red (good!), but when the line is highlighted as my current line the red goes away (bad). Removing set cul fixes the problem, but how do I keep the word marked red while being highlighted? I may have multiple words misspelled on a line and also while typing the misspellings are hidden until I go to the next which kinda sucks.
vimrc: https://gist.github.com/OscarGodson/d1b05d52df4ff160b891
colorscheme: https://github.com/tomasr/molokai
1) one could change the vim color scheme, or the SpellBad highlight scheme; one example of the second case is to add in vimrc the following,
hi clear SpellBad
hi SpellBad cterm=bold
2) (not a solution) someone might find 'spell checking while composing' is a bit annoying / distracting and prefer switching the spell checking off until they finish writing the article.
The problem is that the cursorline highlighting has priority over the syntax highlighting (spell errors belong to that), and that cannot be changed. (You can only specify the priority with the newer matchadd() functions.)
I've once raised this issue for error highlighting, but nothing came out of it. (I'd still like to implement a patch for that one day.)
The problem is only about overlap of background highlighting; in GVIM, most color schemes use the undercurl attribute to avoid that issue. In the console, you can only change the highlighting to foreground color, italic or bold attributes to work around it.
workaround
One clever workaround involves swapping the foreground and background colors while adding the reverse attribute: Turn
hi SpellBad cterm=NONE ctermbg=red ctermfg=white
to
hi SpellBad cterm=reverse ctermbg=white ctermfg=red
These two changes cancel each other out normally, but on a CursorLine, the foreground color now contributes to the coloring, turning hard-to-read white-on-cursorline to red-on-cursorline.
Curiously, and jumping off of both answers from the other posters, adding the following in my vimrc made my red background persist accidentally due to my terminal not being able to fulfill the "italic" switch because it can't mix font types like that (I think). I stuck it in the section of my vimrc that is tested for gvim because gvim underlines my spelling mistakes without issue. Give it a try!
if has("gui_running")
#all my gvim settings
else #we're in terminal
hi clear SpellBad
hi SpellBad cterm=bold,italic ctermfg=red
endif
In the theme I'm using for vim, the strings are shown in red color but the problem is I have spellcheck on and the misspelled words are also shown in red color.
This makes it hard to see what is the mistake until you go to that word and delete any character.
I want to make the highlightation of the misspelled word in somewhat lighter then it currently. Say #ff2929.
You can use the hi (short for :help highlight) command in your ~/.vimrc. The general structure is:
hi SpellBad ctermfg=015 ctermbg=000 cterm=none guifg=#FFFFFF guibg=#000000 gui=none
The cterm is for terminal vim and the gui is for gVim. The fg stands for foreground and is the color of the letters and the bg stands for background and is the color behind the letters.
Terminal colors can be 0-15 for standard terminal colors (8 normal and 8 bright) or 0-255 for terms supporting 256 colors, like xterm-256colors. The gui colors are in hexadecimal format. xterm-color-table is a useful reference for both 256 and hexadecimal colors. The final option can be used to specify bold, italic, or none (neither).
In your case, it might be simplest to set the foreground to black to make the letters stand out. First, find a word that's mispelled with :set spell and then typing asdflkjasldf or something. Then type :hi SpellBad ctermfg=000 guifg=#000 and see if that's a solution you like. If not, use the xterm-color-table or another color reference to find a color you do like.
Try this:
:hi SpellBad guibg=#ff2929 ctermbg=224
guibg is for GUI
ctermbg is for TERM
I found the following to halfway work for a more complex example involving colorscheme, but it is sensitive to the order of .vimrc commands. I tested with Cygwin/mintty and Git Bash, vim 8.0, with similar results. I edited a markdown file with "misspelled" words in headings and paragraphs, so an additional factor is the auto-formatting that vim is doing for markdown. If the .vimrc order is spell, colorscheme, and then hi (trying to use white text on red background), the result for misspelled words is white foreground on black background (image below), regardless of whether in markdown heading or paragraph. This is OK but I'd prefer to have the background for misspelled words be more eye-catching, which is why I specified red background.
However, if the order is spell, hi, and colorscheme, the result is OK in paragraphs but undesired pink on red in headers (image below). This is actually the original behavior without hi, which makes sense because the colorscheme is probably stepping on the hi settings. Based on other testing, the relative position of hi and colorscheme is what is important.
I think I'm going to go with the first option because at least the highlights seem to be in all content, but it would be nice if the red background is used. The following is my .vimrc lines for the first case. Any guidance to fix this would be appreciated.
" Turn on spell-checker
set spell
" Color scheme
" To pick from available list do:
" :colorscheme _space_ Tab
" Reasonable options seem to be: koehler, murphy, elford
colorscheme koehler
" Using the colorscheme with spellchecking results in highlights with
" pink text on red background, which is hard to read, so change the highlight color.
" Color table: https://github.com/guns/xterm-color-table.vim
" Use white text on red background for misspelled words.
hi SpellBad ctermfg=015 ctermbg=009 cterm=bold guibg=#ff0000 guifg=#000000 gui=bold
While using Vim for most of my coding, I typically prefer to have the current line under-lined so it's easier to see where I am in my code. I avoid using things like line-highlighting because it usually makes things harder to see with my bright-text-on-dark-background theme (ie: 'torte' colorscheme).
Here is part of my Vim colorscheme:
hi CursorLine guibg=#0F2130 ctermbg=NONE cterm=underline
hi CursorColumn guibg=#0F2130 ctermbg=darkgray cterm=NONE
I then enable these features in my .vimrc file (ie: ~/.vimrc).
So, in my case, the current line has a colored underline which is the inverted color of the character above it, while the current column has a dark-grey background, while all other text just has a black background.
The only problem I am having here is that I cannot see underscore ('_') characters while coding because the underline for the current line is the exact same color and thickness as the underscore characters. The only workaround, if its even possible, that would make sense here is to:
Increase the spacing between lines
Make the underline appear a few pixels further below my text
Is anything like this possible in Vim (not gVIM)?
Thank you.
If you are using gVim:
:hi! def link CursorLine SpellBad
It will use curl-underline.
Changing the linespace to 10+ will display _ above the Cursorline:
:set linespace=10
#kev: +1; It works in gVIM
However, it seems this just can't happen in Vim, as other commenters have noted.
In the end, I just set the background to be dark grey (ie: ctermbg=253), and then set the cursorline to be darker (ie: ctermbg=black cterm=NONE).
From there, I updated my BASHRC file to contain the following:
export TERM=xterm-256color
This, of all luck, ends up looking better than my previous colorscheme. I now have a modified version of the standard "slate" color scheme with a very dark gray background (ie: ctermbg=253) while the current line has a solid black background.
I'd like to implement a syntax file for vim that hides certain characters in the file. Specifically, I want to write an improved highlighter for reading Markdown files that doesn't display some of the formatting characters, preferring instead to indicate them implicitly. For example, I'd like to have things like *bold* render as simply bold with bold text, or to have headings like
My Header
=========
not show their underline, but just appear a different color. I haven't managed to find any examples so far of vim syntax files that hide specific characters from display. Is this something that is possible in vim? If so, how?
To hide syntax items - or just certain characters - the conceal or Ignore arguments can be used. See
:help hl-Ignore
:help syn-conceal
For an example see the syntax file "help.vim" which is part of crefvim. CRefVim is a C-reference manual which is embedded in the Vim help system. The "help.vim" syntax file extends the standard syntax highlighting for help files.
An example. The '$' character is used here to show text in italic:
Maybe this example is a good starting point for you to dig further...
Habi
You could make your own syntaxfile with an according colortheme, using "bold", "italics" and the like. It wouldn't hide anything, so that your syntax must work with the original text.
For example this could be your syntax for headers
In your syntax you would need:
syn match Header '^\s*\u*\.\s.*$' contains=ALL
hi link Header ModeMsg
and in the colortheme
hi ModeMsg gui=bold guifg=NONE guibg=NONE cterm=bold ctermfg=NONE ctermbg=NONE term=bold
then a header like this
1. This is my new header, being bold
would be shown bold, without any markup at all. By the way, you can export it with the TOhtml feature while keeping the highlighting.