first commit
David Blume authored 9 years ago
|
2) set nocompatible " Use Vim defaults, forget compatibility with vi.
3) set bs=2 " allow backspacing over everything in insert mode
4) set wildmenu " Allows command-line completion with tab
5) set autoindent " Copy indent from current line when starting a new line
6) set smartindent " Do smart auto indenting when starting new line
7) set smarttab " Honor 'shiftwidth', 'tabstop' or 'softtabstop'
8) set hlsearch " highlight all matches for previous search
9) set nofoldenable " start unfolded
10) set foldlevel=0
11) set nowrap " no wrapping text lines on the screen (exceptions below)
12) set sidescroll=5
13) set listchars+=tab:>-,precedes:<,extends:> " indicators of long lines
14)
15) if v:version >= 703
16) " Do save the undo tree to file, but not in the local directory.
17) " Don't forget to mkdir ~/.vim_undo
18) set undodir=~/.vim_undo,.
19) set undofile " undo even after closing and reopening a file
20) endif
21)
22) " The following two lines set the use of perl regex, aka "very magic"
23) nnoremap / /\v
24) vnoremap / /\v
25)
26) " nnoremap <cr> :noh<cr><cr> " clear search highlights
27)
28) " Commented out because I want tags searches to always be case sensitive.
29) " Override with \c anywhere in your search.
30) "set ignorecase " If you enter all lowercase, it's case insensitive,
31) "set smartcase " if you use mixed-case terms, it's case sensitive.
32)
33) syntax on
34)
35) " If you think this is hard to read,
36) " change the color of comments in vim, or
37) " use another color scheme like desert or peaksea
38) "
39) set t_Co=256
40) if v:version >= 703
41) set colorcolumn=80
42) endif
43) if has('gui_running') " Didn't work: if &term != 'builtin_gui'
44) " Light backgrounds for GUI experiences
45) set background=light
46) " colorscheme peaksea " install peaksea
47) colorscheme tolerable " install tolerable
48) if v:version >= 703
49) highlight ColorColumn ctermbg=255 guibg=#F6F6F6
50) endif
51) highlight StatusLine ctermfg=17 ctermbg=Gray " override scheme (overridden by powerline)
52) highlight StatusLineNC ctermfg=20 ctermbg=LightGray" override scheme
53) set lines=50 columns=100
54) else
55) " Dark backgrounds for tty experiences
56) set background=dark
57) colorscheme desert " install desert
58) if v:version >= 703
59) highlight ColorColumn ctermbg=234 guibg=Black " dark gray (or 17, dark blue)
60) endif
61) highlight StatusLine ctermfg=20 ctermbg=Gray " override scheme (overridden by powerline)
62) highlight StatusLineNC ctermfg=17 ctermbg=DarkGray" override scheme
63) endif
64) " highlight Comment term=bold ctermfg=Blue ctermbg=0 guifg=SlateBlue guibg=Black
65)
66) " set mouse=v " visual mode, not working great for PuTTY
67)
68) set tags=tags;/
69)
70) set history=50
71) set ruler
72) if has('statusline')
73) set laststatus=2
74) set statusline=%<%f\ " Filename
75) set statusline+=%w%h%m%r " Options
76) "set statusline+=%{fugitive#statusline()} " Git
77) "set statusline+=\ [%{&ff}/%Y] " filetype
78) "set statusline+=\ [%{getcwd()}] " current dir
79) "set statusline+=\ [A=\%03.3b/H=\%02.2B] " ASCII / Hexadecimal value of char
80) set statusline+=%=%-14.(%l,%c%V%)\ %p%% " Right aligned file nav info
81) endif
82)
83) set encoding=utf-8
84)
85) " I don't set comma for mapleader because it's useful for reverse-finding.
86) " let mapleader = ","
87) " let g:mapleader = ","
88)
89) nmap <leader>w :w!<cr> " Fast saving
90) " I use relative number for cursor movement.
91) nmap <leader>r :set relativenumber!<cr>
92) nmap <leader>n :set number!<cr>
93)
94)
95) " Useful mappings for managing tabs
96) "
97) nmap <leader>th <esc>:tabprevious<cr>
98) nmap <leader>tl <esc>:tabnext<cr>
99) nmap <leader>tn :tabnew
100) nmap <leader>to :tabonly<cr>
101) nmap <leader>tc :tabclose<cr>
102) nmap <leader>tm :tabmove
103) " Opens a new tab with the current buffer's path
104) nmap <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
105)
106) " pastetoggle
107) nmap <leader>p :set invpaste paste?<cr>
108)
109) nmap <leader>e :NERDTreeToggle<cr> " install nerdtree (e for Explore)
110) nmap <leader>l :TlistToggle<cr> " install taglist
111) nmap <leader>bd :Bdelete<cr> " install vim-bbye
112)
113) " Visual mode mappings
114) """
115)
116) " map sort function to a key
117) vnoremap <leader>s :sort<cr>
118)
119) "easier moving of code blocks
120) vnoremap < <gv " better indentation
121) vnoremap > >gv " better indentation
122)
123) " If too many file system events are getting triggered.
124) set nobackup " ~ files
125) set nowritebackup " Don't write buff to temp, delete orig, rename temp to orig
126) set noswapfile " .swp files
127)
128) " Allow tags to open another buffer even if this one is modified
129) set hidden
130)
131) " Switch between source and header files
132) function! SwitchSourceHeader()
133) let s:ext = expand("%:e")
134) let s:base = expand("%:t:r")
135) let s:cmd = "find " . s:base
136) if (s:ext == "cpp" || s:ext == "c")
137) if findfile(s:base . ".h" ) != "" | exe s:cmd . ".h" | return | en
138) if findfile(s:base . ".hpp") != "" | exe s:cmd . ".hpp" | return | en
139) else
140) if findfile(s:base . ".cpp") != "" | exe s:cmd . ".cpp" | return | en
141) if findfile(s:base . ".c" ) != "" | exe s:cmd . ".c" | return | en
142) endif
143) endfunc
144)
145) " Demonstrates a way to look in a mirror directory
146) " function! OpenOther()
147) " if expand("%:e") == "cpp"
148) " exe "split" fnameescape(expand("%:p:r:s?src?include?").".h")
149) " elseif expand("%:e") == "h"
150) " exe "split" fnameescape(expand("%:p:r:s?include?src?").".cpp")
151) " endif
152) " endfunc
153)
154) " Delete trailing white space on save, useful for Python and CoffeeScript ;)
155) function! DeleteTrailingWS()
156) exe "normal mz"
157) %s/\s\+$//ge
158) exe "normal `z"
159) endfunc
160)
|
Add OpenInOtherWindow to .v...
David Blume authored 8 years ago
|
161) function! OpenInOtherWindow()
162) if winnr('$') == 1
163) exe "wincmd F"
164) else
165) let curNum = winnr()
166) let oldBuf = bufnr( "%" )
167) if curNum == 1
168) let othNum = 2
169) else
170) let othNum = 1
171) endif
172) exe "normal! gF"
173) let newBuf = bufnr( "%" )
174) let newLine = line(".")
175) exe 'hide buf' oldBuf
176) exe othNum . "wincmd w"
177) exe 'hide buf' newBuf
178) exe "normal! " . newLine . "G"
179) endif
180) endfunc
181)
182) nmap <silent> <leader>F :call OpenInOtherWindow()<cr>
183)
|
first commit
David Blume authored 9 years ago
|
184) if has("autocmd")
185) autocmd! BufWritePost .vimrc source % " re-source this file when saved.
186) autocmd BufWrite *.py :call DeleteTrailingWS() " Delete trailing whitespace
187) " Don't let smartindent unindent the # character in Python files
188) autocmd FileType python inoremap # X<c-h>#
|