Browse files

Add multipurpose tab and rename current file

  • Loading branch information...
1 parent 8e0a33e commit 1fc388437939cc76c0a866958b92edaeda088ff2 @derwiki committed May 22, 2012
Showing with 44 additions and 22 deletions.
  1. +2 −0 .gitconfig
  2. +42 −22 .vimrc
View
2 .gitconfig
@@ -119,3 +119,5 @@
# update or initialize each submodule
ten = log --oneline --graph -10
+
+ ridof = !sh -c 'wc -l $1 && git rm $1' -
View
64 .vimrc
@@ -112,28 +112,31 @@ set wildmenu
set showmatch " Show matching parens as they come up
set ruler " Show the column number in the status bar
set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%)
-" gvim stuff
+set shortmess+=A " ignore annoying swapfile messagesÂ
+set shortmess+=I " no splash screen
colorscheme elflord
if exists('+colorcolumn')
set cc=80 " character color after 80 characters
endif
" switch tabs
-map = gt
-map - gT
-map <C-j> gT<CR>
-map <C-k> gt<CR>
-map <C-h> gT<CR>
-map <C-l> gt<CR>
+"map = gt
+"map - gT
+map <c-j> gT
+map <c-k> gt
+map <c-h> gT
+map <c-l> gt
" quick edit mode escape
imap jj <Esc>
set backspace=2 " make the backspace key work
-map <Leader>r :!ruby -c %<CR>
-cmap Wq<CR> wq<CR>
-cmap Wqa<CR> wqa<CR>
+" turn off highlight when hitting return
+:nnoremap <CR> :nohlsearch<cr>
+
+" Insert a hash rocket with <c-l>
+imap <c-l> <space>=><space>
"filetype on
"filetype plugin on
@@ -153,20 +156,16 @@ function! ToggleMouse()
echo "Mouse usage enabled"
endif
endfunction
-
nnoremap <F7> :set nu!<CR>
-set textwidth=80
-highlight OverLength cterm=none ctermfg=1 ctermbg=0
-autocmd BufWritePre * :%s/\s\+$//e " Remove trailing whitespace
-
set backupdir=/tmp
set directory=/tmp
" pathogen stuff
call pathogen#runtime_append_all_bundles() " add .vim/bundle subdirs to runtime path
call pathogen#helptags() " wasteful, but no shortage of grunt available
+" common pressed-shift-too-long typos
cabbrev Q q
cabbrev Wq wq
cabbrev W w
@@ -180,10 +179,31 @@ noremap <Down> <nop>
noremap <Left> <nop>
noremap <Right> <nop>
-nnoremap <F5> :GundoToggle<CR>
-
-" move around in vim splits with ctrl-<movement keys>
-map <c-j> <c-w>j
-map <c-k> <c-w>k
-map <c-l> <c-w>l
-map <c-h> <c-w>h
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" MULTIPURPOSE TAB KEY
+" Indent if we're at the beginning of a line. Else, do completion.
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+function! InsertTabWrapper()
+ let col = col('.') - 1
+ if !col || getline('.')[col - 1] !~ '\k'
+ return "\<tab>"
+ else
+ return "\<c-p>"
+ endif
+endfunction
+inoremap <tab> <c-r>=InsertTabWrapper()<cr>
+inoremap <s-tab> <c-n>
+
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" RENAME CURRENT FILE
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+function! RenameFile()
+ let old_name = expand('%')
+ let new_name = input('New file name: ', expand('%'), 'file')
+ if new_name != '' && new_name != old_name
+ exec ':saveas ' . new_name
+ exec ':silent !rm ' . old_name
+ redraw!
+ endif
+endfunction
+map <leader>n :call RenameFile()<cr>

0 comments on commit 1fc3884

Please sign in to comment.