aboutsummaryrefslogtreecommitdiff
path: root/vim/plugin/copy_linebreak.vim
diff options
context:
space:
mode:
Diffstat (limited to 'vim/plugin/copy_linebreak.vim')
-rw-r--r--vim/plugin/copy_linebreak.vim49
1 files changed, 27 insertions, 22 deletions
diff --git a/vim/plugin/copy_linebreak.vim b/vim/plugin/copy_linebreak.vim
index 1dc537d4..faeb1617 100644
--- a/vim/plugin/copy_linebreak.vim
+++ b/vim/plugin/copy_linebreak.vim
@@ -6,31 +6,36 @@
" Author: Tom Ryder <tom@sanctum.geek.nz>
" License: Same as Vim itself
"
-if has('eval')
+if exists('g:loaded_copy_linebreak')
+ \ || !has('linebreak')
+ \ || &compatible
+ finish
+endif
+let g:loaded_copy_linebreak = 1
- " Define function
- function! s:CopyLinebreak()
+" Define function
+function! s:CopyLinebreak()
- " If linebreak is on, turn it off
- if &l:linebreak
- setlocal nolinebreak linebreak?
- setlocal showbreak=
- if exists('&breakindent')
- setlocal nobreakindent
- endif
+ " If linebreak is on, turn it off
+ if &l:linebreak
+ setlocal nolinebreak linebreak?
+ setlocal showbreak=
+ if exists('&breakindent')
+ setlocal nobreakindent
+ endif
- " If it's off, turn it on
- else
- setlocal linebreak linebreak?
- setlocal showbreak<
- if exists('&breakindent')
- setlocal breakindent
- endif
+ " If it's off, turn it on
+ else
+ setlocal linebreak linebreak?
+ setlocal showbreak<
+ if exists('&breakindent')
+ setlocal breakindent
endif
+ endif
- endfunction
+endfunction
- " Provide mapping proxy to the function just defined
- noremap <Plug>CopyLinebreak
- \ :<C-U>call <SID>CopyLinebreak()<CR>
-endif
+" Provide mapping proxy to the function just defined
+noremap <silent> <unique>
+ \ <Plug>CopyLinebreak
+ \ :<C-U>call <SID>CopyLinebreak()<CR>