diff --git a/.vimrc b/.vimrc index bccbaf5..b49fce7 100644 --- a/.vimrc +++ b/.vimrc @@ -236,25 +236,33 @@ nnoremap z :set nonumber! norelativenumber! : autocmd BufLeave,FocusLost,InsertEnter,WinLeave * if &nu | set nornu | endif :augroup END -function! Whitespaces() +" einzelne AufrÀumfunktionen, bei F9 werden alle gecalled +" trailing whitespaces werden automatisch beim speichern entfernt +function! Whitespaces_trailing() " Remove trailing whitespace %s/\s\+$//e - +endfunction +function! Whitespaces_consecutive() " Replace consecutive spaces between words with a single space (only for .md files) if &filetype == "markdown" %s/\(\w\)\s\+\(\w\)/\1 \2/g endif - +endfunction +function! Whitespaces_lines() " Run silent command to remove multiple consecutive empty lines (only for .md files) if &filetype == "markdown" silent %!cat -s endif endfunction - +function! Whitespaces_all() + call Whitespaces_trailing() + call Whitespaces_consecutive() + call Whitespaces_lines() +endfunction " Map F9 to execute the custom function -nnoremap :call Whitespaces() - - +nnoremap :call Whitespaces_all() +" entferne trailing whitespaces beim speichern +autocmd BufWritePre * :call Whitespaces_trailing() " Exit Vim if NERDTree is the only window remaining in the only tab. autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif