goyo.vim (고요)
Distraction-free writing in Vim.
(Color scheme: seoul256)
Best served with limelight.vim.
Use your favorite plugin manager.
- vim-plug
- Add
Plug 'junegunn/goyo.vim'
to .vimrc - Run
:PlugInstall
- Add
:Goyo
- Toggle Goyo
:Goyo [dimension]
- Turn on or resize Goyo
:Goyo!
- Turn Goyo off
The window can be resized with the usual [count]<CTRL-W>
+ >
, <
, +
,
-
keys.
The expected format of a dimension expression is
[WIDTH][XOFFSET][x[HEIGHT][YOFFSET]]
. XOFFSET
and YOFFSET
should be
prefixed by +
or -
. Each component can be given in percentage.
" Width
Goyo 120
" Height
Goyo x30
" Both
Goyo 120x30
" In percentage
Goyo 120x50%
" With offsets
Goyo 50%+25%x50%-25%
g:goyo_width
(default: 80)g:goyo_height
(default: 85%)g:goyo_linenr
(default: 0)
By default, vim-airline, vim-powerline, powerline, lightline.vim, vim-signify, and vim-gitgutter are temporarily disabled while in Goyo mode.
If you have other plugins that you want to disable/enable, or if you want to
change the default settings of Goyo window, you can set up custom routines
to be triggered on GoyoEnter
and GoyoLeave
events.
function! s:goyo_enter()
silent !tmux set status off
silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
set noshowmode
set noshowcmd
set scrolloff=999
Limelight
" ...
endfunction
function! s:goyo_leave()
silent !tmux set status on
silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z
set showmode
set showcmd
set scrolloff=5
Limelight!
" ...
endfunction
autocmd! User GoyoEnter nested call <SID>goyo_enter()
autocmd! User GoyoLeave nested call <SID>goyo_leave()
More examples can be found here: Customization
Goyo reloads the color scheme on exit, therefore, custom patches will be lost. To reliably apply custom colors, autocmd ColorScheme can be used as suggested below.
in .vimrc
" Override Colors in a Color Scheme
fun! s:patch_colorscheme()
hi clear LineNr
hi clear SignColumn
endf
" Set colorscheme and patch it
colo seoul256
call s:patch_colorscheme()
" Re-patch colorscheme whenever ColorScheme is applied
aug patch_colors
au!
au ColorScheme * call s:patch_colorscheme()
aug END
- Works well with splits. Doesn't mess up with the current window arrangement
- Works well with popular statusline plugins
- Prevents accessing the empty windows around the central buffer
- Can be closed with any of
:q[uit]
,:clo[se]
,:tabc[lose]
, or:Goyo
- Can dynamically change the width of the window
- Adjusts its colors when color scheme is changed
- Realigns the window when the terminal (or window) is resized or when the size of the font is changed
- Correctly hides colorcolumns and Emojis in statusline
- Highly customizable with callbacks
MIT