如何将我的Vim高亮线更改为不是下划线?
在某些colorchemes中,当前行突出显示更改背景,而在其他颜色,如Desert,当前行标有下划线。
我想更改沙漠中当前行突出显示使用不同的背景颜色而不是下划线。 我怎样才能做到这一点?
我的.vimrc:
set cursorline
highlight Cursorline cterm=bold
更新:.vimrc解决了这个问题
colorscheme desert
set cursorline
hi CursorLine term=bold cterm=bold guibg=Grey40
ashim asked 2019-05-18T01:07:20Z
5个解决方案
76 votes
color desert
set cursorline
hi CursorLine term=bold cterm=bold guibg=Grey40
desert是你的colorscheme。(应该先来)
把它放在你的~/.vimrc
kev answered 2019-05-18T01:07:41Z
50 votes
这对我来说效果更好(在每个终端)。
:hi CursorLine cterm=NONE ctermbg=darkred ctermfg=white
它是终端的颜色设置:背景颜色 - ctermbg和文本颜色 - ctermfg。 要在图形窗口中使用,请添加参数guibg=darkred guifg=white
您也可以使用以下命令突出显示相应的列:
:set cursorcolumn
在编辑器中按一个键可以打开和关闭高亮显示。 将这些行添加到您的vimrc:
:nnoremap H :set cursorline! cursorcolumn!
键入“H”将打开和关闭突出显示(如果需要,将其映射到另一个键)
您可以在文章中找到更多信息:[http://vim.wikia.com/wiki/Highlight_current_line]
srnka answered 2019-05-18T01:08:43Z
16 votes
与你在终端中获得的gvim类似的行,保留语法高亮:
" first thing is entering vim mode, not plain vi
set nocompatible
" force 256 colors on the terminal
set t_Co=256
" load the color scheme before anything
colorscheme darkblue " or desert... or anything
" the syntax cmd is when the colorscheme gets parse, i think..
syntax on
" set the prefered colours, pick one line here only.
" dark grey, better you can get if you don't support 256 colours
hi CursorLine cterm=NONE ctermbg=8 ctermfg=NONE
" light grey, no 256 colors
hi CursorLine cterm=NONE ctermbg=7 ctermfg=NONE
" dark redish
hi CursorLine cterm=NONE ctermbg=52 ctermfg=NONE
" dark bluish
hi CursorLine cterm=NONE ctermbg=17 ctermfg=NONE
" very light grey
hi CursorLine cterm=NONE ctermbg=254 ctermfg=NONE
" yelowish
hi CursorLine cterm=NONE ctermbg=229 ctermfg=NONE
" almost black
hi CursorLine cterm=NONE ctermbg=234 ctermfg=NONE
gcb answered 2019-05-18T01:09:09Z
10 votes
如果您想使用下划线中的任何一个:
:hi CursorLine cterm=underline
:hi CursorLine gui=underline
否则使用其中一个:
:hi CursorLine cterm=none
:hi CursorLine gui=none
user5920118 answered 2019-05-18T01:09:41Z
8 votes
我有一个类似的问题设置cursorline高亮,但我的是由于我用来在vim退出期间保存会话信息的mksession命令。 如果在没有任何文件参数的情况下运行,则会在程序启动期间自动恢复此会话。
如果有人像这样设置了.vimrc,你可以将以下内容添加到.vimrc中以正确设置cursorline高亮显示: -
function s:SetCursorLine()
set cursorline
hi cursorline cterm=none ctermbg=darkblue ctermfg=white
endfunction
autocmd VimEnter * call s:SetCursorLine()
关于为什么这样做有点解释。 除了各种缓冲区和窗口信息外,mksession还保存当前的colorscheme名称。 在程序启动期间通过会话恢复恢复。 但是,由于会话恢复通常在运行.vimrc之后完成(通常使用通过'autocmd VimEnter *'调用的函数),因此.vimrc中的光标线高亮设置将按恢复的colorscheme的默认值重置。
通过autocmd调用的上述函数将在所有初始化完成后运行,因此成功设置了光标线高亮显示。
HTH。
Hari Mahadevan answered 2019-05-18T01:10:30Z