From 53b73c8d7767e2ba26644e3c8bf78fc8c7cd82e0 Mon Sep 17 00:00:00 2001 From: Michael Campagnaro Date: Wed, 26 Jul 2017 12:07:31 -0400 Subject: [PATCH] Improve vim text wrapping --- vimrc | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/vimrc b/vimrc index 5623b6a..8138531 100644 --- a/vimrc +++ b/vimrc @@ -31,6 +31,7 @@ filetype off "################################################################ "################################################################ +let s:max_row_length = 100 let s:default_bg = 'dark' let s:rainbow_theme = s:default_bg @@ -228,7 +229,7 @@ syntax on set wildmenu set wildmode=longest,list,full set wildignore+=*/tmp/*,*/log/*,*.so,*.swp,*.zip,*/rdoc/* -set colorcolumn=90 +let &colorcolumn=s:max_row_length " Show trailing whitespace set list listchars=tab:»·,trail:· " Adding this since the esc remap on the 'i' key had a long delay when pressed @@ -253,14 +254,6 @@ if has('persistent_undo') set undofile endif -" Wrap text files and don't split up words. Everything else doesn't get -" wrapped. -set nowrap -au BufNewFile,BufRead *.txt setlocal wrap -au BufNewFile,BufRead *.txt setlocal lbr -au BufNewFile,BufRead *.md setlocal wrap -au BufNewFile,BufRead *.md setlocal lbr - " Remove trailing whitespace on save all files. au BufWritePre * :%s/\s\+$//e @@ -289,8 +282,15 @@ imap augroup campoCmds " Clear all autocmds in the group autocmd! - autocmd FileType text setlocal textwidth=78 + + " Automatically wrap at N characters autocmd FileType gitcommit setlocal colorcolumn=72 + autocmd BufRead,BufNewFile *.{md,txt} execute "setlocal textwidth=" .s:max_row_length + + " Spell checking + autocmd FileType gitcommit setlocal spell + autocmd FileType markdown setlocal spell + autocmd FileType text setlocal spell " Jump to last cursor position unless it's invalid or in an event handler autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif @@ -301,6 +301,14 @@ augroup campoCmds " Indent p tags autocmd FileType html,eruby if g:html_indent_tags !~ '\\|p\>' | let g:html_indent_tags .= '\|p\|li\|dt\|dd' | endif + " Properly indent schemes (scheme, racket, etc) + autocmd bufread,bufnewfile *.{lisp,scm,rkt} setlocal equalprg=scmindent.rkt + + " Auto reload VIM when settings changed + autocmd BufWritePost .vimrc so $MYVIMRC + autocmd BufWritePost *.vim so $MYVIMRC + autocmd BufWritePost vimrc.symlink so $MYVIMRC + "//////////////////////////////////////////////////////////////// " FILE TEMPLATES "//////////////////////////////////////////////////////////////// @@ -554,13 +562,6 @@ function! ReloadRainbow() endfunction -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" SCHEME -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" properly indent schemes (scheme, racket, etc) -autocmd bufread,bufnewfile *.lisp,*.scm,*.rkt setlocal equalprg=scmindent.rkt - - """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " C-TAGS """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""