Browse files

.vimrc: Add some goodies found in @alrra’s dotfiles

  • Loading branch information...
1 parent 6135d22 commit e4f42d3ca85bbf18a2156fc43699b236045dd3b3 @mathiasbynens committed Feb 9, 2012
Showing with 15 additions and 3 deletions.
  1. +15 −3 .vimrc
View
18 .vimrc
@@ -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.