如何在Vim Goyo模式下移除波浪线与脱字符?
How to Hide Tildes (~) and Trailing Whitespace Carets (^) in Vim Goyo Mode
Absolutely! You can absolutely make both the tilde characters (shown at the end of the buffer) and the caret markers for trailing whitespace disappear when Goyo mode is active. Here's a clean, non-intrusive way to set this up in your Vim configuration:
Step-by-Step Configuration
Add these lines to your ~/.vimrc (or init.vim if you're using Neovim):
" Hide tildes and trailing whitespace carets when entering Goyo autocmd! User GoyoEnter autocmd User GoyoEnter setlocal fillchars+=eob:\ listchars-=trail:^ " Restore original settings when exiting Goyo autocmd! User GoyoLeave autocmd User GoyoLeave setlocal fillchars-=eob:\ listchars+=trail:^
What This Does
Let's break down the key parts:
- Tilde (~) removal: The
fillcharsoption controls how Vim draws special characters. By settingeob:\(note the space after the backslash), we replace the default tilde for "end of buffer" lines with an invisible space. - Caret (^) removal: The
listcharsoption defines markers for whitespace characters. Removingtrail:^tells Vim not to show a caret for trailing spaces at the end of lines. - Autocmd triggers: We use Goyo's built-in
GoyoEnterandGoyoLeaveevents to apply these changes only when Goyo is active, and revert them when you exit the mode. This way your normal Vim setup stays intact.
Optional: If You Want to Disable All List Markers
If you don't need any whitespace markers at all in Goyo mode, you can simplify the configuration:
autocmd! User GoyoEnter autocmd User GoyoEnter setlocal fillchars+=eob:\ nolist autocmd! User GoyoLeave autocmd User GoyoLeave setlocal fillchars-=eob:\ list
This turns off Vim's list mode entirely while in Goyo, hiding all whitespace markers including tabs or non-breakable spaces.
内容的提问来源于stack exchange,提问作者cgg
相关产品推荐
相关产品推荐

