Skip to content

Instantly share code, notes, and snippets.

Last active August 26, 2018 20:34
What would you like to do?
Gist file containing code for medium post codi.vim fullscreen workflow
" since it is fullscreen, I'd like a 50/50 split
let g:codi#width = 50.0
fun! s:FullscreenScratch()
" store filetype and bufnr of current buffer
" for later reference
let current_buf_ft = &ft
let current_buf_num = bufnr('%')
" create a new empty tab and set it up
tabe | setlocal buftype=nofile noswapfile modifiable buflisted
" set filetype to that of original source file
" e.g. ruby / python / w/e Codi supports
let &filetype = current_buf_ft
" create a buffer local mapping that overrides the
" outer one to delete the current scratch buffer instead
" when the buffer is destroyed, this mapping will be
" destroyed with it and the next <Leader><Leader>
" will spawn a new fullscreen scratch window again
" we do not have to unmap as this mapping will be
" automatically destroyed alongside the buffer.
nmap <silent><buffer> <Leader><Leader> :silent! q!<Cr>
" everything is setup, filetype is set
" let Codi do the rest :)
" create a mapping to call the fullscreen scratch wrapper
nmap <silent> <Leader><Leader> :call <SID>FullscreenScratch()<Cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment