Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
.vimrc: Add some goodies found in @alrra’s dotfiles
  • Loading branch information
mathiasbynens committed Feb 9, 2012
1 parent 6135d22 commit e4f42d3
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions .vimrc
Expand Up @@ -55,20 +55,32 @@ set shortmess=atI
set showmode
" Show the filename in the window titlebar
set title
" Show the (partial) command as it’s being typed
set showcmd
" Use relative line numbers
if exists("&relativenumber")
" Use relative line numbers
set relativenumber
au BufReadPost * set relativenumber
endif
" Start scrolling three lines before the horizontal window border
set scrolloff=3

" Strip trailing whitespace (,ss)
function! StripWhitespace ()
function! StripWhitespace()
let save_cursor = getpos(".")
let old_query = getreg('/')
:%s/\s\+$//e
call setpos('.', save_cursor)
call setreg('/', old_query)
endfunction
noremap <leader>ss :call StripWhitespace ()<CR>
noremap <leader>ss :call StripWhitespace()<CR>
" Save a file as root (,W)
noremap <leader>W :w !sudo tee % > /dev/null<CR>
" Automatic commands
if has("autocmd")
" Enable file type detection
filetype on
" Treat .json files as .js
autocmd BufNewFile,BufRead *.json setfiletype json syntax=javascript
endif

0 comments on commit e4f42d3

Please sign in to comment.