goyo.vim


Ⅰ. 插件描述

:tulip: Distraction-free writing in Vim

Ⅱ. 基本信息

创建日期:  2013-11-30
使用用户:  1239
Github星:  2925
插件作者:  Junegunn Choi

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'junegunn/goyo-vim'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'junegunn/goyo-vim'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'junegunn/goyo-vim'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/junegunn/goyo.vim

Ⅳ. 文档说明

goyo.vim (고요)

Distraction-free writing in Vim.

(Color scheme: seoul256)

Best served with limelight.vim.

Installation

Use your favorite plugin manager.

  • vim-plug

    1. Add Plug 'junegunn/goyo.vim' to .vimrc
    2. Run :PlugInstall

Usage

  • :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, and <CTRL-W> + = will resize it back to the initial size.

Dimension expression

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%

Configuration

  • g:goyo_width (default: 80)
  • g:goyo_height (default: 85%)
  • g:goyo_linenr (default: 0)

Callbacks

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

Inspiration

Pros.

  1. Works well with splits. Doesn't mess up with the current window arrangement
  2. Works well with popular statusline plugins
  3. Prevents accessing the empty windows around the central buffer
  4. Can be closed with any of :q[uit], :clo[se], :tabc[lose], or :Goyo
  5. Can dynamically change the width of the window
  6. Adjusts its colors when color scheme is changed
  7. Realigns the window when the terminal (or window) is resized or when the size
    of the font is changed
  8. Correctly hides colorcolumns and Emojis in statusline
  9. Highly customizable with callbacks

License

MIT

添加新评论