diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-11-04 18:48:22 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-11-04 18:48:22 +1300 |
commit | 63087e57b8b1aa030b431b86f3be533ee20f07dc (patch) | |
tree | d9c129817e6e9722bdd8c559dc2f341991b68040 /vim/config/whitespace.vim | |
parent | Merge branch 'hotfix/v0.6.1' (diff) | |
parent | Update dotfiles(7) manual from README.md (diff) | |
download | dotfiles-a24ca4fd5b9d7d954475a311d9ae402949884286.tar.gz (sig) dotfiles-a24ca4fd5b9d7d954475a311d9ae402949884286.zip |
Merge branch 'release/v0.7.0'v0.7.0
* release/v0.7.0: (21 commits)
Update dotfiles(7) manual from README.md
Bump version number
Add heading for Vim plugins subsection
Update README to mention Vim plugins
Rename toggle plugin again, use commands not funcs
Add short documentation for new custom plugins
Use same comment boilerplate for custom plugins
Check 'eval' feature for loading command_typos.vim
Wrap detect_background.vim func call in 'silent!'
Rename and refactor option toggle plugin
Don't suggest mappings in Vim plugin comments
Move Vim background detection logic into plugin
Specify an install-vim-autoload target
Spin 'fo' toggle out into new flag toggler plugin
Spin copyable linebreak config into new plugin
Spin stable join config out into new plugin
Use <Plug> prefix, make space strip configurable
Rename a misnamed variable in big_file.vim
Rename bigfile plugin to big_file
Move trailing space strip config into plugin
...
Diffstat (limited to 'vim/config/whitespace.vim')
-rw-r--r-- | vim/config/whitespace.vim | 59 |
1 files changed, 2 insertions, 57 deletions
diff --git a/vim/config/whitespace.vim b/vim/config/whitespace.vim index bfe2663d..75ab7173 100644 --- a/vim/config/whitespace.vim +++ b/vim/config/whitespace.vim @@ -1,57 +1,2 @@ -" Strip trailing whitespace with \x in the whole document -if has('eval') - - " Define function for stripping whitespace - function! s:StripTrailingWhitespace() - - " Iterating line number - let l:li = 1 - - " Line number of last line that had non-whitespace characters on it - let l:lw = 0 - - " Line number of the file's last line - let l:ll = line('$') - - " Iterate over the lines - while l:li <= l:ll - - " Get the line text - let l:line = getline(l:li) - - " Replace the line with a subsitution of its text stripping extraneous - " whitespace - call setline(l:li, substitute(l:line, '\m\C\s\+$', '', 'g')) - - " If this line has any non-whitespace characters on it, update l:lw with - " its index - if l:line =~# '\m\C\S' - let l:lw = l:li - endif - - " Increment the line counter for the next iteration - let l:li = l:li + 1 - endwhile - - " If the last non-whitespace line was before the last line proper, we can - " delete all lines after it - if l:lw < l:ll - - " Get the current line and column so we can return to it - " (Yes I know about winsaveview() and winrestview(); I want this to work - " even on very old versions of Vim if possible) - let l:lc = line('.') - let l:cc = col('.') - - " Delete the lines, which will move the cursor - execute l:lw + 1.',$ delete' - - " Return the cursor to the saved position - call cursor(l:lc, l:cc) - endif - endfunction - - " Map \x to the function just defined - nnoremap <silent> <Leader>x :<C-U>call <SID>StripTrailingWhitespace()<CR> - -endif +" \x strips trailing whitespace via a custom plugin +nmap <leader>x <Plug>StripTrailingWhitespace |