首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何让vim在使用vim的同时突出显示尾随的空格?

如何让vim在使用vim的同时突出显示尾随的空格?
EN

Stack Overflow用户
提问于 2018-02-23 03:12:11
回答 2查看 3K关注 0票数 1

Vim highlighting with solarized color scheme之后,我尝试了这个

代码语言:javascript
复制
" Default color scheme
syntax enable
 set background=dark
colorscheme solarized
autocmd ColorScheme * highlight RedundantSpaces ctermbg=red
match RedundantSpaces /\s\+$/

然而,我仍然无法让我的空格显示出来。这是我的.vimrc:

代码语言:javascript
复制
set nocompatible              " required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'

Plugin 'tmhedberg/SimpylFold'
Plugin 'Vimjas/vim-python-pep8-indent'
Plugin 'vim-syntastic/syntastic'
Plugin 'nvie/vim-flake8'
Plugin 'jeffkreeftmeijer/vim-numbertoggle'
Plugin 'altercation/vim-colors-solarized'

" add all your plugins here (note older versions of Vundle
" used Bundle instead of Plugin)

" ...

" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required

"split navigations
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>

" See docstrings for folded code
let g:SimpylFold_docstring_preview=1
" Enable folding
set foldmethod=indent
set foldlevel=99

" Enable folding with the spacebar
nnoremap <space> za

" UTF8 Support
set encoding=utf-8

" Syntastic recommended settings
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*

let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0

" Default color scheme
syntax enable
set background=dark
colorscheme solarized
autocmd ColorScheme * highlight RedundantSpaces ctermbg=red
match RedundantSpaces /\s\+$/

" Make my code look pretty
let python_highlight_all=1
syntax on

" line numbering
set number relativenumber

另外,如果可能的话,我如何在Solarize中使用https://github.com/vim-scripts/ShowTrailingWhitespace

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-02-23 23:19:25

将此代码添加到.vimrc的最底部

代码语言:javascript
复制
highlight RedundantSpaces ctermbg=red guibg=red 
match RedundantSpaces /\s\+$/

你应该已经准备好了,不需要ShowTrailingWhitespace插件

票数 10
EN

Stack Overflow用户

发布于 2018-02-23 11:14:23

没有必要只使用插件来跟踪空格,我的.vimrc中有以下内容:

代码语言:javascript
复制
autocmd BufWinEnter <buffer> match Error /\s\+$/
autocmd InsertEnter <buffer> match Error /\s\+\%#\@<!$/
autocmd InsertLeave <buffer> match Error /\s\+$/
autocmd BufWinLeave <buffer> call clearmatches()

当您编辑代码时,它会跟踪空格,所以我认为它会做您想要做的事情。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48935451

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档