如何将我的Vim高亮线更改为不是下划线?

时间:2011-12-27 00:56:19

标签: vim

在某些颜色方案中,当前行突出显示会改变背景,在其他情况下,如Desert,当前行标有下划线。

我想更改沙漠中当前行突出显示使用不同的背景颜色而不是下划线。我怎么能这样做?

我的.vimrc

set cursorline
highlight Cursorline cterm=bold

更新:解决问题的.vimrc

colorscheme desert
set cursorline
hi CursorLine term=bold cterm=bold guibg=Grey40

6 个答案:

答案 0 :(得分:82)

color desert
set cursorline
hi CursorLine term=bold cterm=bold guibg=Grey40

desert是你的颜色方案。(应该先来) 把它放在你的~/.vimrc

答案 1 :(得分:54)

这对我来说效果更好(在每个终端)。

:hi CursorLine   cterm=NONE ctermbg=darkred ctermfg=white

终端的颜色设置:背景颜色 - ctermbg ,文字颜色 - ctermfg 要在图形窗口中使用,请添加参数guibg=darkred guifg=white

您也可以使用以下命令突出显示相应的列:

:set cursorcolumn

在编辑器中按一个键可以打开和关闭高亮显示。将这些行添加到 vimrc

:nnoremap H :set cursorline! cursorcolumn!<CR>

输入'H'会切换打开和关闭突出显示(如果需要,可将其映射到另一个键)

您可以在文章中找到更多信息: http://vim.wikia.com/wiki/Highlight_current_line

答案 2 :(得分:19)

与你在终端中的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

答案 3 :(得分:10)

如果您想使用下划线之一来打开下划线:

:hi CursorLine cterm=underline
:hi CursorLine gui=underline

否则使用其中一个:

:hi CursorLine cterm=none
:hi CursorLine gui=none

答案 4 :(得分:8)

我有一个类似的问题设置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 *'调用的函数),因此恢复的colorscheme的默认值将重置.vimrc中的cursorline highlight设置。

通过autocmd调用的上述函数将在所有初始化完成后运行,因此成功设置了光标高亮。

HTH。

答案 5 :(得分:0)

您必须添加.vimrc结束行:

highlight lineNr term=bold cterm=NONE ctermbg=none  ctermfg=none gui=bold

set cursorline

highlight CursorLine term=bold cterm=NONE ctermbg=none  ctermfg=none gui=bold

highlight CursorLineNr term=bold cterm=none ctermbg=none ctermfg=yellow gui=bold
相关问题