Skip to content

Instantly share code, notes, and snippets.

@git2samus
Created September 10, 2012 00:18
Show Gist options
  • Select an option

  • Save git2samus/3688073 to your computer and use it in GitHub Desktop.

Select an option

Save git2samus/3688073 to your computer and use it in GitHub Desktop.
helper for plaintext file edition in vim
fun! TextMode(mode) range
if a:mode == 'textmode'
setlocal filetype=text
setlocal wrap
setlocal nolist
setlocal linebreak
nnoremap <buffer> j gj
nnoremap <buffer> k gk
nnoremap <buffer> 0 g0
nnoremap <buffer> $ g$
echo 'textmode'
else
filetype detect
setlocal nowrap
setlocal list
setlocal nolinebreak
nunmap <buffer> j
nunmap <buffer> k
nunmap <buffer> 0
nunmap <buffer> $
echo 'notextmode'
endif
endfun
nnoremap <Leader>t :call TextMode('textmode')<CR>
nnoremap <Leader>T :call TextMode('notextmode')<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment