" Toggle wordwrap
function WrapToggle()
- if &wrap
- call WrapOff()
- echo "Word wrap off"
- else
- call WrapOn()
- echo "Word wrap on"
- endif
+ if &wrap
+ call WrapOff()
+ echo "Word wrap off"
+ else
+ call WrapOn()
+ echo "Word wrap on"
+ endif
endfunction
" Turn word wrap off, reset arrows, home, end, etc to default bindings
function WrapOff()
- setlocal nowrap
- " Go up and down by physical linebreaks when not wordwrapped
- iunmap <buffer> <End>
- iunmap <buffer> <Home>
- iunmap <buffer> <Down>
- iunmap <buffer> <Up>
- nunmap <buffer> <Down>
- nunmap <buffer> <Up>
- nunmap <buffer> <End>
- nunmap <buffer> <Home>
- nunmap <buffer> 0
- nunmap <buffer> ^
- nunmap <buffer> $
- vunmap <buffer> <Down>
- vunmap <buffer> <Up>
- vunmap <buffer> <End>
- vunmap <buffer> <Home>
- vunmap <buffer> 0
- vunmap <buffer> ^
- vunmap <buffer> $
- " Allow only backspace & space
- set whichwrap=b,s
+ setlocal nowrap
+ " Go up and down by physical linebreaks when not wordwrapped
+ iunmap <buffer> <End>
+ iunmap <buffer> <Home>
+ iunmap <buffer> <Down>
+ iunmap <buffer> <Up>
+ nunmap <buffer> <Down>
+ nunmap <buffer> <Up>
+ nunmap <buffer> <End>
+ nunmap <buffer> <Home>
+ nunmap <buffer> 0
+ nunmap <buffer> ^
+ nunmap <buffer> $
+ vunmap <buffer> <Down>
+ vunmap <buffer> <Up>
+ vunmap <buffer> <End>
+ vunmap <buffer> <Home>
+ vunmap <buffer> 0
+ vunmap <buffer> ^
+ vunmap <buffer> $
+ " Allow only backspace & space
+ set whichwrap=b,s
endfunction
" Turn word wrapping on and bind arrows, home, end, etc to display lines
function WrapOn()
- setlocal wrap
- " Go up and down by display lines, not linebreaks when wordwrapped
- imap <buffer> <End> <C-o>g$
- imap <buffer> <Home> <C-o>g0
- imap <buffer> <Down> <C-o>gj
- imap <buffer> <Up> <C-o>gk
- nmap <buffer> <Down> gj
- nmap <buffer> <Up> gk
- nmap <buffer> <End> g$
- nmap <buffer> <Home> g0
- nmap <buffer> 0 g0
- nmap <buffer> ^ g^
- nmap <buffer> $ g$
- vmap <buffer> <Down> gj
- vmap <buffer> <Up> gk
- vmap <buffer> <End> g$
- vmap <buffer> <Home> g0
- vmap <buffer> 0 g0
- vmap <buffer> ^ g^
- vmap <buffer> $ g$
- " Allow backspace, space, left/right keys to move across lines
- set whichwrap=b,s,<,>,[,]
+ setlocal wrap
+ " Go up and down by display lines, not linebreaks when wordwrapped
+ imap <buffer> <End> <C-o>g$
+ imap <buffer> <Home> <C-o>g0
+ imap <buffer> <Down> <C-o>gj
+ imap <buffer> <Up> <C-o>gk
+ nmap <buffer> <Down> gj
+ nmap <buffer> <Up> gk
+ nmap <buffer> <End> g$
+ nmap <buffer> <Home> g0
+ nmap <buffer> 0 g0
+ nmap <buffer> ^ g^
+ nmap <buffer> $ g$
+ vmap <buffer> <Down> gj
+ vmap <buffer> <Up> gk
+ vmap <buffer> <End> g$
+ vmap <buffer> <Home> g0
+ vmap <buffer> 0 g0
+ vmap <buffer> ^ g^
+ vmap <buffer> $ g$
+ " Allow backspace, space, left/right keys to move across lines
+ set whichwrap=b,s,<,>,[,]
endfunction
" Toggle show invisible characters
function InvShow()
- if &list
- echo "Invisible characters off"
- set nolist
- else
- echo "Invisible characters on"
- set listchars=tab:.\ ,trail:!
- set list
- endif
+ if &list
+ echo "Invisible characters off"
+ set nolist
+ else
+ echo "Invisible characters on"
+ set listchars=tab:.\ ,trail:!
+ set list
+ endif
endfunction
" Spell checking mode toggle
function ToggleSpelling()
- if !exists("s:spell_check") || s:spell_check == 0
- echo "Spell check on"
- let s:spell_check = 1
- setlocal spell spelllang=en_au
- else
- echo "Spell check off"
- let s:spell_check = 0
- setlocal spell spelllang=
- endif
+ if !exists("s:spell_check") || s:spell_check == 0
+ echo "Spell check on"
+ let s:spell_check = 1
+ setlocal spell spelllang=en_au
+ else
+ echo "Spell check off"
+ let s:spell_check = 0
+ setlocal spell spelllang=
+ endif
endfunction
" Save using sudo
function SudoWriteFunction()
- :w !sudo tee %
- :e!
+ :w !sudo tee %
+ :e!
endfunction