Vim 下编辑显示下划线

本文最后更新于:2022年6月1日 下午

1.打开配置文件

1
# vim /etc/vimrc

2.加入下划线参数

1
# set cursorline          " Show Vim underline

3.esc:wq 保存即生效

还可进行DIY

1
2
3
4
5
6
7
横:
set cursorline " Show Vim underline
highlight CursorLine cterm=NONE ctermbg=grey ctermfg=NONE guibg=NONE guifg=NONE

竖:
set cursorcolumn " Show Vim verticalline
highlight CursorColumn cterm=NONE ctermbg=grey ctermfg=NONE guibg=NONE guifg=NONE

效果图:

  • highlght:主要用于配色,包括语法高亮等个性化的配置
  • CursorLine:行
  • CursorColumn:列
  • cterm:原生vim样式,NONE表示可自定义设置
  • ctermbg:光标覆盖背景色
  • ctermfg :光标覆盖前景色
  • guibg:gvim的背景色
  • guifg:gvim的前景色

我用的效果图和代码在下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
1 if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
2 set fileencodings=ucs-bom,utf-8,latin1
3 endif
4
5 colorscheme desert
6 set cursorline " 下划线
7 highlight CursorLine ctermbg=darkred ctermfg=white cterm=bold term=bold guibg=grey40
8
9 " set cursorcolumn " 竖划线
10 " highlight CursorColumn cterm=NONE ctermbg=darkgrey ctermfg=NONE guibg=NONE guifg=NONE
11
12 " set mouse=a " 鼠标可用
13 set nu " 显示行号
14 set showmode
15 set autoindent " vim使用自动对齐(自动缩进)
16 set cindent "(cindent是特别针对 C语言语法自动缩进)
17 set smartindent " 智能的选择对齐方式,对于类似C语言编写上有用
18 set tabstop=4 " 设置tab键为4个空格
19 set shiftwidth=4 " 设置当行之间交错时使用4个空格
20 set ai! " 设置自动缩进
21 set showmatch " 设置匹配模式输入一个左括号时会匹配相应的右括号
22
23
24
25 set nocompatible " Use Vim defaults (much better!)
26 set bs=indent,eol,start " allow backspacing over everything in insert mode
27 "set ai " always set autoindenting on
28 "set backup " keep a backup file
29 set viminfo='20,\"50 " read/write a .viminfo file, don't store more
30 " than 50 lines of registers
31 set history=50 " keep 50 lines of command line history
32 set ruler " show the cursor position all the time
33
34 " Only do this part when compiled with support for autocommands
35 if has("autocmd")
36 augroup redhat
37 autocmd!
38 " In text files, always limit the width of text to 78 characters
39 " autocmd BufRead *.txt set tw=78
40 " When editing a file, always jump to the last cursor position
41 autocmd BufReadPost *
42 \ if line("'\"") > 0 && line ("'\"") <= line("$") |
43 \ exe "normal! g'\"" |
44 \ endif
45 " don't write swapfile on most commonly used directories for NFS mounts or USB sticks
46 autocmd BufNewFile,BufReadPre /media/*,/run/media/*,/mnt/* set directory=~/tmp,/var/tmp,/tmp
47 " start with spec file template
48 autocmd BufNewFile *.spec 0r /usr/share/vim/vimfiles/template.spec
49 augroup END
50 endif
51
52 if has("cscope") && filereadable("/usr/bin/cscope")
53 set csprg=/usr/bin/cscope
54 set csto=0
55 set cst
56 set nocsverb
57 " add any database in current directory
58 if filereadable("cscope.out")
59 cs add $PWD/cscope.out
60 " else add database pointed to by environment
61 elseif $CSCOPE_DB != ""
62 cs add $CSCOPE_DB
63 endif
64 set csverb
65 endif
66
67 " Switch syntax highlighting on, when the terminal has colors
68 " Also switch on highlighting the last used search pattern.
69 if &t_Co > 2 || has("gui_running")
70 syntax on
71 set hlsearch
72 endif
73
74 " filetype plugin on
75
76 if &term=="xterm"
77 set t_Co=8
78 set t_Sb=^[[4%dm
79 set t_Sf=^[[3%dm
80 endif
81
82 " Don't wake up system with blinking cursor:
83 " http://www.linuxpowertop.org/known.php
84 let &guicursor = &guicursor . ",a:blinkon0"

Vim 下编辑显示下划线
https://simple2ich4n.top/39213/
作者
2ich4n
发布于
2021年7月17日
更新于
2022年6月1日
许可协议