:tulip: Distraction-free writing in Vim
Distraction-free writing in Vim.
(Color scheme: seoul256)
Best served with limelight.vim.
Use your favorite plugin manager.
Plug 'junegunn/goyo.vim'
to .vimrc:PlugInstall
:Goyo
:Goyo [dimension]
:Goyo!
The window can be resized with the usual [count]<CTRL-W>
+ >
, <
, +
,-
keys, and <CTRL-W>
+ =
will resize it back to the initial size.
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()
if executable('tmux') && strlen($TMUX)
silent !tmux set status off
silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
endif
set noshowmode
set noshowcmd
set scrolloff=999
Limelight
" ...
endfunction
function! s:goyo_leave()
if executable('tmux') && strlen($TMUX)
silent !tmux set status on
silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z
endif
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
“My custom colors are lost when I exit Goyo!”
That’s because Goyo restores the base color scheme using :colorscheme
CURRENT_COLOR_SCHEME
command on exit, and it resets your tweaks. Goyo can try
to remember all your customizations and restore them on exit, but it doesn’t,
because there is a better, more robust way to address the issue.
The real problem here is that you will lose all your changes when you switch
between color schemes, even when you’re not using Goyo.
" In your Vim configuration file
" - Base color scheme
colorscheme molokai
" - Your color customizations
hi LineNr ctermfg=red guifg=red
It works, only when you stick to a single color scheme. When you switch
between color schemes,
" Switch to another color scheme
colorscheme Tomorrow-Night
" Switch back to the original one
colorscheme molokai
And all the customizations you have made are lost.
What you should to do is to customize the colors on autocmd ColorScheme
,
which is automatically triggered whenever you change color schemes.
function! s:tweak_molokai_colors()
" Your molokai customizations
hi LineNr ...
hi FoldColumn ...
endfunction
autocmd! ColorScheme molokai call s:tweak_molokai_colors()
colorscheme molokai
:q[uit]
, :clo[se]
, :tabc[lose]
, or :Goyo
MIT