aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-05-25 20:59:54 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-05-25 20:59:54 +1200
commit809fe73a31478f78788ea9a5f208abc81dcdefd5 (patch)
tree8f7b817a83cc65fb6dbd94efbe6e3506a12c750d
parentInline load guard conditionals (diff)
downloadvim-copy-linebreak-809fe73a31478f78788ea9a5f208abc81dcdefd5.tar.gz
vim-copy-linebreak-809fe73a31478f78788ea9a5f208abc81dcdefd5.zip
Move code out to autoload functions
-rw-r--r--autoload/copy_linebreak.vim31
-rw-r--r--plugin/copy_linebreak.vim38
2 files changed, 34 insertions, 35 deletions
diff --git a/autoload/copy_linebreak.vim b/autoload/copy_linebreak.vim
new file mode 100644
index 0000000..3ea5f1c
--- /dev/null
+++ b/autoload/copy_linebreak.vim
@@ -0,0 +1,31 @@
+" Enable copy-friendly linebreak options
+function! copy_linebreak#Enable() abort
+ setlocal nolinebreak linebreak?
+ let s:showbreak_save = &showbreak
+ set showbreak=
+ if exists('+breakindent')
+ setlocal nobreakindent
+ endif
+endfunction
+
+" Disable copy-friendly linebreak options
+function! copy_linebreak#Disable() abort
+ setlocal linebreak linebreak?
+ if exists('s:showbreak_save')
+ let &showbreak = s:showbreak_save
+ unlet s:showbreak_save
+ endif
+ if exists('+breakindent')
+ setlocal breakindent<
+ endif
+endfunction
+
+" Toggle copy-friendly linebreak options, using the current setting for the
+" 'linebreak' option as the pivot
+function! copy_linebreak#Toggle() abort
+ if &linebreak
+ call copy_linebreak#Enable()
+ else
+ call copy_linebreak#Disable()
+ endif
+endfunction
diff --git a/plugin/copy_linebreak.vim b/plugin/copy_linebreak.vim
index ac0f3cf..43018f1 100644
--- a/plugin/copy_linebreak.vim
+++ b/plugin/copy_linebreak.vim
@@ -10,45 +10,13 @@ if exists('loaded_copy_linebreak') || &compatible || v:version < 700
endif
let loaded_copy_linebreak = 1
-" Enable copy-friendly linebreak options
-function! s:CopyLinebreakEnable()
- setlocal nolinebreak linebreak?
- let s:showbreak_save = &showbreak
- set showbreak=
- if exists('+breakindent')
- setlocal nobreakindent
- endif
-endfunction
-
-" Disable copy-friendly linebreak options
-function! s:CopyLinebreakDisable()
- setlocal linebreak linebreak?
- if exists('s:showbreak_save')
- let &showbreak = s:showbreak_save
- unlet s:showbreak_save
- endif
- if exists('+breakindent')
- setlocal breakindent<
- endif
-endfunction
-
-" Toggle copy-friendly linebreak options, using the current setting for the
-" 'linebreak' option as the pivot
-function! s:CopyLinebreakToggle()
- if &linebreak
- call s:CopyLinebreakEnable()
- else
- call s:CopyLinebreakDisable()
- endif
-endfunction
-
" Provide mappings to the functions just defined
noremap <silent>
\ <Plug>(CopyLinebreakEnable)
- \ :<C-U>call <SID>CopyLinebreakEnable()<CR>
+ \ :<C-U>call copy_linebreak#Enable()<CR>
noremap <silent>
\ <Plug>(CopyLinebreakDisable)
- \ :<C-U>call <SID>CopyLinebreakDisable()<CR>
+ \ :<C-U>call copy_linebreak#Disable()<CR>
noremap <silent>
\ <Plug>(CopyLinebreakToggle)
- \ :<C-U>call <SID>CopyLinebreakToggle()<CR>
+ \ :<C-U>call copy_linebreak#Toggle()<CR>