Added ,ws to strip trailing whitespace in a file
This commit is contained in:
parent
cbf5cacb76
commit
30725b537e
@ -218,6 +218,7 @@ files contain key mappings as well (TODO: probably will move them out to skwp-ke
|
|||||||
* ,jF factories
|
* ,jF factories
|
||||||
|
|
||||||
**RSI-reduction**
|
**RSI-reduction**
|
||||||
|
|
||||||
* Cmd-k and Cmd-d to type underscores and dashes (use Shift), since they are so common in code but so far away from home row
|
* Cmd-k and Cmd-d to type underscores and dashes (use Shift), since they are so common in code but so far away from home row
|
||||||
* ; instead of : - avoid Shift for common tasks, just hit semicolon to get to ex mode
|
* ; instead of : - avoid Shift for common tasks, just hit semicolon to get to ex mode
|
||||||
* ,. to go to last edit location instead of '. because the apostrophe is hard on the pinky
|
* ,. to go to last edit location instead of '. because the apostrophe is hard on the pinky
|
||||||
@ -252,6 +253,7 @@ files contain key mappings as well (TODO: probably will move them out to skwp-ke
|
|||||||
* ,cc - (Current command) copies the command under your cursor and executes it in vim. Great for testing single line changes to vimrc.
|
* ,cc - (Current command) copies the command under your cursor and executes it in vim. Great for testing single line changes to vimrc.
|
||||||
* ,yw - yank a word from anywhere within the word (so you don't have to go to the beginning of it)
|
* ,yw - yank a word from anywhere within the word (so you don't have to go to the beginning of it)
|
||||||
* ,ow - overwrite a word with whatever is in your yank buffer - you can be anywhere on the word. saves having to visually select it
|
* ,ow - overwrite a word with whatever is in your yank buffer - you can be anywhere on the word. saves having to visually select it
|
||||||
|
* ,ws - strip trailing whitespaces
|
||||||
* sj - split a line such as a hash {:foo => {:bar => :baz}} into a multiline hash (j = down)
|
* sj - split a line such as a hash {:foo => {:bar => :baz}} into a multiline hash (j = down)
|
||||||
* sk - unsplit a link (k = up)
|
* sk - unsplit a link (k = up)
|
||||||
* Cmd-Shift-A - align things (type a character/expression to align by, works in visual mode or by itself)
|
* Cmd-Shift-A - align things (type a character/expression to align by, works in visual mode or by itself)
|
||||||
|
15
vim/plugin/settings/whitespace-killer.vim
Normal file
15
vim/plugin/settings/whitespace-killer.vim
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
" via: http://rails-bestpractices.com/posts/60-remove-trailing-whitespace
|
||||||
|
" Strip trailing whitespace
|
||||||
|
function! <SID>StripTrailingWhitespaces()
|
||||||
|
" Preparation: save last search, and cursor position.
|
||||||
|
let _s=@/
|
||||||
|
let l = line(".")
|
||||||
|
let c = col(".")
|
||||||
|
" Do the business:
|
||||||
|
%s/\s\+$//e
|
||||||
|
" Clean up: restore previous search history, and cursor position
|
||||||
|
let @/=_s
|
||||||
|
call cursor(l, c)
|
||||||
|
endfunction
|
||||||
|
command! StripTrailingWhitespaces call <SID>StripTrailingWhitespaces()
|
||||||
|
nmap ,ws :StripTrailingWhitespaces<CR>
|
Loading…
Reference in New Issue
Block a user