• Stars
    star
    4,404
  • Rank 9,250 (Top 0.2 %)
  • Language
    Vim Script
  • License
    MIT License
  • Created over 10 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🌷 Distraction-free writing in 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

FAQ

"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

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

More Repositories

1

fzf

🌸 A command-line fuzzy finder
Go
55,523
star
2

vim-plug

🌺 Minimalist Vim Plugin Manager
Vim Script
32,890
star
3

fzf.vim

fzf ❤️ vim
Vim Script
9,178
star
4

vim-easy-align

🌻 A Vim alignment plugin
Vim Script
3,981
star
5

limelight.vim

🔦 All the world's indeed a stage and we are merely players
Vim Script
2,290
star
6

redis-stat

(UNMAINTAINED) A real-time Redis monitoring tool
Ruby
2,014
star
7

seoul256.vim

🌳 Low-contrast Vim color scheme based on Seoul Colors
Vim Script
1,604
star
8

gv.vim

A git commit browser in Vim
Vim Script
1,286
star
9

vim-peekaboo

👀 " / @ / CTRL-R
Vim Script
1,102
star
10

vim-emoji

😃 Emoji in Vim
Vim Script
606
star
11

vader.vim

A simple Vimscript test framework
Vim Script
571
star
12

vim-github-dashboard

:octocat: Browse GitHub events in Vim
Vim Script
481
star
13

vim-slash

Enhancing in-buffer search experience
Vim Script
322
star
14

fzf-git.sh

bash and zsh key bindings for Git objects, powered by fzf
Shell
280
star
15

vim-journal

📝
Vim Script
259
star
16

myvim

🍱 Script to create a portable bundle of Vim environment
Shell
252
star
17

heytmux

Tmux scripting made easy
Ruby
139
star
18

vim-xmark

Live markdown preview for Vim on macOS (UNMAINTAINED; see https://github.com/iamcco/markdown-preview.nvim)
CSS
135
star
19

fzf-bin

117
star
20

vim-after-object

👉 Target text *after* the designated characters
Vim Script
112
star
21

vim-oblique

DEPRECATED Improved /-search (experimental)
Vim Script
83
star
22

vim-startuptime-benchmark

Outdated information
Vim Script
69
star
23

tmux-fzf-url

🚀 Quickly open urls on screen from your browser!
Shell
45
star
24

perlin_noise

Perlin noise generator in Ruby
Ruby
43
star
25

gimchi

Gimchi reads Korean.
Ruby
40
star
26

hbase-jruby

A JRuby binding for HBase
Ruby
38
star
27

tmux-fzf-maccy

Tmux plugin for Maccy and fzf integration
Shell
34
star
28

blsd

List directories in breadth-first order
Go
33
star
29

mvmv

Simple batch renaming script (ruby)
Ruby
27
star
30

vim-fnr

🎭 Find-N-Replace helper free of regular expressions
Vim Script
25
star
31

jdbc-helper

Deprecated. Use Sequel.
Ruby
19
star
32

jruby-daemon-template

Turn a JRuby script into an init-d style daemon
Shell
18
star
33

tabularize

Formatting tabular data with paddings
Ruby
18
star
34

mini-file-server

A simple, insecure file server
Clojure
17
star
35

ansi256

A Rubygem for colorizing text with 256-color ANSI codes
Ruby
16
star
36

vim-pseudocl

Pseudo-command-line (experimental)
Vim Script
16
star
37

insensitive_hash

DEPRECATED: Use hashie
Ruby
15
star
38

pipe-logger

Log rotation of stdout & stderr
Ruby
14
star
39

grouper

A simple batch processing facility
Clojure
12
star
40

vim-redis

Experimental Redis plugin for Vim
Vim Script
12
star
41

lq

A simple HTTP server for queuing lines of text
Clojure
11
star
42

clj-inspector

Inspector helps debugging Clojure programs
Clojure
11
star
43

parallelize

Simple multi-threading for Ruby
Ruby
10
star
44

tre-ruby

Approximate regular expression matching using TRE
Ruby
10
star
45

treely

Library for generating tree diagram of nested data structure
Clojure
9
star
46

junegunn

8
star
47

coffee-processing

Helps writing Processing.js sketches in CoffeeScript
Ruby
8
star
48

ssh-copy-id.rb

Unmaintained
Ruby
7
star
49

agl

List files and directories using ag
Ruby
7
star
50

si

Human-readable numbers with SI prefix (metric prefix)
Ruby
6
star
51

evented-servers

experiments with libev
C
6
star
52

vim-ruby-x

if_ruby helper
Vim Script
6
star
53

microbe

A simple micro benchmark helper for Clojure
Clojure
5
star
54

vim-cfr

Decompile Java class files using CFR
Vim Script
5
star
55

shorten

Number shortener
Ruby
4
star
56

each_line_reverse

Read lines of a file in reverse order
Ruby
4
star
57

proco

experimental: a lightweight asynchronous task executor designed for efficient batch processing
Ruby
4
star
58

lps

lps: rate-controlled loop execution
Ruby
3
star
59

SuperCSV

A fork of SuperCSV project with a few fixes
Java
2
star
60

colored-not

Toggles methods from colored gem
Ruby
2
star
61

img2xterm-clj

img2xterm rewritten in clojure (for no good reason)
Clojure
2
star
62

jrubysql

SQL client for any JDBC-compliant database.
Ruby
2
star
63

linux-scripts

Ruby
2
star
64

option_initializer

Object construction with method chaining
Ruby
2
star
65

zipfian

Zipfian distribution in Ruby
Ruby
2
star
66

rcron

A simple cron-like scheduler for Ruby
Ruby
2
star
67

quote_unquote

Wraps (and unwraps) strings with quotes
Ruby
1
star
68

maven_dependency

A Ruby gem to resolve maven dependencies
Ruby
1
star
69

coffee-processing-live

coffee-processing demo app
JavaScript
1
star
70

tweet-backup-ruby

Ruby script for backing up tweets
Ruby
1
star
71

i

1
star
72

each_sql

Enumerate each SQL statement in SQL scripts
Ruby
1
star
73

hbase-client-dep

Makefile
1
star
74

srsly

SRSLY? NO!
Ruby
1
star
75

omniauth-nate

OmniAuth strategy for Nate.com (Nate/Cyworld)
Ruby
1
star
76

oxm

A tiny Object-XML-Mapper for Ruby
Ruby
1
star