junegunn / goyo.vim

:tulip: Distraction-free writing in Vim
MIT License
4.49k stars 115 forks source link

how to enable goyo when start vim? #247

Open xukongwen opened 3 years ago

xukongwen commented 3 years ago

thanks!

christopherisnow commented 3 years ago

See h: Buf

shaunsingh commented 3 years ago

If you want to run any command on start with vim, you can use an autocmd. In this case, you could put the following line in your .vimrc

autocmd vimenter * Goyo

which would run the command :Goyo as soon as vim starts up

I highly recommend looking through a bit of the documentation, as it makes tinkering around with vim much easier in the long run~

scammi commented 3 years ago

Thank you.

I needed markdown files to be open with Goyo. Super simple.

autocmd vimenter *.md Goyo

ghost commented 2 years ago

How to avoid typing ":q!" twice to exit?

sicr0 commented 2 years ago

@leontepe I am having the same question. Did you found any solution?

zach-is-my-name commented 2 years ago

@leontepe @sicr0 when I can remember to do it i use :qa short for "quit all". Vim should check if you have any unsaved buffers before exiting. Caveat - because I use buffers, when I type :q I'm quitting vim not closing a tab or window.

jonulrich commented 1 year ago

How to avoid typing ":q!" twice to exit?

Just in case anyone has not found a workaround yet:

let s:goyostatus = 1
function! ToggleGoyo()
    if s:goyostatus
        let s:goyostatus = 0
    else
        let s:goyostatus = 1
    endif
    Goyo
endfunction

nnoremap <silent> <Leader><Leader> :call ToggleGoyo()<CR> 

function! s:goyo_leave()
  if s:goyostatus
    quit!
  endif
endfunction

autocmd! User GoyoLeave nested call <SID>goyo_leave()

Not sure if there's a more elegant solution but this works as long as you toggle with :call ToggleGoyo() or \\ and not :Goyo. For my purposes tho toggling is not necessary and is just an added bonus. If you don't foresee a need to toggle off Goyo at all I think you can get away with this:

function! s:goyo_leave()
    quit!
endfunction

autocmd! User GoyoLeave nested call <SID>goyo_leave()
jonulrich commented 1 year ago

nevermind there was a better solution all along

Ensure :q to quit even when Goyo is active