Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add the useful parts of my vimrc

  • Loading branch information...
commit 63af46f302997e030cdc8ad349f720f0fadbb6ab 1 parent 080043b
@scrooloose authored
Showing with 129 additions and 0 deletions.
  1. +129 −0 vimrc
View
129 vimrc
@@ -0,0 +1,129 @@
+"Use Vim settings, rather then Vi settings (much better!).
+"This must be first, because it changes other options as a side effect.
+set nocompatible
+
+"allow backspacing over everything in insert mode
+set backspace=indent,eol,start
+
+"store lots of :cmdline history
+set history=1000
+
+set showcmd "show incomplete cmds down the bottom
+set showmode "show current mode down the bottom
+
+set incsearch "find the next match as we type the search
+set hlsearch "hilight searches by default
+
+set nowrap "dont wrap lines
+set linebreak "wrap lines at convenient points
+
+"statusline setup
+set statusline=%t "tail of the filename
+set statusline+=[%{strlen(&fenc)?&fenc:'none'}, "file encoding
+set statusline+=%{&ff}] "file format
+set statusline+=%h "help file flag
+set statusline+=%m "modified flag
+set statusline+=%r "read only flag
+set statusline+=%y "filetype
+set statusline+=%= "left/right separator
+set statusline+=%c, "cursor column
+set statusline+=%l/%L "cursor line/total lines
+set statusline+=\ %P "percent through file
+set laststatus=2
+
+"indent settings
+set shiftwidth=4
+set softtabstop=4
+set expandtab
+set autoindent
+
+"folding settings
+set foldmethod=indent "fold based on indent
+set foldnestmax=3 "deepest fold is 3 levels
+set nofoldenable "dont fold by default
+
+set wildmode=list:longest "make cmdline tab completion similar to bash
+set wildmenu "enable ctrl-n and ctrl-p to scroll thru matches
+
+"display tabs and trailing spaces
+set list
+set listchars=tab:▷⋅,trail:⋅,nbsp:⋅
+
+set formatoptions-=o "dont continue comments when pushing o/O
+
+"vertical/horizontal scroll off settings
+set scrolloff=3
+set sidescrolloff=7
+set sidescroll=1
+
+"load ftplugins and indent files
+filetype plugin on
+filetype indent on
+
+"turn on syntax highlighting
+syntax on
+
+"some stuff to get the mouse going in term
+set mouse=a
+set ttymouse=xterm2
+
+"tell the term has 256 colors
+set t_Co=256
+
+"hide buffers when not displayed
+set hidden
+
+"make <c-l> clear the highlight as well as redraw
+nnoremap <C-L> :nohls<CR><C-L>
+inoremap <C-L> <C-O>:nohls<CR>
+
+"map Q to something useful
+noremap Q gq
+
+"make Y consistent with C and D
+nnoremap Y y$
+
+"visual search mappings
+function! s:VSetSearch()
+ let temp = @@
+ norm! gvy
+ let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g')
+ let @@ = temp
+endfunction
+vnoremap * :<C-u>call <SID>VSetSearch()<CR>//<CR>
+vnoremap # :<C-u>call <SID>VSetSearch()<CR>??<CR>
+
+
+" jump to last cursor position when opening a file
+" dont do it when writing a commit log entry
+autocmd BufReadPost * call SetCursorPosition()
+function! SetCursorPosition()
+ if &filetype !~ 'commit\c'
+ if line("'\"") > 0 && line("'\"") <= line("$")
+ exe "normal g`\""
+ endif
+ end
+endfunction
+
+
+"simple template system
+command! -complete=customlist,<SID>AvailableTemplates -n=1
+ \ Template :call <SID>InsertTemplate('<args>')
+
+function! <SID>InsertTemplate(name)
+ "read in the template
+ execute 'read ~/.vim/templates/' . &filetype . '/' . a:name
+
+ "if the cursor was previously on a blank line, delete it
+ if getline(line(".")-1) =~ '^\s*$'
+ exec line(".")-1 . 'd'
+ endif
+endfunction
+
+function! <SID>AvailableTemplates(lead, cmdline, cursorpos)
+ let templateDir = expand('~/.vim/templates/' . &filetype . '/')
+ let files = split(globpath(templateDir, a:lead . '*'), '\n')
+
+ "chop off the templateDir from each file
+ return map(files, 'strpart(v:val,strlen(templateDir))')
+endfunction
Please sign in to comment.
Something went wrong with that request. Please try again.