Vim Tip I always forget
To get rid of all the crazy ^M’s that appear in files from windows boxes. In vim:
:%s/C-vC-m//g
(That’s Control-v, Control-m).
To get rid of all the crazy ^M’s that appear in files from windows boxes. In vim:
:%s/C-vC-m//g
(That’s Control-v, Control-m).
or, from the command line:
# dos2unix filename
but I like the vim tip because not all boxes will have dos2unix (though I bet most do)
Using an autocommand to switch the file format automatically from dos/mac to unix for source files works as well.
autocmd FileType perl,pm,lisp,scheme,tcl,python,c setlocal ff=unix
Another nicety strips off the trailing whitespace on writes:
function! DeleteTrailingWS()
normal mz
%s/\s\+$//ge
normal `z
endfunction
if has(“autocmd”)
autocmd BufWrite *.py :call DeleteTrailingWS()
endif