From 7787e23a3a9d680876504741f41d3cebab53efca Mon Sep 17 00:00:00 2001 From: "Vayn a.k.a. VT" Date: Sun, 9 Oct 2011 06:16:28 +0800 Subject: [PATCH 01/22] Change some settings to fit my requirement * Change mapping * Change sidebar setting --- plugin/vimroom.vim | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugin/vimroom.vim b/plugin/vimroom.vim index 55dfbb1..188adbe 100644 --- a/plugin/vimroom.vim +++ b/plugin/vimroom.vim @@ -22,7 +22,7 @@ let g:loaded_vimroom_plugin = 1 " The desired column width. Defaults to 80: if !exists( "g:vimroom_width" ) - let g:vimroom_width = 80 + let g:vimroom_width = 82 endif " The minimum sidebar size. Defaults to 5: @@ -128,6 +128,7 @@ function! VimroomToggle() " Remove wrapping and linebreaks set nowrap set nolinebreak + set colorcolumn=0 else if s:is_the_screen_wide_enough() let s:active = 1 @@ -138,11 +139,15 @@ function! VimroomToggle() endif " Create the left sidebar exec( "silent leftabove " . s:sidebar . "vsplit new" ) + set nu + set nonu set noma set nocursorline wincmd l " Create the right sidebar exec( "silent rightbelow " . s:sidebar . "vsplit new" ) + set nu + set nonu set noma set nocursorline wincmd h @@ -161,6 +166,8 @@ function! VimroomToggle() " Setup wrapping, line breaking, and push the cursor down set wrap set linebreak + set colorcolumn=79 + hi ColorColumn ctermbg=0 if s:save_textwidth != "" exec( "set textwidth=".g:vimroom_width ) endif @@ -202,5 +209,5 @@ command -nargs=0 VimroomToggle call VimroomToggle() " If no mapping exists, map it to `V`. if !hasmapto( 'VimroomToggle' ) - nmap V VimroomToggle + nmap v VimroomToggle endif From 3597d68cdf5e5ae449e6e4453c760fb62e26a87a Mon Sep 17 00:00:00 2001 From: "Vayn a.k.a. VT" Date: Sun, 9 Oct 2011 06:24:27 +0800 Subject: [PATCH 02/22] Change mapping --- plugin/vimroom.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimroom.vim b/plugin/vimroom.vim index 188adbe..310b015 100644 --- a/plugin/vimroom.vim +++ b/plugin/vimroom.vim @@ -209,5 +209,5 @@ command -nargs=0 VimroomToggle call VimroomToggle() " If no mapping exists, map it to `V`. if !hasmapto( 'VimroomToggle' ) - nmap v VimroomToggle + nmap V VimroomToggle endif From d6ae7dfc05b744e045b14761292440cf8717f9a5 Mon Sep 17 00:00:00 2001 From: "Vayn a.k.a. VT" Date: Sun, 9 Oct 2011 06:40:01 +0800 Subject: [PATCH 03/22] Replace V with v in mapping --- plugin/vimroom.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/vimroom.vim b/plugin/vimroom.vim index 310b015..e75b613 100644 --- a/plugin/vimroom.vim +++ b/plugin/vimroom.vim @@ -207,7 +207,7 @@ noremap VimroomToggle :call VimroomToggle() " Create a `VimroomToggle` command: command -nargs=0 VimroomToggle call VimroomToggle() -" If no mapping exists, map it to `V`. +" If no mapping exists, map it to `v`. if !hasmapto( 'VimroomToggle' ) - nmap V VimroomToggle + nmap v VimroomToggle endif From 1651408568161347bb2cfc3418a0716cfa8489bf Mon Sep 17 00:00:00 2001 From: "Vayn a.k.a. VT" Date: Sun, 9 Oct 2011 06:58:30 +0800 Subject: [PATCH 04/22] Split background color in different env --- plugin/vimroom.vim | 239 +++++++++++++++++++++++---------------------- 1 file changed, 123 insertions(+), 116 deletions(-) diff --git a/plugin/vimroom.vim b/plugin/vimroom.vim index e75b613..1f33cb5 100644 --- a/plugin/vimroom.vim +++ b/plugin/vimroom.vim @@ -1,12 +1,12 @@ "============================================================================== -"File: vimroom.vim +"File: vimroom.vim "Description: Vaguely emulates a writeroom-like environment in Vim by -" splitting the current window in such a way as to center a column -" of user-specified width, wrap the text, and break lines. +" splitting the current window in such a way as to center a column +" of user-specified width, wrap the text, and break lines. "Maintainer: Mike West -"Version: 0.7 +"Version: 0.7 "Last Change: 2010-10-31 -"License: BSD <../LICENSE.markdown> +"License: BSD <../LICENSE.markdown> "============================================================================== """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -16,35 +16,35 @@ " The typical start to any vim plugin: If the plugin has already been loaded, " exit as quickly as possible. if exists( "g:loaded_vimroom_plugin" ) - finish + finish endif let g:loaded_vimroom_plugin = 1 " The desired column width. Defaults to 80: if !exists( "g:vimroom_width" ) - let g:vimroom_width = 82 + let g:vimroom_width = 82 endif " The minimum sidebar size. Defaults to 5: if !exists( "g:vimroom_min_sidebar_width" ) - let g:vimroom_min_sidebar_width = 5 + let g:vimroom_min_sidebar_width = 5 endif " The sidebar height. Defaults to 3: if !exists( "g:vimroom_sidebar_height" ) - let g:vimroom_sidebar_height = 3 + let g:vimroom_sidebar_height = 3 endif " The background color. Defaults to "black" if !exists( "g:vimroom_background" ) - let g:vimroom_background = "black" + let g:vimroom_background = "black" endif " The "scrolloff" value: how many lines should be kept visible above and below " the cursor at all times? Defaults to 999 (which centers your cursor in the " active window). if !exists( "g:vimroom_scrolloff" ) - let g:vimroom_scrolloff = 999 + let g:vimroom_scrolloff = 999 endif " Should Vimroom map navigational keys (``, ``, `j`, `k`) to navigate @@ -52,7 +52,7 @@ endif " with wrapped lines). Defaults to `1` (on). Set to `0` if you'd prefer not to " run the mappings. if !exists( "g:vimroom_navigation_keys" ) - let g:vimroom_navigation_keys = 1 + let g:vimroom_navigation_keys = 1 endif """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -66,148 +66,155 @@ let s:minwidth = g:vimroom_width + ( g:vimroom_min_sidebar_width * 2 ) " Save the current color scheme for reset later let s:scheme = "" if exists( "g:colors_name" ) - let s:scheme = g:colors_name + let s:scheme = g:colors_name endif if exists( "&t_mr" ) - let s:save_t_mr = &t_mr + let s:save_t_mr = &t_mr end " Save the current scrolloff value for reset later let s:save_scrolloff = "" if exists( "&scrolloff" ) - let s:save_scrolloff = &scrolloff + let s:save_scrolloff = &scrolloff end " Save the current `laststatus` value for reset later let s:save_laststatus = "" if exists( "&laststatus" ) - let s:save_laststatus = &laststatus + let s:save_laststatus = &laststatus endif " Save the current `textwidth` value for reset later let s:save_textwidth = "" if exists( "&textwidth" ) - let s:save_textwidth = &textwidth + let s:save_textwidth = &textwidth endif " We're currently in nonvimroomized state let s:active = 0 function! s:is_the_screen_wide_enough() - return winwidth( winnr() ) >= s:minwidth + return winwidth( winnr() ) >= s:minwidth endfunction function! s:sidebar_size() - return ( winwidth( winnr() ) - g:vimroom_width - 2 ) / 2 + return ( winwidth( winnr() ) - g:vimroom_width - 2 ) / 2 endfunction function! VimroomToggle() - if s:active == 1 - let s:active = 0 - " Close all other windows - only - " Reset color scheme (or clear new colors, if no scheme is set) - if s:scheme != "" - exec( "colorscheme " . s:scheme ) - else - hi clear - endif - if s:save_t_mr != "" - exec( "set t_mr=" .s:save_t_mr ) - endif - " Reset `scrolloff` and `laststatus` - if s:save_scrolloff != "" - exec( "set scrolloff=" . s:save_scrolloff ) - endif - if s:save_laststatus != "" - exec( "set laststatus=" . s:save_laststatus ) - endif - if s:save_textwidth != "" - exec( "set textwidth=" . s:save_textwidth ) - endif - " Remove wrapping and linebreaks - set nowrap - set nolinebreak - set colorcolumn=0 + if s:active == 1 + let s:active = 0 + " Close all other windows + only + " Reset color scheme (or clear new colors, if no scheme is set) + if s:scheme != "" + exec( "colorscheme " . s:scheme ) else - if s:is_the_screen_wide_enough() - let s:active = 1 - let s:sidebar = s:sidebar_size() - " Turn off status bar - if s:save_laststatus != "" - set laststatus=0 - endif - " Create the left sidebar - exec( "silent leftabove " . s:sidebar . "vsplit new" ) - set nu - set nonu - set noma - set nocursorline - wincmd l - " Create the right sidebar - exec( "silent rightbelow " . s:sidebar . "vsplit new" ) - set nu - set nonu - set noma - set nocursorline - wincmd h - if g:vimroom_sidebar_height - " Create the top sidebar - exec( "silent leftabove " . g:vimroom_sidebar_height . "split new" ) - set noma - set nocursorline - wincmd j - " Create the bottom sidebar - exec( "silent rightbelow " . g:vimroom_sidebar_height . "split new" ) - set noma - set nocursorline - wincmd k - endif - " Setup wrapping, line breaking, and push the cursor down - set wrap - set linebreak - set colorcolumn=79 - hi ColorColumn ctermbg=0 - if s:save_textwidth != "" - exec( "set textwidth=".g:vimroom_width ) - endif - if s:save_scrolloff != "" - exec( "set scrolloff=".g:vimroom_scrolloff ) - endif - - " Setup navigation over "display lines", not "logical lines" if - " mappings for the navigation keys don't already exist. - if g:vimroom_navigation_keys - try - noremap g - noremap g - noremap k gk - noremap j gj - inoremap g - inoremap g - catch /E227:/ - echo "Navigational key mappings already exist." - endtry - endif - - " Hide distracting visual elements - exec( "hi VertSplit ctermbg=" . g:vimroom_background . " ctermfg=" . g:vimroom_background . " guifg=" . g:vimroom_background . " guibg=" . g:vimroom_background ) - exec( "hi NonText ctermbg=" . g:vimroom_background . " ctermfg=" . g:vimroom_background . " guifg=" . g:vimroom_background . " guibg=" . g:vimroom_background ) - exec( "hi StatusLine ctermbg=" . g:vimroom_background . " ctermfg=" . g:vimroom_background . " guifg=" . g:vimroom_background . " guibg=" . g:vimroom_background ) - exec( "hi StatusLineNC ctermbg=" . g:vimroom_background . " ctermfg=" . g:vimroom_background . " guifg=" . g:vimroom_background . " guibg=" . g:vimroom_background ) - set t_mr="" - set fillchars+=vert:\ - endif + hi clear endif + if s:save_t_mr != "" + exec( "set t_mr=" .s:save_t_mr ) + endif + " Reset `scrolloff` and `laststatus` + if s:save_scrolloff != "" + exec( "set scrolloff=" . s:save_scrolloff ) + endif + if s:save_laststatus != "" + exec( "set laststatus=" . s:save_laststatus ) + endif + if s:save_textwidth != "" + exec( "set textwidth=" . s:save_textwidth ) + endif + " Remove wrapping and linebreaks + set nowrap + set nolinebreak + set colorcolumn=0 + else + if s:is_the_screen_wide_enough() + let s:active = 1 + let s:sidebar = s:sidebar_size() + " Turn off status bar + if s:save_laststatus != "" + set laststatus=0 + endif + " Create the left sidebar + exec( "silent leftabove " . s:sidebar . "vsplit new" ) + set nu + set nonu + set noma + set nocursorline + wincmd l + " Create the right sidebar + exec( "silent rightbelow " . s:sidebar . "vsplit new" ) + set nu + set nonu + set noma + set nocursorline + wincmd h + if g:vimroom_sidebar_height + " Create the top sidebar + exec( "silent leftabove " . g:vimroom_sidebar_height . "split new" ) + set noma + set nocursorline + wincmd j + " Create the bottom sidebar + exec( "silent rightbelow " . g:vimroom_sidebar_height . "split new" ) + set noma + set nocursorline + wincmd k + endif + " Setup wrapping, line breaking, and push the cursor down + set wrap + set linebreak + set colorcolumn=79 + hi ColorColumn ctermbg=0 + if s:save_textwidth != "" + exec( "set textwidth=".g:vimroom_width ) + endif + if s:save_scrolloff != "" + exec( "set scrolloff=".g:vimroom_scrolloff ) + endif + + " Setup navigation over "display lines", not "logical lines" if + " mappings for the navigation keys don't already exist. + if g:vimroom_navigation_keys + try + noremap g + noremap g + noremap k gk + noremap j gj + inoremap g + inoremap g + catch /E227:/ + echo "Navigational key mappings already exist." + endtry + endif + + " Hide distracting visual elements + if has('gui_running') + exec( "hi VertSplit guibg=" . g:vimroom_background . " guifg=" . g:vimroom_background ) + exec( "hi NonText guibg=" . g:vimroom_background . " guifg=" . g:vimroom_background ) + exec( "hi StatusLine guibg=" . g:vimroom_background . " guifg=" . g:vimroom_background ) + exec( "hi StatusLineNC guibg=" . g:vimroom_background . " guifg=" . g:vimroom_background ) + else + exec( "hi VertSplit ctermbg=" . g:vimroom_background . " ctermfg=" . g:vimroom_background ) + exec( "hi NonText ctermbg=" . g:vimroom_background . " ctermfg=" . g:vimroom_background ) + exec( "hi StatusLine ctermbg=" . g:vimroom_background . " ctermfg=" . g:vimroom_background ) + exec( "hi StatusLineNC ctermbg=" . g:vimroom_background . " ctermfg=" . g:vimroom_background ) + endif + set t_mr="" + set fillchars+=vert:\ + endif + endif endfunction " Create a mapping for the `VimroomToggle` function -noremap VimroomToggle :call VimroomToggle() +noremap VimroomToggle :call VimroomToggle() " Create a `VimroomToggle` command: command -nargs=0 VimroomToggle call VimroomToggle() " If no mapping exists, map it to `v`. if !hasmapto( 'VimroomToggle' ) - nmap v VimroomToggle + nmap v VimroomToggle endif From c243ce948dd5008201a66a23050a6319f62d96ea Mon Sep 17 00:00:00 2001 From: "Vayn a.k.a. VT" Date: Sun, 9 Oct 2011 17:31:34 +0800 Subject: [PATCH 05/22] Tweak the code * Formatting source code * Use local variable to save default setting --- plugin/vimroom.vim | 296 ++++++++++++++++++++++++--------------------- 1 file changed, 158 insertions(+), 138 deletions(-) diff --git a/plugin/vimroom.vim b/plugin/vimroom.vim index cf267b0..c78f917 100644 --- a/plugin/vimroom.vim +++ b/plugin/vimroom.vim @@ -1,58 +1,57 @@ "============================================================================== -"File: vimroom.vim +"File: vimroom.vim "Description: Vaguely emulates a writeroom-like environment in Vim by -" splitting the current window in such a way as to center a column -" of user-specified width, wrap the text, and break lines. +" splitting the current window in such a way as to center a column +" of user-specified width, wrap the text, and break lines. "Maintainer: Mike West -"Version: 0.7 +"Version: 0.7 "Last Change: 2010-10-31 -"License: BSD <../LICENSE.markdown> +"License: BSD <../LICENSE.markdown> "============================================================================== - """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Plugin Configuration " " The typical start to any vim plugin: If the plugin has already been loaded, " exit as quickly as possible. -if exists( "g:loaded_vimroom_plugin" ) - finish +if exists('g:loaded_vimroom_plugin') + finish endif let g:loaded_vimroom_plugin = 1 -" The desired column width. Defaults to 80: -if !exists( "g:vimroom_width" ) - let g:vimroom_width = 80 +" The desired column width. Defaults to 82: +if !exists('g:vimroom_width') + let g:vimroom_width = 82 endif -" The minimum sidebar size. Defaults to 5: -if !exists( "g:vimroom_min_sidebar_width" ) - let g:vimroom_min_sidebar_width = 5 +" The minimum sidebar size. Defaults to 5: +if !exists('g:vimroom_min_sidebar_width') + let g:vimroom_min_sidebar_width = 5 endif -" The sidebar height. Defaults to 3: -if !exists( "g:vimroom_sidebar_height" ) - let g:vimroom_sidebar_height = 3 +" The sidebar height. Defaults to 3: +if !exists('g:vimroom_sidebar_height') + let g:vimroom_sidebar_height = 3 endif -" The background color. Defaults to "black" -if !exists( "g:vimroom_background" ) - let g:vimroom_background = "black" +" The background color. Defaults to "black" +if !exists('g:vimroom_background') + let g:vimroom_background = 'black' endif " The "scrolloff" value: how many lines should be kept visible above and below -" the cursor at all times? Defaults to 999 (which centers your cursor in the +" the cursor at all times? Defaults to 999 (which centers your cursor in the " active window). -if !exists( "g:vimroom_scrolloff" ) - let g:vimroom_scrolloff = 999 +if !exists('g:vimroom_scrolloff') + let g:vimroom_scrolloff = 999 endif " Should Vimroom map navigational keys (``, ``, `j`, `k`) to navigate " "display" lines instead of "logical" lines (which makes it much simpler to deal " with wrapped lines). Defaults to `1` (on). Set to `0` if you'd prefer not to " run the mappings. -if !exists( "g:vimroom_navigation_keys" ) - let g:vimroom_navigation_keys = 1 +if !exists('g:vimroom_navigation_keys') + let g:vimroom_navigation_keys = 1 endif """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -61,150 +60,171 @@ endif " Given the desired column width, and minimum sidebar width, determine " the minimum window width necessary for splitting to make sense -let s:minwidth = g:vimroom_width + ( g:vimroom_min_sidebar_width * 2 ) +let s:minwidth = g:vimroom_width + (g:vimroom_min_sidebar_width * 2) " Save the current color scheme for reset later -let s:scheme = "" -if exists( "g:colors_name" ) - let s:scheme = g:colors_name +let s:scheme = '' +if exists('g:colors_name') + let s:scheme = g:colors_name endif -if exists( "&t_mr" ) - let s:save_t_mr = &t_mr +if exists('&t_mr') + let s:save_t_mr = &t_mr end " Save the current scrolloff value for reset later -let s:save_scrolloff = "" -if exists( "&scrolloff" ) - let s:save_scrolloff = &scrolloff +let s:save_scrolloff = '' +if exists('&scrolloff') + let s:save_scrolloff = &scrolloff end " Save the current `laststatus` value for reset later -let s:save_laststatus = "" -if exists( "&laststatus" ) - let s:save_laststatus = &laststatus +let s:save_laststatus = '' +if exists('&laststatus') + let s:save_laststatus = &laststatus endif " Save the current `textwidth` value for reset later -let s:save_textwidth = "" -if exists( "&textwidth" ) - let s:save_textwidth = &textwidth +let s:save_textwidth = '' +if exists('&textwidth') + let s:save_textwidth = &textwidth +endif + +" Save the current `colorcolumn` value for reset later +let s:save_cc = '' +if exists('&colorcolumn') + let s:save_cc = &colorcolumn endif " We're currently in nonvimroomized state let s:active = 0 function! s:is_the_screen_wide_enough() - return winwidth( winnr() ) >= s:minwidth + return winwidth(winnr()) >= s:minwidth endfunction function! s:sidebar_size() - return ( winwidth( winnr() ) - g:vimroom_width - 2 ) / 2 + return (winwidth(winnr()) - g:vimroom_width - 2) / 2 endfunction function! VimroomToggle() - if s:active == 1 - let s:active = 0 - " Close all other windows - only - " Reset color scheme (or clear new colors, if no scheme is set) - if s:scheme != "" - exec( "colorscheme " . s:scheme ) - else - hi clear - endif - if s:save_t_mr != "" - exec( "set t_mr=" .s:save_t_mr ) - endif - " Reset `scrolloff` and `laststatus` - if s:save_scrolloff != "" - exec( "set scrolloff=" . s:save_scrolloff ) - endif - if s:save_laststatus != "" - exec( "set laststatus=" . s:save_laststatus ) - endif - if s:save_textwidth != "" - exec( "set textwidth=" . s:save_textwidth ) - endif - " Remove wrapping and linebreaks - set nowrap - set nolinebreak + if s:active == 1 + let s:active = 0 + " Close all other windows + only + " Reset color scheme (or clear new colors, if no scheme is set) + if s:scheme != '' + exec('colorscheme ' . s:scheme) else - if s:is_the_screen_wide_enough() - let s:active = 1 - let s:sidebar = s:sidebar_size() - " Turn off status bar - if s:save_laststatus != "" - set laststatus=0 - endif - " Create the left sidebar - exec( "silent leftabove " . s:sidebar . "vsplit new" ) - set noma - set nocursorline - set nonumber - wincmd l - " Create the right sidebar - exec( "silent rightbelow " . s:sidebar . "vsplit new" ) - set noma - set nocursorline - set nonumber - wincmd h - if g:vimroom_sidebar_height - " Create the top sidebar - exec( "silent leftabove " . g:vimroom_sidebar_height . "split new" ) - set noma - set nocursorline - set nonumber - wincmd j - " Create the bottom sidebar - exec( "silent rightbelow " . g:vimroom_sidebar_height . "split new" ) - set noma - set nocursorline - set nonumber - wincmd k - endif - " Setup wrapping, line breaking, and push the cursor down - set wrap - set linebreak - if s:save_textwidth != "" - exec( "set textwidth=".g:vimroom_width ) - endif - if s:save_scrolloff != "" - exec( "set scrolloff=".g:vimroom_scrolloff ) - endif - - " Setup navigation over "display lines", not "logical lines" if - " mappings for the navigation keys don't already exist. - if g:vimroom_navigation_keys - try - noremap g - noremap g - noremap k gk - noremap j gj - inoremap g - inoremap g - catch /E227:/ - echo "Navigational key mappings already exist." - endtry - endif - - " Hide distracting visual elements - exec( "hi VertSplit ctermbg=" . g:vimroom_background . " ctermfg=" . g:vimroom_background . " guifg=" . g:vimroom_background . " guibg=" . g:vimroom_background ) - exec( "hi NonText ctermbg=" . g:vimroom_background . " ctermfg=" . g:vimroom_background . " guifg=" . g:vimroom_background . " guibg=" . g:vimroom_background ) - exec( "hi StatusLine ctermbg=" . g:vimroom_background . " ctermfg=" . g:vimroom_background . " guifg=" . g:vimroom_background . " guibg=" . g:vimroom_background ) - exec( "hi StatusLineNC ctermbg=" . g:vimroom_background . " ctermfg=" . g:vimroom_background . " guifg=" . g:vimroom_background . " guibg=" . g:vimroom_background ) - set t_mr="" - set fillchars+=vert:\ - endif + hi clear + endif + if s:save_t_mr != '' + exec('set t_mr=' .s:save_t_mr) + endif + " Reset `scrolloff` and `laststatus` + if s:save_scrolloff != '' + exec('set scrolloff=' . s:save_scrolloff) + endif + if s:save_laststatus != '' + exec('set laststatus=' . s:save_laststatus) + endif + if s:save_textwidth != '' + exec('set textwidth=' . s:save_textwidth) + endif + if s:save_cc != '' + exec('set colorcolumn='. s:save_cc) + endif + " Remove wrapping and linebreaks + set nowrap + set nolinebreak + else + if s:is_the_screen_wide_enough() + let s:active = 1 + let s:sidebar = s:sidebar_size() + " Turn off status bar + if s:save_laststatus != '' + set laststatus=0 + endif + " Use colorcolumn as window fence + set colorcolumn=79 + hi ColorColumn ctermbg=0 + " Create the left sidebar + exec('silent leftabove ' . s:sidebar . 'vsplit new') + " If we use "relativenumber", we must change it to "number" first, + " then we could close it. + set nu + set nonu + set noma + set nocursorline + wincmd l + " Create the right sidebar + exec('silent rightbelow ' . s:sidebar . 'vsplit new') + set nu + set nonu + set noma + set nocursorline + wincmd h + if g:vimroom_sidebar_height + " Create the top sidebar + exec('silent leftabove ' . g:vimroom_sidebar_height . 'split new') + set noma + set nocursorline + wincmd j + " Create the bottom sidebar + exec('silent rightbelow ' . g:vimroom_sidebar_height . 'split new') + set noma + set nocursorline + wincmd k + endif + " Setup wrapping, line breaking, and push the cursor down + set wrap + set linebreak + if s:save_textwidth != '' + exec('set textwidth='.g:vimroom_width) + endif + if s:save_scrolloff != '' + exec('set scrolloff='.g:vimroom_scrolloff) + endif + + " Setup navigation over 'display lines', not 'logical lines' if + " mappings for the navigation keys don't already exist. + if g:vimroom_navigation_keys + try + noremap g + noremap g + noremap k gk + noremap j gj + inoremap g + inoremap g + catch /E227:/ + echo 'Navigational key mappings already exist.' + endtry + endif + + " Hide distracting visual elements + if has('gui_running') + exec('hi VertSplit guibg=' . g:vimroom_background . ' guifg=' . g:vimroom_background) + exec('hi NonText guibg=' . g:vimroom_background . ' guifg=' . g:vimroom_background) + exec('hi StatusLine guibg=' . g:vimroom_background . ' guifg=' . g:vimroom_background) + exec('hi StatusLineNC guibg=' . g:vimroom_background . ' guifg=' . g:vimroom_background) + else + exec('hi VertSplit ctermbg=' . g:vimroom_background . ' ctermfg=' . g:vimroom_background) + exec('hi NonText ctermbg=' . g:vimroom_background . ' ctermfg=' . g:vimroom_background) + exec('hi StatusLine ctermbg=' . g:vimroom_background . ' ctermfg=' . g:vimroom_background) + exec('hi StatusLineNC ctermbg=' . g:vimroom_background . ' ctermfg=' . g:vimroom_background) + endif + set t_mr='' + set fillchars+=vert:\ endif + endif endfunction " Create a mapping for the `VimroomToggle` function -noremap VimroomToggle :call VimroomToggle() +noremap VimroomToggle :call VimroomToggle() " Create a `VimroomToggle` command: command -nargs=0 VimroomToggle call VimroomToggle() -" If no mapping exists, map it to `V`. -if !hasmapto( 'VimroomToggle' ) - nmap V VimroomToggle +" If no mapping exists, map it to `v`. +if !hasmapto('VimroomToggle') + nmap v VimroomToggle endif From c4878e451408d0000ec9e840a21908cf125c51be Mon Sep 17 00:00:00 2001 From: "Vayn a.k.a. VT" Date: Sun, 9 Oct 2011 18:25:13 +0800 Subject: [PATCH 06/22] Delete diff file --- plugin/vimroom.vim.orig | 266 ---------------------------------------- 1 file changed, 266 deletions(-) delete mode 100644 plugin/vimroom.vim.orig diff --git a/plugin/vimroom.vim.orig b/plugin/vimroom.vim.orig deleted file mode 100644 index a977c0f..0000000 --- a/plugin/vimroom.vim.orig +++ /dev/null @@ -1,266 +0,0 @@ -"============================================================================== -"File: vimroom.vim -"Description: Vaguely emulates a writeroom-like environment in Vim by -" splitting the current window in such a way as to center a column -" of user-specified width, wrap the text, and break lines. -"Maintainer: Mike West -"Version: 0.7 -"Last Change: 2010-10-31 -"License: BSD <../LICENSE.markdown> -"============================================================================== -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Plugin Configuration -" - -" The typical start to any vim plugin: If the plugin has already been loaded, -" exit as quickly as possible. -if exists('g:loaded_vimroom_plugin') - finish -endif -let g:loaded_vimroom_plugin = 1 - -" The desired column width. Defaults to 82: -if !exists('g:vimroom_width') - let g:vimroom_width = 82 -endif - -" The minimum sidebar size. Defaults to 5: -if !exists('g:vimroom_min_sidebar_width') - let g:vimroom_min_sidebar_width = 5 -endif - -" The sidebar height. Defaults to 3: -if !exists('g:vimroom_sidebar_height') - let g:vimroom_sidebar_height = 3 -endif - -" The background color. Defaults to "black" -if !exists('g:vimroom_background') - let g:vimroom_background = 'black' -endif - -" The "scrolloff" value: how many lines should be kept visible above and below -" the cursor at all times? Defaults to 999 (which centers your cursor in the -" active window). -if !exists('g:vimroom_scrolloff') - let g:vimroom_scrolloff = 999 -endif - -" Should Vimroom map navigational keys (``, ``, `j`, `k`) to navigate -" "display" lines instead of "logical" lines (which makes it much simpler to deal -" with wrapped lines). Defaults to `1` (on). Set to `0` if you'd prefer not to -" run the mappings. -if !exists('g:vimroom_navigation_keys') - let g:vimroom_navigation_keys = 1 -endif - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Plugin Code -" - -" Given the desired column width, and minimum sidebar width, determine -" the minimum window width necessary for splitting to make sense -let s:minwidth = g:vimroom_width + (g:vimroom_min_sidebar_width * 2) - -" Save the current color scheme for reset later -let s:scheme = '' -if exists('g:colors_name') - let s:scheme = g:colors_name -endif -if exists('&t_mr') - let s:save_t_mr = &t_mr -end - -" Save the current scrolloff value for reset later -let s:save_scrolloff = '' -if exists('&scrolloff') - let s:save_scrolloff = &scrolloff -end - -" Save the current `laststatus` value for reset later -let s:save_laststatus = '' -if exists('&laststatus') - let s:save_laststatus = &laststatus -endif - -" Save the current `textwidth` value for reset later -let s:save_textwidth = '' -if exists('&textwidth') - let s:save_textwidth = &textwidth -endif - -" Save the current `colorcolumn` value for reset later -let s:save_cc = '' -if exists('&colorcolumn') - let s:save_cc = &colorcolumn -endif - -" We're currently in nonvimroomized state -let s:active = 0 - -function! s:is_the_screen_wide_enough() - return winwidth(winnr()) >= s:minwidth -endfunction - -function! s:sidebar_size() - return (winwidth(winnr()) - g:vimroom_width - 2) / 2 -endfunction - -function! VimroomToggle() -<<<<<<< HEAD - if s:active == 1 - let s:active = 0 - " Close all other windows - only - " Reset color scheme (or clear new colors, if no scheme is set) - if s:scheme != '' - exec('colorscheme ' . s:scheme) -======= - if s:active == 1 - let s:active = 0 - " Close all other split windows - wincmd j - close - wincmd k - close - wincmd l - close - wincmd h - close - " Reset color scheme (or clear new colors, if no scheme is set) - if s:scheme != "" - exec( "colorscheme " . s:scheme ) - else - hi clear - endif - if s:save_t_mr != "" - exec( "set t_mr=" .s:save_t_mr ) - endif - " Reset `scrolloff` and `laststatus` - if s:save_scrolloff != "" - exec( "set scrolloff=" . s:save_scrolloff ) - endif - if s:save_laststatus != "" - exec( "set laststatus=" . s:save_laststatus ) - endif - if s:save_textwidth != "" - exec( "set textwidth=" . s:save_textwidth ) - endif - " Remove wrapping and linebreaks - set nowrap - set nolinebreak ->>>>>>> a53b642278c445f816785792f126a89bc787bc77 - else - hi clear - endif - if s:save_t_mr != '' - exec('set t_mr=' .s:save_t_mr) - endif - " Reset `scrolloff` and `laststatus` - if s:save_scrolloff != '' - exec('set scrolloff=' . s:save_scrolloff) - endif - if s:save_laststatus != '' - exec('set laststatus=' . s:save_laststatus) - endif - if s:save_textwidth != '' - exec('set textwidth=' . s:save_textwidth) - endif - if s:save_cc != '' - exec('set colorcolumn='. s:save_cc) - endif - " Remove wrapping and linebreaks - set nowrap - set nolinebreak - else - if s:is_the_screen_wide_enough() - let s:active = 1 - let s:sidebar = s:sidebar_size() - " Turn off status bar - if s:save_laststatus != '' - set laststatus=0 - endif - " Use colorcolumn as window fence - set colorcolumn=79 - hi ColorColumn ctermbg=0 - " Create the left sidebar - exec('silent leftabove ' . s:sidebar . 'vsplit new') - " If we use "relativenumber", we must change it to "number" first, - " then we could close it. - set nu - set nonu - set noma - set nocursorline - wincmd l - " Create the right sidebar - exec('silent rightbelow ' . s:sidebar . 'vsplit new') - set nu - set nonu - set noma - set nocursorline - wincmd h - if g:vimroom_sidebar_height - " Create the top sidebar - exec('silent leftabove ' . g:vimroom_sidebar_height . 'split new') - set noma - set nocursorline - wincmd j - " Create the bottom sidebar - exec('silent rightbelow ' . g:vimroom_sidebar_height . 'split new') - set noma - set nocursorline - wincmd k - endif - " Setup wrapping, line breaking, and push the cursor down - set wrap - set linebreak - if s:save_textwidth != '' - exec('set textwidth='.g:vimroom_width) - endif - if s:save_scrolloff != '' - exec('set scrolloff='.g:vimroom_scrolloff) - endif - - " Setup navigation over 'display lines', not 'logical lines' if - " mappings for the navigation keys don't already exist. - if g:vimroom_navigation_keys - try - noremap g - noremap g - noremap k gk - noremap j gj - inoremap g - inoremap g - catch /E227:/ - echo 'Navigational key mappings already exist.' - endtry - endif - - " Hide distracting visual elements - if has('gui_running') - exec('hi VertSplit guibg=' . g:vimroom_background . ' guifg=' . g:vimroom_background) - exec('hi NonText guibg=' . g:vimroom_background . ' guifg=' . g:vimroom_background) - exec('hi StatusLine guibg=' . g:vimroom_background . ' guifg=' . g:vimroom_background) - exec('hi StatusLineNC guibg=' . g:vimroom_background . ' guifg=' . g:vimroom_background) - else - exec('hi VertSplit ctermbg=' . g:vimroom_background . ' ctermfg=' . g:vimroom_background) - exec('hi NonText ctermbg=' . g:vimroom_background . ' ctermfg=' . g:vimroom_background) - exec('hi StatusLine ctermbg=' . g:vimroom_background . ' ctermfg=' . g:vimroom_background) - exec('hi StatusLineNC ctermbg=' . g:vimroom_background . ' ctermfg=' . g:vimroom_background) - endif - set t_mr='' - set fillchars+=vert:\ - endif - endif -endfunction - -" Create a mapping for the `VimroomToggle` function -noremap VimroomToggle :call VimroomToggle() - -" Create a `VimroomToggle` command: -command -nargs=0 VimroomToggle call VimroomToggle() - -" If no mapping exists, map it to `v`. -if !hasmapto('VimroomToggle') - nmap v VimroomToggle -endif From 4d3b85818258c057cb838a0fa50e826bc68240bd Mon Sep 17 00:00:00 2001 From: "Vayn a.k.a. VT" Date: Sun, 9 Oct 2011 18:27:24 +0800 Subject: [PATCH 07/22] Use "setlocal" instead of "set" when setting modifiable --- plugin/vimroom.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/vimroom.vim b/plugin/vimroom.vim index d52d24b..87ce2b1 100644 --- a/plugin/vimroom.vim +++ b/plugin/vimroom.vim @@ -160,14 +160,14 @@ function! VimroomToggle() " then we could close it. set nu set nonu - set noma + setlocal noma set nocursorline wincmd l " Create the right sidebar exec('silent rightbelow ' . s:sidebar . 'vsplit new') set nu set nonu - set noma + setlocal noma set nocursorline wincmd h if g:vimroom_sidebar_height From cddd22a468bd0bd47235236f203a01640e7e171e Mon Sep 17 00:00:00 2001 From: "Vayn a.k.a. VT" Date: Sun, 9 Oct 2011 19:23:55 +0800 Subject: [PATCH 08/22] Delete colorcolumn settings --- plugin/vimroom.vim | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/plugin/vimroom.vim b/plugin/vimroom.vim index 87ce2b1..b31740f 100644 --- a/plugin/vimroom.vim +++ b/plugin/vimroom.vim @@ -89,12 +89,6 @@ if exists('&textwidth') let s:save_textwidth = &textwidth endif -" Save the current `colorcolumn` value for reset later -let s:save_cc = '' -if exists('&colorcolumn') - let s:save_cc = &colorcolumn -endif - " We're currently in nonvimroomized state let s:active = 0 @@ -137,9 +131,6 @@ function! VimroomToggle() if s:save_textwidth != '' exec('set textwidth=' . s:save_textwidth) endif - if s:save_cc != '' - exec('set colorcolumn='. s:save_cc) - endif " Remove wrapping and linebreaks set nowrap set nolinebreak @@ -151,9 +142,6 @@ function! VimroomToggle() if s:save_laststatus != '' set laststatus=0 endif - " Use colorcolumn as window fence - set colorcolumn=79 - hi ColorColumn ctermbg=0 " Create the left sidebar exec('silent leftabove ' . s:sidebar . 'vsplit new') " If we use "relativenumber", we must change it to "number" first, @@ -173,12 +161,12 @@ function! VimroomToggle() if g:vimroom_sidebar_height " Create the top sidebar exec('silent leftabove ' . g:vimroom_sidebar_height . 'split new') - set noma + setlocal noma set nocursorline wincmd j " Create the bottom sidebar exec('silent rightbelow ' . g:vimroom_sidebar_height . 'split new') - set noma + setlocal noma set nocursorline wincmd k endif From 4a07f5efc83e4d528a76d7c0ffc9ec3f838b8d7b Mon Sep 17 00:00:00 2001 From: "Vayn a.k.a. VT" Date: Sun, 9 Oct 2011 19:52:07 +0800 Subject: [PATCH 09/22] Fix "windows close" problem --- plugin/vimroom.vim | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/plugin/vimroom.vim b/plugin/vimroom.vim index b31740f..6c5d806 100644 --- a/plugin/vimroom.vim +++ b/plugin/vimroom.vim @@ -104,14 +104,18 @@ function! VimroomToggle() if s:active == 1 let s:active = 0 " Close all other windows - wincmd j - close - wincmd k - close - wincmd l - close - wincmd h - close + if g:vimroom_sidebar_height + wincmd j + close + wincmd k + close + endif + if g:vimroom_min_sidebar_width + wincmd l + close + wincmd h + close + endif " Reset color scheme (or clear new colors, if no scheme is set) if s:scheme != '' exec('colorscheme ' . s:scheme) @@ -197,11 +201,13 @@ function! VimroomToggle() " Hide distracting visual elements if has('gui_running') + exec('hi LineNr guibg=' . g:vimroom_background) exec('hi VertSplit guibg=' . g:vimroom_background . ' guifg=' . g:vimroom_background) exec('hi NonText guibg=' . g:vimroom_background . ' guifg=' . g:vimroom_background) exec('hi StatusLine guibg=' . g:vimroom_background . ' guifg=' . g:vimroom_background) exec('hi StatusLineNC guibg=' . g:vimroom_background . ' guifg=' . g:vimroom_background) else + exec('hi LineNr ctermbg=' . g:vimroom_background) exec('hi VertSplit ctermbg=' . g:vimroom_background . ' ctermfg=' . g:vimroom_background) exec('hi NonText ctermbg=' . g:vimroom_background . ' ctermfg=' . g:vimroom_background) exec('hi StatusLine ctermbg=' . g:vimroom_background . ' ctermfg=' . g:vimroom_background) From 656ed95e82751e91f51eff573f10d1295351dd27 Mon Sep 17 00:00:00 2001 From: "Vayn a.k.a. VT" Date: Sun, 9 Oct 2011 19:56:33 +0800 Subject: [PATCH 10/22] Set numberwidth --- plugin/vimroom.vim | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plugin/vimroom.vim b/plugin/vimroom.vim index 6c5d806..4c14296 100644 --- a/plugin/vimroom.vim +++ b/plugin/vimroom.vim @@ -89,6 +89,12 @@ if exists('&textwidth') let s:save_textwidth = &textwidth endif +" Save the current `numberwidth` value for reset later +let s:save_textwidth = '' +if exists('&numberwidth') + let s:save_numberwidth = &numberwidth +endif + " We're currently in nonvimroomized state let s:active = 0 @@ -135,6 +141,9 @@ function! VimroomToggle() if s:save_textwidth != '' exec('set textwidth=' . s:save_textwidth) endif + if s:save_numberwidth != '' + exec('set numberwidth=' . s:save_numberwidth) + endif " Remove wrapping and linebreaks set nowrap set nolinebreak @@ -142,6 +151,10 @@ function! VimroomToggle() if s:is_the_screen_wide_enough() let s:active = 1 let s:sidebar = s:sidebar_size() + " Set numberwidth + if s:save_numberwidth != '' + set numberwidth=1 + endif " Turn off status bar if s:save_laststatus != '' set laststatus=0 From 120e587d8db33f701909011a023f86f876fa06ba Mon Sep 17 00:00:00 2001 From: "Vayn a.k.a. VT" Date: Sun, 9 Oct 2011 20:11:56 +0800 Subject: [PATCH 11/22] Fix local variable --- plugin/vimroom.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimroom.vim b/plugin/vimroom.vim index 4c14296..2418c1b 100644 --- a/plugin/vimroom.vim +++ b/plugin/vimroom.vim @@ -90,7 +90,7 @@ if exists('&textwidth') endif " Save the current `numberwidth` value for reset later -let s:save_textwidth = '' +let s:save_numberwidth = '' if exists('&numberwidth') let s:save_numberwidth = &numberwidth endif From 3cc161f3a7d502ca1030b7681b4d89ba5a0f6d47 Mon Sep 17 00:00:00 2001 From: "Vayn a.k.a. VT" Date: Sun, 9 Oct 2011 21:20:58 +0800 Subject: [PATCH 12/22] Add snapshot in readme --- README.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.markdown b/README.markdown index d9ac0a4..5c94a42 100644 --- a/README.markdown +++ b/README.markdown @@ -2,3 +2,7 @@ Vimroom ======= Readme goes here. + +__Snapshot__ + +[![Snapshot](http://f.cl.ly/items/2Z1h2h1E0o140F2i322t/2011-10-09-203409_scrot.png)](http://cl.ly/251J0j042E290v0e0b32) From 89f096768a94ac0cdf4e6b92660c8aa3ef862618 Mon Sep 17 00:00:00 2001 From: "Vayn a.k.a. VT" Date: Sun, 9 Oct 2011 21:22:47 +0800 Subject: [PATCH 13/22] "Disable" line number not "close" it --- plugin/vimroom.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimroom.vim b/plugin/vimroom.vim index 2418c1b..49e9c10 100644 --- a/plugin/vimroom.vim +++ b/plugin/vimroom.vim @@ -162,7 +162,7 @@ function! VimroomToggle() " Create the left sidebar exec('silent leftabove ' . s:sidebar . 'vsplit new') " If we use "relativenumber", we must change it to "number" first, - " then we could close it. + " then we could disable it. set nu set nonu setlocal noma From af8cf42e6938a1758a3e53dd2d9c9a046fc29458 Mon Sep 17 00:00:00 2001 From: "Vayn a.k.a. VT" Date: Sun, 9 Oct 2011 21:29:33 +0800 Subject: [PATCH 14/22] Disable line number in height padding windows --- plugin/vimroom.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugin/vimroom.vim b/plugin/vimroom.vim index 49e9c10..c1c1970 100644 --- a/plugin/vimroom.vim +++ b/plugin/vimroom.vim @@ -178,11 +178,15 @@ function! VimroomToggle() if g:vimroom_sidebar_height " Create the top sidebar exec('silent leftabove ' . g:vimroom_sidebar_height . 'split new') + set nu + set nonu setlocal noma set nocursorline wincmd j " Create the bottom sidebar exec('silent rightbelow ' . g:vimroom_sidebar_height . 'split new') + set nu + set nonu setlocal noma set nocursorline wincmd k From e4f55c668796143d5417c4659ed98c48304a696e Mon Sep 17 00:00:00 2001 From: "Vayn a.k.a. VT" Date: Sun, 9 Oct 2011 21:38:37 +0800 Subject: [PATCH 15/22] Revert default column width to 80 --- plugin/vimroom.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/vimroom.vim b/plugin/vimroom.vim index c1c1970..ae20023 100644 --- a/plugin/vimroom.vim +++ b/plugin/vimroom.vim @@ -19,9 +19,9 @@ if exists('g:loaded_vimroom_plugin') endif let g:loaded_vimroom_plugin = 1 -" The desired column width. Defaults to 82: +" The desired column width. Defaults to 80: if !exists('g:vimroom_width') - let g:vimroom_width = 82 + let g:vimroom_width = 80 endif " The minimum sidebar size. Defaults to 5: From cafbc80a375dbf4d2f223944e4ba1adb3350d101 Mon Sep 17 00:00:00 2001 From: "Vayn a.k.a. VT" Date: Sun, 9 Oct 2011 21:43:30 +0800 Subject: [PATCH 16/22] Change default width to 82 I found 80 is not wide enough if textwidth is 79 --- plugin/vimroom.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/vimroom.vim b/plugin/vimroom.vim index ae20023..c1c1970 100644 --- a/plugin/vimroom.vim +++ b/plugin/vimroom.vim @@ -19,9 +19,9 @@ if exists('g:loaded_vimroom_plugin') endif let g:loaded_vimroom_plugin = 1 -" The desired column width. Defaults to 80: +" The desired column width. Defaults to 82: if !exists('g:vimroom_width') - let g:vimroom_width = 80 + let g:vimroom_width = 82 endif " The minimum sidebar size. Defaults to 5: From e05ad46c7ebf9e1f391fff27be14c3b86c0e02a9 Mon Sep 17 00:00:00 2001 From: "Vayn a.k.a. VT" Date: Mon, 10 Oct 2011 05:28:59 +0800 Subject: [PATCH 17/22] Revert README --- README.markdown | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.markdown b/README.markdown index 5c94a42..d9ac0a4 100644 --- a/README.markdown +++ b/README.markdown @@ -2,7 +2,3 @@ Vimroom ======= Readme goes here. - -__Snapshot__ - -[![Snapshot](http://f.cl.ly/items/2Z1h2h1E0o140F2i322t/2011-10-09-203409_scrot.png)](http://cl.ly/251J0j042E290v0e0b32) From e6bcb931bab375bc6430fabe3446f8e156eb9a28 Mon Sep 17 00:00:00 2001 From: "Vayn a.k.a. VT" Date: Mon, 10 Oct 2011 05:43:53 +0800 Subject: [PATCH 18/22] Change numberwidth when Vim is in VimRoom --- vimroom.vim | 271 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 271 insertions(+) create mode 100644 vimroom.vim diff --git a/vimroom.vim b/vimroom.vim new file mode 100644 index 0000000..bfc2761 --- /dev/null +++ b/vimroom.vim @@ -0,0 +1,271 @@ +"============================================================================== +"File: vimroom.vim +"Description: Vaguely emulates a writeroom-like environment in Vim by +" splitting the current window in such a way as to center a column +" of user-specified width, wrap the text, and break lines. +"Maintainer: Mike West +"Version: 0.7 +"Last Change: 2010-10-31 +"License: BSD <../LICENSE.markdown> +"============================================================================== + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Plugin Configuration +" + +" The typical start to any vim plugin: If the plugin has already been loaded, +" exit as quickly as possible. +if exists( "g:loaded_vimroom_plugin" ) + finish +endif +let g:loaded_vimroom_plugin = 1 + +" The desired column width. Defaults to 80: +if !exists( "g:vimroom_width" ) + let g:vimroom_width = 80 +endif + +" The minimum sidebar size. Defaults to 5: +if !exists( "g:vimroom_min_sidebar_width" ) + let g:vimroom_min_sidebar_width = 5 +endif + +" The sidebar height. Defaults to 3: +if !exists( "g:vimroom_sidebar_height" ) + let g:vimroom_sidebar_height = 3 +endif + +" The GUI background color. Defaults to "black" +if !exists( "g:vimroom_guibackground" ) + let g:vimroom_guibackground = "black" +endif + +" The cterm background color. Defaults to "bg" +if !exists( "g:vimroom_ctermbackground" ) + let g:vimroom_ctermbackground = "bg" +endif + +" The "scrolloff" value: how many lines should be kept visible above and below +" the cursor at all times? Defaults to 999 (which centers your cursor in the +" active window). +if !exists( "g:vimroom_scrolloff" ) + let g:vimroom_scrolloff = 999 +endif + +" Should Vimroom map navigational keys (``, ``, `j`, `k`) to navigate +" "display" lines instead of "logical" lines (which makes it much simpler to deal +" with wrapped lines). Defaults to `1` (on). Set to `0` if you'd prefer not to +" run the mappings. +if !exists( "g:vimroom_navigation_keys" ) + let g:vimroom_navigation_keys = 1 +endif + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Plugin Code +" + +" Given the desired column width, and minimum sidebar width, determine +" the minimum window width necessary for splitting to make sense +let s:minwidth = g:vimroom_width + ( g:vimroom_min_sidebar_width * 2 ) + +" Save the current color scheme for reset later +let s:scheme = "" +if exists( "g:colors_name" ) + let s:scheme = g:colors_name +endif +if exists( "&t_mr" ) + let s:save_t_mr = &t_mr +end + +" Save the current scrolloff value for reset later +let s:save_scrolloff = "" +if exists( "&scrolloff" ) + let s:save_scrolloff = &scrolloff +end + +" Save the current `laststatus` value for reset later +let s:save_laststatus = "" +if exists( "&laststatus" ) + let s:save_laststatus = &laststatus +endif + +" Save the current `textwidth` value for reset later +let s:save_textwidth = "" +if exists( "&textwidth" ) + let s:save_textwidth = &textwidth +endif + +" Save the current `number` and `relativenumber` values for reset later +let s:save_number = 0 +let s:save_relativenumber = 0 +if exists( "&number" ) + let s:save_number = &number +endif +if exists ( "&relativenumber" ) + let s:save_relativenumber = &relativenumber +endif + +" Save the current `numberwidth` value for reset later +let s:save_numberwidth = '' +if exists('&numberwidth') + let s:save_numberwidth = &numberwidth +endif + +" We're currently in nonvimroomized state +let s:active = 0 + +function! s:is_the_screen_wide_enough() + return winwidth( winnr() ) >= s:minwidth +endfunction + +function! s:sidebar_size() + return ( winwidth( winnr() ) - g:vimroom_width - 2 ) / 2 +endfunction + +function! VimroomToggle() + if s:active == 1 + let s:active = 0 + " Close all other split windows + if g:vimroom_sidebar_height + wincmd j + close + wincmd k + close + endif + if g:vimroom_min_sidebar_width + wincmd l + close + wincmd h + close + endif + " Reset color scheme (or clear new colors, if no scheme is set) + if s:scheme != "" + exec( "colorscheme " . s:scheme ) + else + hi clear + endif + if s:save_t_mr != "" + exec( "set t_mr=" .s:save_t_mr ) + endif + " Reset `scrolloff` and `laststatus` + if s:save_scrolloff != "" + exec( "set scrolloff=" . s:save_scrolloff ) + endif + if s:save_laststatus != "" + exec( "set laststatus=" . s:save_laststatus ) + endif + if s:save_textwidth != "" + exec( "set textwidth=" . s:save_textwidth ) + endif + if s:save_numberwidth != '' + exec('set numberwidth=' . s:save_numberwidth) + endif + if s:save_number != 0 + set number + endif + if s:save_relativenumber != 0 + set relativenumber + endif + " Remove wrapping and linebreaks + set nowrap + set nolinebreak + else + if s:is_the_screen_wide_enough() + let s:active = 1 + let s:sidebar = s:sidebar_size() + " Set numberwidth + if s:save_numberwidth != '' + set numberwidth=1 + endif + " Turn off status bar + if s:save_laststatus != "" + setlocal laststatus=0 + endif + if g:vimroom_min_sidebar_width + " Create the left sidebar + exec( "silent leftabove " . s:sidebar . "vsplit new" ) + setlocal noma + setlocal nocursorline + setlocal nonumber + setlocal norelativenumber + wincmd l + " Create the right sidebar + exec( "silent rightbelow " . s:sidebar . "vsplit new" ) + setlocal noma + setlocal nocursorline + setlocal nonumber + setlocal norelativenumber + wincmd h + endif + if g:vimroom_sidebar_height + " Create the top sidebar + exec( "silent leftabove " . g:vimroom_sidebar_height . "split new" ) + setlocal noma + setlocal nocursorline + setlocal nonumber + setlocal norelativenumber + wincmd j + " Create the bottom sidebar + exec( "silent rightbelow " . g:vimroom_sidebar_height . "split new" ) + setlocal noma + setlocal nocursorline + setlocal nonumber + setlocal norelativenumber + wincmd k + endif + " Setup wrapping, line breaking, and push the cursor down + set wrap + set linebreak + set nonumber + set norelativenumber + if s:save_textwidth != "" + exec( "set textwidth=".g:vimroom_width ) + endif + if s:save_scrolloff != "" + exec( "set scrolloff=".g:vimroom_scrolloff ) + endif + + " Setup navigation over "display lines", not "logical lines" if + " mappings for the navigation keys don't already exist. + if g:vimroom_navigation_keys + try + noremap g + noremap g + noremap k gk + noremap j gj + inoremap g + inoremap g + catch /E227:/ + echo "Navigational key mappings already exist." + endtry + endif + + " Hide distracting visual elements + if has('gui_running') + let l:highlightbgcolor = "guibg=" . g:vimroom_guibackground + let l:highlightfgbgcolor = "guifg=" . g:vimroom_guibackground . " " . l:highlightbgcolor + else + let l:highlightbgcolor = "ctermbg=" . g:vimroom_guibackground + let l:highlightfgbgcolor = "ctermfg=" . g:vimroom_ctermbackground . " " . l:highlightbgcolor + endif + exec( "hi Normal " . l:highlightbgcolor ) + exec( "hi VertSplit " . l:highlightfgbgcolor ) + exec( "hi NonText " . l:highlightfgbgcolor ) + exec( "hi StatusLine " . l:highlightfgbgcolor ) + exec( "hi StatusLineNC " . l:highlightfgbgcolor ) + set t_mr="" + set fillchars+=vert:\ + endif + endif +endfunction + +" Create a mapping for the `VimroomToggle` function +noremap VimroomToggle :call VimroomToggle() + +" Create a `VimroomToggle` command: +command -nargs=0 VimroomToggle call VimroomToggle() + +" If no mapping exists, map it to `V`. +if !hasmapto( 'VimroomToggle' ) + nmap V VimroomToggle +endif From 6c37c56baa86406f464c93ac2964182465d48a26 Mon Sep 17 00:00:00 2001 From: "Vayn a.k.a. VT" Date: Mon, 10 Oct 2011 05:57:35 +0800 Subject: [PATCH 19/22] Move modified vimroom to correct directory --- plugin/vimroom.vim | 13 +++ vimroom.vim | 271 --------------------------------------------- 2 files changed, 13 insertions(+), 271 deletions(-) delete mode 100644 vimroom.vim diff --git a/plugin/vimroom.vim b/plugin/vimroom.vim index a4445ff..bfc2761 100644 --- a/plugin/vimroom.vim +++ b/plugin/vimroom.vim @@ -105,6 +105,12 @@ if exists ( "&relativenumber" ) let s:save_relativenumber = &relativenumber endif +" Save the current `numberwidth` value for reset later +let s:save_numberwidth = '' +if exists('&numberwidth') + let s:save_numberwidth = &numberwidth +endif + " We're currently in nonvimroomized state let s:active = 0 @@ -151,6 +157,9 @@ function! VimroomToggle() if s:save_textwidth != "" exec( "set textwidth=" . s:save_textwidth ) endif + if s:save_numberwidth != '' + exec('set numberwidth=' . s:save_numberwidth) + endif if s:save_number != 0 set number endif @@ -164,6 +173,10 @@ function! VimroomToggle() if s:is_the_screen_wide_enough() let s:active = 1 let s:sidebar = s:sidebar_size() + " Set numberwidth + if s:save_numberwidth != '' + set numberwidth=1 + endif " Turn off status bar if s:save_laststatus != "" setlocal laststatus=0 diff --git a/vimroom.vim b/vimroom.vim deleted file mode 100644 index bfc2761..0000000 --- a/vimroom.vim +++ /dev/null @@ -1,271 +0,0 @@ -"============================================================================== -"File: vimroom.vim -"Description: Vaguely emulates a writeroom-like environment in Vim by -" splitting the current window in such a way as to center a column -" of user-specified width, wrap the text, and break lines. -"Maintainer: Mike West -"Version: 0.7 -"Last Change: 2010-10-31 -"License: BSD <../LICENSE.markdown> -"============================================================================== - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Plugin Configuration -" - -" The typical start to any vim plugin: If the plugin has already been loaded, -" exit as quickly as possible. -if exists( "g:loaded_vimroom_plugin" ) - finish -endif -let g:loaded_vimroom_plugin = 1 - -" The desired column width. Defaults to 80: -if !exists( "g:vimroom_width" ) - let g:vimroom_width = 80 -endif - -" The minimum sidebar size. Defaults to 5: -if !exists( "g:vimroom_min_sidebar_width" ) - let g:vimroom_min_sidebar_width = 5 -endif - -" The sidebar height. Defaults to 3: -if !exists( "g:vimroom_sidebar_height" ) - let g:vimroom_sidebar_height = 3 -endif - -" The GUI background color. Defaults to "black" -if !exists( "g:vimroom_guibackground" ) - let g:vimroom_guibackground = "black" -endif - -" The cterm background color. Defaults to "bg" -if !exists( "g:vimroom_ctermbackground" ) - let g:vimroom_ctermbackground = "bg" -endif - -" The "scrolloff" value: how many lines should be kept visible above and below -" the cursor at all times? Defaults to 999 (which centers your cursor in the -" active window). -if !exists( "g:vimroom_scrolloff" ) - let g:vimroom_scrolloff = 999 -endif - -" Should Vimroom map navigational keys (``, ``, `j`, `k`) to navigate -" "display" lines instead of "logical" lines (which makes it much simpler to deal -" with wrapped lines). Defaults to `1` (on). Set to `0` if you'd prefer not to -" run the mappings. -if !exists( "g:vimroom_navigation_keys" ) - let g:vimroom_navigation_keys = 1 -endif - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Plugin Code -" - -" Given the desired column width, and minimum sidebar width, determine -" the minimum window width necessary for splitting to make sense -let s:minwidth = g:vimroom_width + ( g:vimroom_min_sidebar_width * 2 ) - -" Save the current color scheme for reset later -let s:scheme = "" -if exists( "g:colors_name" ) - let s:scheme = g:colors_name -endif -if exists( "&t_mr" ) - let s:save_t_mr = &t_mr -end - -" Save the current scrolloff value for reset later -let s:save_scrolloff = "" -if exists( "&scrolloff" ) - let s:save_scrolloff = &scrolloff -end - -" Save the current `laststatus` value for reset later -let s:save_laststatus = "" -if exists( "&laststatus" ) - let s:save_laststatus = &laststatus -endif - -" Save the current `textwidth` value for reset later -let s:save_textwidth = "" -if exists( "&textwidth" ) - let s:save_textwidth = &textwidth -endif - -" Save the current `number` and `relativenumber` values for reset later -let s:save_number = 0 -let s:save_relativenumber = 0 -if exists( "&number" ) - let s:save_number = &number -endif -if exists ( "&relativenumber" ) - let s:save_relativenumber = &relativenumber -endif - -" Save the current `numberwidth` value for reset later -let s:save_numberwidth = '' -if exists('&numberwidth') - let s:save_numberwidth = &numberwidth -endif - -" We're currently in nonvimroomized state -let s:active = 0 - -function! s:is_the_screen_wide_enough() - return winwidth( winnr() ) >= s:minwidth -endfunction - -function! s:sidebar_size() - return ( winwidth( winnr() ) - g:vimroom_width - 2 ) / 2 -endfunction - -function! VimroomToggle() - if s:active == 1 - let s:active = 0 - " Close all other split windows - if g:vimroom_sidebar_height - wincmd j - close - wincmd k - close - endif - if g:vimroom_min_sidebar_width - wincmd l - close - wincmd h - close - endif - " Reset color scheme (or clear new colors, if no scheme is set) - if s:scheme != "" - exec( "colorscheme " . s:scheme ) - else - hi clear - endif - if s:save_t_mr != "" - exec( "set t_mr=" .s:save_t_mr ) - endif - " Reset `scrolloff` and `laststatus` - if s:save_scrolloff != "" - exec( "set scrolloff=" . s:save_scrolloff ) - endif - if s:save_laststatus != "" - exec( "set laststatus=" . s:save_laststatus ) - endif - if s:save_textwidth != "" - exec( "set textwidth=" . s:save_textwidth ) - endif - if s:save_numberwidth != '' - exec('set numberwidth=' . s:save_numberwidth) - endif - if s:save_number != 0 - set number - endif - if s:save_relativenumber != 0 - set relativenumber - endif - " Remove wrapping and linebreaks - set nowrap - set nolinebreak - else - if s:is_the_screen_wide_enough() - let s:active = 1 - let s:sidebar = s:sidebar_size() - " Set numberwidth - if s:save_numberwidth != '' - set numberwidth=1 - endif - " Turn off status bar - if s:save_laststatus != "" - setlocal laststatus=0 - endif - if g:vimroom_min_sidebar_width - " Create the left sidebar - exec( "silent leftabove " . s:sidebar . "vsplit new" ) - setlocal noma - setlocal nocursorline - setlocal nonumber - setlocal norelativenumber - wincmd l - " Create the right sidebar - exec( "silent rightbelow " . s:sidebar . "vsplit new" ) - setlocal noma - setlocal nocursorline - setlocal nonumber - setlocal norelativenumber - wincmd h - endif - if g:vimroom_sidebar_height - " Create the top sidebar - exec( "silent leftabove " . g:vimroom_sidebar_height . "split new" ) - setlocal noma - setlocal nocursorline - setlocal nonumber - setlocal norelativenumber - wincmd j - " Create the bottom sidebar - exec( "silent rightbelow " . g:vimroom_sidebar_height . "split new" ) - setlocal noma - setlocal nocursorline - setlocal nonumber - setlocal norelativenumber - wincmd k - endif - " Setup wrapping, line breaking, and push the cursor down - set wrap - set linebreak - set nonumber - set norelativenumber - if s:save_textwidth != "" - exec( "set textwidth=".g:vimroom_width ) - endif - if s:save_scrolloff != "" - exec( "set scrolloff=".g:vimroom_scrolloff ) - endif - - " Setup navigation over "display lines", not "logical lines" if - " mappings for the navigation keys don't already exist. - if g:vimroom_navigation_keys - try - noremap g - noremap g - noremap k gk - noremap j gj - inoremap g - inoremap g - catch /E227:/ - echo "Navigational key mappings already exist." - endtry - endif - - " Hide distracting visual elements - if has('gui_running') - let l:highlightbgcolor = "guibg=" . g:vimroom_guibackground - let l:highlightfgbgcolor = "guifg=" . g:vimroom_guibackground . " " . l:highlightbgcolor - else - let l:highlightbgcolor = "ctermbg=" . g:vimroom_guibackground - let l:highlightfgbgcolor = "ctermfg=" . g:vimroom_ctermbackground . " " . l:highlightbgcolor - endif - exec( "hi Normal " . l:highlightbgcolor ) - exec( "hi VertSplit " . l:highlightfgbgcolor ) - exec( "hi NonText " . l:highlightfgbgcolor ) - exec( "hi StatusLine " . l:highlightfgbgcolor ) - exec( "hi StatusLineNC " . l:highlightfgbgcolor ) - set t_mr="" - set fillchars+=vert:\ - endif - endif -endfunction - -" Create a mapping for the `VimroomToggle` function -noremap VimroomToggle :call VimroomToggle() - -" Create a `VimroomToggle` command: -command -nargs=0 VimroomToggle call VimroomToggle() - -" If no mapping exists, map it to `V`. -if !hasmapto( 'VimroomToggle' ) - nmap V VimroomToggle -endif From fc0195628950bbe7ecca0e563d5eb901754a9a41 Mon Sep 17 00:00:00 2001 From: "Vayn a.k.a. VT" Date: Mon, 10 Oct 2011 06:38:12 +0800 Subject: [PATCH 20/22] Close padding buffers if we quit current buffer --- plugin/vimroom.vim | 58 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/plugin/vimroom.vim b/plugin/vimroom.vim index bfc2761..4fe7e8e 100644 --- a/plugin/vimroom.vim +++ b/plugin/vimroom.vim @@ -105,12 +105,6 @@ if exists ( "&relativenumber" ) let s:save_relativenumber = &relativenumber endif -" Save the current `numberwidth` value for reset later -let s:save_numberwidth = '' -if exists('&numberwidth') - let s:save_numberwidth = &numberwidth -endif - " We're currently in nonvimroomized state let s:active = 0 @@ -122,6 +116,41 @@ function! s:sidebar_size() return ( winwidth( winnr() ) - g:vimroom_width - 2 ) / 2 endfunction +" Save current buffer name +let b:vimroom_bufname = expand("%:t") +" Close padding buffer if we quit current buffer +autocmd BufHidden bw | call s:close_padding() + +function! s:close_padding() + " Save buffer list + redir => buflist + silent ls! + redir END + + let has_other_buf = 0 + + " Is there other buffer open? + for buf in split(buflist, "\n") + if match(buf, '_RoomPadding') == -1 + let has_other_buf = 1 + break + endif + endfor + + if has_other_buf + " If there is other buffer existing, + " we close padding buffer first. + bd RoomPadding + " Initialize environment for other buffer + let b:vimroom_bufname = expand("%:t") + let s:active = 0 + autocmd BufHidden bw | call s:close_padding() + else + " Otherwise, we just quit vim + qa + endif +endfunction + function! VimroomToggle() if s:active == 1 let s:active = 0 @@ -157,9 +186,6 @@ function! VimroomToggle() if s:save_textwidth != "" exec( "set textwidth=" . s:save_textwidth ) endif - if s:save_numberwidth != '' - exec('set numberwidth=' . s:save_numberwidth) - endif if s:save_number != 0 set number endif @@ -173,24 +199,20 @@ function! VimroomToggle() if s:is_the_screen_wide_enough() let s:active = 1 let s:sidebar = s:sidebar_size() - " Set numberwidth - if s:save_numberwidth != '' - set numberwidth=1 - endif " Turn off status bar if s:save_laststatus != "" setlocal laststatus=0 endif if g:vimroom_min_sidebar_width " Create the left sidebar - exec( "silent leftabove " . s:sidebar . "vsplit new" ) + exec( "silent leftabove " . s:sidebar . "vsplit _RoomPadding" ) setlocal noma setlocal nocursorline setlocal nonumber setlocal norelativenumber wincmd l " Create the right sidebar - exec( "silent rightbelow " . s:sidebar . "vsplit new" ) + exec( "silent rightbelow " . s:sidebar . "vsplit _RoomPadding" ) setlocal noma setlocal nocursorline setlocal nonumber @@ -199,14 +221,14 @@ function! VimroomToggle() endif if g:vimroom_sidebar_height " Create the top sidebar - exec( "silent leftabove " . g:vimroom_sidebar_height . "split new" ) + exec( "silent leftabove " . g:vimroom_sidebar_height . "split _RoomPadding" ) setlocal noma setlocal nocursorline setlocal nonumber setlocal norelativenumber wincmd j " Create the bottom sidebar - exec( "silent rightbelow " . g:vimroom_sidebar_height . "split new" ) + exec( "silent rightbelow " . g:vimroom_sidebar_height . "split _RoomPadding" ) setlocal noma setlocal nocursorline setlocal nonumber @@ -245,7 +267,7 @@ function! VimroomToggle() let l:highlightbgcolor = "guibg=" . g:vimroom_guibackground let l:highlightfgbgcolor = "guifg=" . g:vimroom_guibackground . " " . l:highlightbgcolor else - let l:highlightbgcolor = "ctermbg=" . g:vimroom_guibackground + let l:highlightbgcolor = "ctermbg=" . g:vimroom_ctermbackground let l:highlightfgbgcolor = "ctermfg=" . g:vimroom_ctermbackground . " " . l:highlightbgcolor endif exec( "hi Normal " . l:highlightbgcolor ) From 650bf97b3a36a83bc14f990d90cf8ef9dcbecb5d Mon Sep 17 00:00:00 2001 From: "Vayn a.k.a. VT" Date: Tue, 11 Oct 2011 23:19:09 +0800 Subject: [PATCH 21/22] Sometimes user would change colorscheme when they are in room --- plugin/vimroom.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugin/vimroom.vim b/plugin/vimroom.vim index 2f37478..a3b0c01 100644 --- a/plugin/vimroom.vim +++ b/plugin/vimroom.vim @@ -287,6 +287,8 @@ function! VimroomToggle() exec( "hi StatusLineNC " . l:highlightfgbgcolor ) set t_mr="" set fillchars+=vert:\ + " Sometimes user would change colorscheme when they are in room + autocmd ColorScheme let s:scheme = g:colors_name endif endif endfunction From f9bbbc50050ce7b13514b7ef3d5087d12ece5b67 Mon Sep 17 00:00:00 2001 From: "Vayn a.k.a. VT" Date: Wed, 12 Oct 2011 05:03:21 +0800 Subject: [PATCH 22/22] Enhanced solution for closing padding buffers when we quit current buffer --- plugin/vimroom.vim | 88 ++++++++++++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 35 deletions(-) diff --git a/plugin/vimroom.vim b/plugin/vimroom.vim index a3b0c01..a2184af 100644 --- a/plugin/vimroom.vim +++ b/plugin/vimroom.vim @@ -127,36 +127,54 @@ endfunction " Save current buffer name let b:vimroom_bufname = expand("%:t") " Close padding buffer if we quit current buffer -autocmd BufHidden bw | call s:close_padding() +autocmd BufHidden call s:close_padding() function! s:close_padding() - " Save buffer list - redir => buflist - silent ls! - redir END - - let has_other_buf = 0 - - " Is there other buffer open? - for buf in split(buflist, "\n") - if match(buf, '_RoomPadding') == -1 - let has_other_buf = 1 - break + " Try to close current buffer and related padding buffers + try + " Unload current buffer + bdelete + " Save buffer list + redir => buflist + silent ls + redir END + + let has_other_buf = 0 + + " Is there other buffer open? + for buf in split(buflist, "\n") + if match(buf, '_RoomPadding') == -1 + let has_other_buf = 1 + break + endif + endfor + + if has_other_buf + " If there is other buffer existing, + " we close padding buffer first. + bwipeout _RoomPadding + " Initialize environment for other buffer + let b:vimroom_bufname = expand("%:t") + let s:active = 0 + autocmd BufHidden call s:close_padding() + else + " Otherwise, we just quit vim + qa endif - endfor - - if has_other_buf - " If there is other buffer existing, - " we close padding buffer first. - bd RoomPadding - " Initialize environment for other buffer - let b:vimroom_bufname = expand("%:t") - let s:active = 0 - autocmd BufHidden bw | call s:close_padding() - else - " Otherwise, we just quit vim - qa - endif + catch + " XXX It is not the best solution, but I have no other better solutions. + " If the current buffer has been changed, and we didn't save it before + " we quit, we would be in here. + + " Close padding buffers + bwipeout _RoomPadding + + " Show errors and warnings + let exc = substitute(v:exception, 'Vim([a-z]*):', '', '') + echohl ErrorMsg | echo exc | echohl None + echohl WarningMsg | echo "You are in a weird dimension." | echohl None + echohl WarningMsg | echo "The best thing you should do now is save and quit." | echohl None + endtry endfunction function! VimroomToggle() @@ -177,28 +195,28 @@ function! VimroomToggle() endif " Reset color scheme (or clear new colors, if no scheme is set) if s:scheme != "" - exec( "colorscheme " . s:scheme ) + exec( "colorscheme " . s:scheme ) else - hi clear + hi clear endif if s:save_t_mr != "" - exec( "set t_mr=" .s:save_t_mr ) + exec( "set t_mr=" .s:save_t_mr ) endif " Reset `scrolloff` and `laststatus` if s:save_scrolloff != "" - exec( "set scrolloff=" . s:save_scrolloff ) + exec( "set scrolloff=" . s:save_scrolloff ) endif if s:save_laststatus != "" - exec( "set laststatus=" . s:save_laststatus ) + exec( "set laststatus=" . s:save_laststatus ) endif if s:save_textwidth != "" - exec( "set textwidth=" . s:save_textwidth ) + exec( "set textwidth=" . s:save_textwidth ) endif if s:save_number != 0 - set number + set number endif if s:save_relativenumber != 0 - set relativenumber + set relativenumber endif " Remove wrapping and linebreaks set nowrap