You are not logged in.
Pages: 1
In Vim I'm trying to make it so that my text filetype is using the same highlighting colours I've configured for conf file types. The .vimrc file config below specifically only seems to work with conf files, and changes my comment colour to light blue. But when I open this up in my gnome terminal, the comments are not changing to that same colour specifically for the text filetype files (they are white).
$ cat .vimrc
set textwidth=72
autocmd FileType conf highlight Comment ctermfg=50
autocmd FileType text highlight Comment ctermfg=50
colorscheme default
syntax enable
This makes me think there is something wrong with vim not having some config file available for the text filetype (some text.vim file must be missing from the installation). With some digging, I found that if I copy the conf.vim file to text.vim solves the issue.
$ sudo cp /usr/share/vim/vim90/syntax/conf.vim /usr/share/vim/vim90/syntax/text.vim
The question is, is this the right approach? I'm not entirely sure this wouldn't get erased on an update. I mean it works, but I just don't know if that's the correct way to solve the problem (or why the text.vim file would be missing from a default install of vim)?
Last edited by sg4rb0sss (2023-12-22 13:07:24)
Offline
syntax != filetype, https://stackoverflow.com/questions/271 … tax-in-vim
https://vim.fandom.com/wiki/Filetype.vim#File_locations
=> /usr/share/vim/vim90/ftplugin/text.vim
There's no "text" syntax, because it's unstrucured "text", what would you highlight there itfp.
What is a comment in your "text"?
Offline
To elaborate a bit on the above, to get vim to colorize a bit of text two things need to happen 1) that bit of text needs to be linked to a highlight group (e.g., defining that lines starting with a '#' are to be in the 'Comment' group), and 2) each highlight group must be assigned a color (and / or fontweight, etc).
The "conf" filetype definition takes care of the first of these for you which is why you can successfully just do the second by assigning color 50 to "Comment". But there is no definition of "Comment" for plain text files. You can add one if you want, but that's up to you.
Last edited by Trilby (2023-12-22 14:58:38)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Pages: 1