whitespace snippets

Strip trailing whitespace with vim

Tagged vim, whitespace  Languages 
" Strip trailing whitespace
function! <SID>StripTrailingWhitespaces()
    " Skip these
    if &ft =~ '\|slim|haml'
    " Preparation: save last search, and cursor position.
    let [email protected]/
    let l = line(".")
    let c = col(".")
    " Do the business:
    " Clean up: restore previous search history, and cursor position
    let @/=_s
    call cursor(l, c)
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()

How to fix "command not found:  grep" on OSX

Tagged key bindings, alt, space, whitespace, ruby, grep  Languages bash

This issue will bite everyone who touches a keyboard. This fixes, e.g., the following issues: * command not found:  grep (Shell) * undefined local variable or method (Ruby) *

First, do this:

mkdir -p ~/Library/KeyBindings/
vim ~/Library/KeyBindings/DefaultKeyBinding.dict

Then paste this:

  "~ " = ("insertText:", " ");

Save the file.

Quit and reopen applications to apply the new key bindings in DefaultKeyBinding.dict.


http://osxnotes.net/keybindings.html http://linuxtoosx.blogspot.fi/2010/10/disabling-option-space-and-altgr-space.html


For MacVim i have yet to find a solution for insert mode, so just use vim in the terminal...