0e9a327d30520a0e7ca0cbdd513194458ebc7d97
dblume Harmonize Git in vim; If <c...

dblume authored 1 year ago

1) " Version 2023-04-26.1 - Harmonize the git commands for common recipes
David Blume first commit

David Blume authored 8 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
dblume Better fold settings for zA

dblume authored 1 year ago

9) set foldlevel=99
David Blume first commit

David Blume authored 8 years ago

10) set nowrap          " no wrapping text lines on the screen (exceptions below)
11) set sidescroll=5
dblume May use nbsp in PS1; add it...

dblume authored 2 years ago

12) set listchars+=tab:>-,precedes:<,extends:>,nbsp:· " for :set list
David Blume first commit

David Blume authored 8 years ago

13) 
14) if v:version >= 703
15)   " Do save the undo tree to file, but not in the local directory.
16)   " Don't forget to mkdir ~/.vim_undo
17)   set undodir=~/.vim_undo,.
18)   set undofile        " undo even after closing and reopening a file
19) endif
20) 
21) " The following two lines set the use of perl regex, aka "very magic"
22) nnoremap / /\v
23) vnoremap / /\v
24) 
David Blume vimrc key remappings. jk as...

David Blume authored 6 years ago

25) " Make j and k move to the next row, not file line
26) nnoremap j gj
27) nnoremap k gk
28) 
29) " From Steve Losh: http://learnvimscriptthehardway.stevelosh.com/chapters/10.html
dblume Use j and k for navigating...

dblume authored 1 year ago

30) " Map jk to ESC in insert mode (except when navigating popup menu)
31) inoremap <expr> jk pumvisible() ? '' : '<esc>'
32) inoremap <expr> j pumvisible() ? '<Down>' : 'j'
33) inoremap <expr> k pumvisible() ? '<Up>' : 'k'
David Blume vimrc key remappings. jk as...

David Blume authored 6 years ago

34) 
dblume Add easier window navigation.

dblume authored 2 years ago

35) " https://stevelosh.com/blog/2010/09/coming-home-to-vim/#s3-why-i-came-back-to-vim
36) nnoremap <leader>v <C-w>v<C-w>l
37) nnoremap <C-h> <C-w>h
38) nnoremap <C-j> <C-w>j
39) nnoremap <C-k> <C-w>k
40) nnoremap <C-l> <C-w>l
41) 
dblume map <leader>c and d to use...

dblume authored 1 year ago

42) " https://levelup.gitconnected.com/7-surprising-vim-tricks-that-will-save-you-hours-b158d23fe9b7
dblume Add git Blame to vim; add g...

dblume authored 1 year ago

43) "nnoremap d "_d
44) "nnoremap D "_D
45) "nnoremap c "_c
46) "nnoremap C "_C
47) "nnoremap x "_x
48) "nnoremap X "_X
49) "nnoremap <leader>d d
50) "nnoremap <leader>D D
51) "nnoremap <leader>c c
52) "nnoremap <leader>C C
53) "nnoremap <leader>x x
54) "nnoremap <leader>X X
dblume map <leader>c and d to use...

dblume authored 1 year ago

55) 
David Blume vimrc key remappings. jk as...

David Blume authored 6 years ago

56) " clear search highlights
57) nnoremap <cr> :noh<cr><cr>
David Blume first commit

David Blume authored 8 years ago

58) 
dblume tab key navigation of buffers

dblume authored 1 year ago

59) " tab switches to previous/next buffer
60) nnoremap <Tab> :bp<cr>
61) nnoremap <S-Tab> :bn<cr>
62) 
David Blume first commit

David Blume authored 8 years ago

63) syntax on
64) 
65) set t_Co=256
66) if v:version >= 703
67)   set colorcolumn=80
68) endif
69) if has('gui_running') " Didn't work: if &term != 'builtin_gui'
70)   " Light backgrounds for GUI experiences
71)   set background=light
72)   " colorscheme peaksea                        " install peaksea
73)   colorscheme tolerable                        " install tolerable
74)   if v:version >= 703
75)     highlight ColorColumn ctermbg=255 guibg=#F6F6F6
76)   endif
dblume Better statusline color.

dblume authored 2 years ago

77)   highlight StatusLine   ctermfg=17 ctermbg=Gray " override scheme
David Blume first commit

David Blume authored 8 years ago

78)   highlight StatusLineNC ctermfg=20 ctermbg=LightGray" override scheme
David Blume Specify a font for gvim on...

David Blume authored 4 years ago

79)   if has('win32')
80)     set guifont=DejaVu_Sans_Mono_for_Powerline:h10:cANSI:qDRAFT
81)   endif
David Blume first commit

David Blume authored 8 years ago

82)   set lines=50 columns=100
83) else
84)   " Dark backgrounds for tty experiences
85)   set background=dark
86)   colorscheme desert                           " install desert
87)   if v:version >= 703
David Blume Windows PuTTY shows ctermbg...

David Blume authored 6 years ago

88)     highlight ColorColumn ctermbg=233 guibg=Black " dark gray (or 17, dark blue)
David Blume first commit

David Blume authored 8 years ago

89)   endif
dblume Better statusline color.

dblume authored 2 years ago

90)   highlight StatusLine   ctermfg=24 ctermbg=LightGray  " override scheme
91)   highlight StatusLineNC ctermfg=236 ctermbg=Gray  " override scheme
92)   highlight MatchParen   term=reverse ctermbg=23  " 23 is more subtle than default
David Blume first commit

David Blume authored 8 years ago

93) endif
dblume Better statusline color.

dblume authored 2 years ago

94) 
95) " let g:loaded_airline = 1  " For testing the statusline settings above
David Blume first commit

David Blume authored 8 years ago

96) 
97) " set mouse=v     " visual mode, not working great for PuTTY
98) 
99) set tags=tags;/
100) 
101) set history=50
102) set ruler
103) if has('statusline')
104)   set laststatus=2
105)   set statusline=%<%f\   " Filename
106)   set statusline+=%w%h%m%r " Options
107)   "set statusline+=%{fugitive#statusline()} " Git
dblume Remove some lines, allow mo...

dblume authored 2 years ago

108)   set statusline+=\[%{&ff}/%Y]              " filetype
109)   set statusline+=%=%-12.(%l,%c%V%)\ %p%%   " Right aligned file nav info
David Blume first commit

David Blume authored 8 years ago

110) endif
111) 
112) set encoding=utf-8
113) 
dblume No comments after key mappi...

dblume authored 1 year ago

114) " Fast saving
115) nmap <leader>w :w!<cr>
David Blume first commit

David Blume authored 8 years ago

116) " I use relative number for cursor movement.
117) nmap <leader>r :set relativenumber!<cr>
118) nmap <leader>n :set number!<cr>
119) 
120) " Useful mappings for managing tabs
dblume Remove bad vim mappings for...

dblume authored 2 years ago

121) " Tab Previous: gT or C-PageUp
122) " Tab Next: gt or C-PageDown
David Blume first commit

David Blume authored 8 years ago

123) nmap <leader>tn :tabnew
124) nmap <leader>to :tabonly<cr>
125) nmap <leader>tc :tabclose<cr>
126) nmap <leader>tm :tabmove
dblume Add shortcuts for tab selec...

dblume authored 2 years ago

127) nmap <leader>1 1gt
128) nmap <leader>2 2gt
129) nmap <leader>3 3gt
130) nmap <leader>4 4gt
131) nmap <leader>5 5gt
132) nmap <leader>6 6gt
133) nmap <leader>7 7gt
134) nmap <leader>8 8gt
135) nmap <leader>9 9gt
dblume Use <leader>o OpenCurrentAs...

dblume authored 2 years ago

136) 
137) " Open current buffer in new tab. Close with C-w,c
138) " https://vim.fandom.com/wiki/Maximize_window_and_return_to_previous_split_structure
139) function! OpenCurrentAsNewTab()
dblume Restore entire window view...

dblume authored 2 years ago

140)     let l:currentView = winsaveview()
dblume Use <leader>o OpenCurrentAs...

dblume authored 2 years ago

141)     tabedit %
dblume Restore entire window view...

dblume authored 2 years ago

142)     call winrestview(l:currentView)
dblume Use <leader>o OpenCurrentAs...

dblume authored 2 years ago

143) endfunction
144) nmap <leader>o :call OpenCurrentAsNewTab()<CR>
David Blume first commit

David Blume authored 8 years ago

145) 
dblume Repeatedly call Blame to go...

dblume authored 1 year ago

146) " git blame, show, diff and log
dblume Add git blame, show commit,...

dblume authored 1 year ago

147) " Delete these functions when you install https://github.com/tpope/vim-fugitive
dblume Avoid duplicate buffer name...

dblume authored 1 year ago

148) 
149) "A helper function that tries to show a buffer if it already exists
150) function! ShowBufInNewTab(bufname)
151)    let l:bnr = bufnr(a:bufname)
152)    if l:bnr > 0
153)        tabnew
154)        exec 'buffer ' . l:bnr
155)        return 1
156)    endif
157)    return 0
158) endfunction
159) 
dblume Add git blame, show commit,...

dblume authored 1 year ago

160) function! GitBlame()
dblume Repeatedly call Blame to go...

dblume authored 1 year ago

161)     let l:hash = expand('<cword>')
dblume 'Blame' in vim restores you...

dblume authored 1 year ago

162)     let l:currentView = winsaveview()
dblume Avoid duplicate buffer name...

dblume authored 1 year ago

163)     " If in a Blame window already, do blame for some prior commit
dblume Harmonize Git in vim; If <c...

dblume authored 1 year ago

164)     if l:hash =~ '^[0-9a-f]\{7,40}$' && stridx(expand('%'), ' -- ') != -1
dblume Repeatedly call Blame to go...

dblume authored 1 year ago

165)         let l:fname = split(expand('%'), ' -- ')[-1]
dblume Avoid duplicate buffer name...

dblume authored 1 year ago

166)         let l:bufname = 'git blame ' . l:hash . '^ -- ' . l:fname
167)         if !ShowBufInNewTab(l:bufname)
168)             exec 'tabnew | r! git blame ' . l:hash . '^ -- ' . shellescape(l:fname)
dblume Use fnamescape (for raspber...

dblume authored 1 year ago

169)             exec 'silent :file ' . fnameescape(l:bufname)
dblume Avoid duplicate buffer name...

dblume authored 1 year ago

170)         endif
dblume Repeatedly call Blame to go...

dblume authored 1 year ago

171)     else
172)         let l:fname = expand('%')
dblume Avoid duplicate buffer name...

dblume authored 1 year ago

173)         let l:bufname = 'git blame -- ' . l:fname
174)         if !ShowBufInNewTab(l:bufname)
175)             exec 'tabnew | r! git blame -- ' . shellescape(l:fname)
dblume Use fnamescape (for raspber...

dblume authored 1 year ago

176)             exec 'silent :file ' . fnameescape(l:bufname)
dblume Avoid duplicate buffer name...

dblume authored 1 year ago

177)         endif
dblume Repeatedly call Blame to go...

dblume authored 1 year ago

178)     endif
179)     0d_
dblume 'Blame' in vim restores you...

dblume authored 1 year ago

180)     call winrestview(l:currentView)
dblume Add git blame, show commit,...

dblume authored 1 year ago

181)     setl buftype=nofile
182) endfunction
183) command Blame :call GitBlame()
184) 
dblume Add vim command ShowFile fo...

dblume authored 1 year ago

185) function! GitShow(commit_or_file)
dblume Harmonize Git in vim; If <c...

dblume authored 1 year ago

186)     let l:fname = expand('%')
dblume Add git blame, show commit,...

dblume authored 1 year ago

187)     let l:hash = expand('<cword>')
dblume Harmonize Git in vim; If <c...

dblume authored 1 year ago

188)     if l:hash =~ '^[0-9a-f]\{7,40}$'
189)         if stridx(l:fname, ' -- ') != -1
190)             let l:fname = split(l:fname, ' -- ')[-1]
dblume Whitespace fix

dblume authored 1 year ago

191)         endif
dblume Add vim command ShowFile fo...

dblume authored 1 year ago

192)         if a:commit_or_file != "file"
dblume Avoid duplicate buffer name...

dblume authored 1 year ago

193)             let l:bufname = 'git show ' . l:hash . ' -- ' . l:fname
194)             if !ShowBufInNewTab(l:bufname)
195)                 " Have Show show all the affected files, so don't actually use  "--"
196)                 " exec 'tabnew | r! git show ' . l:hash . ' -- ' . shellescape(l:fname)
197)                 exec 'tabnew | r! git show ' . l:hash
198)                 " We lie here (' -- ') to have a filename the other git commands can use.
dblume Use fnamescape (for raspber...

dblume authored 1 year ago

199)                 exec 'silent :file ' . fnameescape(l:bufname)
dblume Avoid duplicate buffer name...

dblume authored 1 year ago

200)             endif
dblume Add vim command ShowFile fo...

dblume authored 1 year ago

201)         else
dblume Avoid duplicate buffer name...

dblume authored 1 year ago

202)             let l:bufname = 'git show ' . l:hash . ':' . l:fname
203)             if !ShowBufInNewTab(l:bufname)
204)                 exec 'tabnew | r! git show ' . l:hash . ':' . shellescape(l:fname)
dblume Use fnamescape (for raspber...

dblume authored 1 year ago

205)                 exec 'silent :file ' . fnameescape(l:bufname)
dblume Avoid duplicate buffer name...

dblume authored 1 year ago

206)             endif
dblume Add vim command ShowFile fo...

dblume authored 1 year ago

207)         endif
dblume Repeatedly call Blame to go...

dblume authored 1 year ago

208)         setl buftype=nofile
209)         0d_
210)     else
211)         echo l:hash . ' is not a git hash.'
212)     endif
dblume Add git blame, show commit,...

dblume authored 1 year ago

213) endfunction
dblume Add vim command ShowFile fo...

dblume authored 1 year ago

214) command Show :call GitShow("commit")
215) command ShowFile :call GitShow("file")
dblume Add git blame, show commit,...

dblume authored 1 year ago

216) 
217) function! GitDiff()
dblume Better filename expansion f...

dblume authored 1 year ago

218)     let l:fname = expand('%:.')
dblume Add git blame, show commit,...

dblume authored 1 year ago

219)     let l:buf = winbufnr(0)
dblume Add git log to vim; make gi...

dblume authored 1 year ago

220)     let l:commit = 'HEAD'
dblume Harmonize Git in vim; If <c...

dblume authored 1 year ago

221)     let l:hash = expand('<cword>')
dblume Add git log to vim; make gi...

dblume authored 1 year ago

222) 
dblume Harmonize Git in vim; If <c...

dblume authored 1 year ago

223)     " If the current word is a hash, then diff that vs. previous
224)     if l:hash =~ '^[0-9a-f]\{7,40}$' && stridx(expand('%'), ' -- ') != -1
225)         let l:fname = split(expand('%'), ' -- ')[-1]
226)         exec ':tabnew | silent r! git show ' . l:hash . '^:$(git rev-parse --show-prefix)' . shellescape(l:fname)
227)         setl buftype=nofile
228)         0d_
dblume Add fnameescape() for Raspb...

dblume authored 1 year ago

229)         exec 'silent :file ' . fnameescape('git show '.l:hash .'^:'.l:fname)
dblume Add git log to vim; make gi...

dblume authored 1 year ago

230) 
dblume Harmonize Git in vim; If <c...

dblume authored 1 year ago

231)         exec 'vne | silent r! git show ' . l:hash . ':$(git rev-parse --show-prefix)' . shellescape(l:fname)
232)         setl buftype=nofile
dblume Add fnameescape() for Raspb...

dblume authored 1 year ago

233)         exec 'silent :file ' . fnameescape('git show '.l:hash.':'.l:fname)
dblume Harmonize Git in vim; If <c...

dblume authored 1 year ago

234)         0d_
235)     else
236)         " If the buffer is not different then repo, then diff HEAD vs file's previous commit
237)         let l:o = system("git status --porcelain | grep " . l:fname)
238)         if v:shell_error != 0
239)             let l:commit = system('git log -2 --pretty=format:"%h" -- ' . l:fname . ' | tail -n 1')
240)         endif
dblume Whitespace fix

dblume authored 1 year ago

241) 
dblume Harmonize Git in vim; If <c...

dblume authored 1 year ago

242)         " Bug if l:filename includes ".."
243)         exec ':tabnew | r! git show ' . l:commit . ':$(git rev-parse --show-prefix)' . l:fname
244)         setl buftype=nofile
245)         0d_
dblume Add fnameescape() for Raspb...

dblume authored 1 year ago

246)         exec 'silent :file ' . fnameescape('git show '.l:commit.':'.l:fname)
dblume Harmonize Git in vim; If <c...

dblume authored 1 year ago

247)         exec 'vert sb '.l:buf
248)     endif
dblume Add git blame, show commit,...

dblume authored 1 year ago

249)     windo diffthis
250)     setl buftype=nofile
251)     wincmd r
252)     wincmd l
253) endfunction
254) command Diff :call GitDiff()
dblume Add git Blame to vim; add g...

dblume authored 1 year ago

255) 
dblume Default log commands only s...

dblume authored 1 year ago

256) function! GitLog(flags)
dblume Harmonize Git in vim; If <c...

dblume authored 1 year ago

257)     let l:fname = expand('%')
dblume Log command should check fo...

dblume authored 1 year ago

258)     if stridx(l:fname, ' -- ') != -1
259)         let l:fname = split(l:fname, ' -- ')[-1]
260)     endif
dblume Default log commands only s...

dblume authored 1 year ago

261)     let l:bufname = 'git log ' . a:flags . '-- ' . l:fname
dblume Avoid duplicate buffer name...

dblume authored 1 year ago

262)     if !ShowBufInNewTab(l:bufname)
dblume Default log commands only s...

dblume authored 1 year ago

263)         exec 'tabnew | r! git log --no-color --graph --date=short ' . a:flags . '--pretty="format:\%h \%ad \%s \%an \%d" -- ' . shellescape(l:fname)
dblume Avoid duplicate buffer name...

dblume authored 1 year ago

264)         setl buftype=nofile
265)         0d_
dblume Use fnamescape (for raspber...

dblume authored 1 year ago

266)         exec 'silent :file ' . fnameescape(l:bufname)
dblume Avoid duplicate buffer name...

dblume authored 1 year ago

267)     endif
dblume Add git log to vim; make gi...

dblume authored 1 year ago

268) endfunction
dblume Default log commands only s...

dblume authored 1 year ago

269) command Logall :call GitLog('--all ')
270) command Log :call GitLog('')
dblume Add git log to vim; make gi...

dblume authored 1 year ago

271) 
David Blume first commit

David Blume authored 8 years ago

272) " pastetoggle
273) nmap <leader>p :set invpaste paste?<cr>
274) 
David Blume Add mapping to paste onto n...

David Blume authored 6 years ago

275) " Control+p to paste onto next line
276) nmap <C-p> :pu<cr>
277) 
David Blume Will use netrw's Explore in...

David Blume authored 3 years ago

278) " Make netrw's Explore behave a little like NERDTreeToggle
279) " http://vimcasts.org/blog/2013/01/oil-and-vinegar-split-windows-and-project-drawer/
David Blume Remove NERDTree and use net...

David Blume authored 4 years ago

280) function! ToggleNetrw()
David Blume Improve the toggling of the...

David Blume authored 3 years ago

281)   if bufwinnr("NetrwTreeListing") > 0
282)     for i in range(1, bufnr("$"))
283)       if (getbufvar(i, "&filetype") == "netrw")
David Blume Use netrw Vexplore to assur...

David Blume authored 3 years ago

284)         silent exe "bwipeout " . i
David Blume Improve the toggling of the...

David Blume authored 3 years ago

285)         return
286)       endif
287)     endfor
288)   endif
David Blume Use netrw Vexplore to assur...

David Blume authored 3 years ago

289)   silent Vexplore %:p:h
David Blume Remove NERDTree and use net...

David Blume authored 4 years ago

290) endfunction
291) nmap <leader>e :call ToggleNetrw()<cr>
292) 
dblume No comments after key mappi...

dblume authored 1 year ago

293) " install taglist
294) let Tlist_GainFocus_On_ToggleOpen = 1  " Jump to taglist window on open
295) let Tlist_Exit_OnlyWindow = 1          " if you are the last, kill yourself
296) let Tlist_Close_On_Select = 1          " Close taglist window on select
297) nmap <leader>l :TlistToggle<cr>
298) 
299) " install vim-bbye
300) nmap <leader>bd :Bdelete<cr>
David Blume first commit

David Blume authored 8 years ago

301) 
302) " Visual mode mappings
303) """
304) 
305) " map sort function to a key
306) vnoremap <leader>s :sort<cr>
307) 
308) "easier moving of code blocks
David Blume vimrc key remappings. jk as...

David Blume authored 6 years ago

309) vnoremap < <gv
310) vnoremap > >gv
David Blume first commit

David Blume authored 8 years ago

311) 
312) " If too many file system events are getting triggered.
313) set nobackup       " ~ files
314) set nowritebackup  " Don't write buff to temp, delete orig, rename temp to orig
315) set noswapfile     " .swp files
316) 
317) " Allow tags to open another buffer even if this one is modified
318) set hidden
319) 
320) " Switch between source and header files
321) function! SwitchSourceHeader()
322)   let s:ext  = expand("%:e")
323)   let s:base = expand("%:t:r")
324)   let s:cmd  = "find " . s:base
325)   if (s:ext == "cpp" || s:ext == "c")
326)     if findfile(s:base . ".h"  ) != "" | exe s:cmd . ".h"   | return | en
327)     if findfile(s:base . ".hpp") != "" | exe s:cmd . ".hpp" | return | en
328)   else
329)     if findfile(s:base . ".cpp") != "" | exe s:cmd . ".cpp" | return | en
330)     if findfile(s:base . ".c"  ) != "" | exe s:cmd . ".c"   | return | en
331)   endif
332) endfunc
333) 
334) " Demonstrates a way to look in a mirror directory
335) " function! OpenOther()
336) "    if expand("%:e") == "cpp"
337) "      exe "split" fnameescape(expand("%:p:r:s?src?include?").".h")
338) "    elseif expand("%:e") == "h"
339) "      exe "split" fnameescape(expand("%:p:r:s?include?src?").".cpp")
340) "    endif
341) " endfunc
342) 
343) " Delete trailing white space on save, useful for Python and CoffeeScript ;)
344) function! DeleteTrailingWS()
345)   exe "normal mz"
346)   %s/\s\+$//ge
347)   exe "normal `z"
348) endfunc
349) 
David Blume Add OpenInOtherWindow to .v...

David Blume authored 8 years ago

350) function! OpenInOtherWindow()
351)   if winnr('$') == 1
352)     exe "wincmd F"
353)   else
354)     let curNum = winnr()
355)     let oldBuf = bufnr( "%" )
356)     if curNum == 1
357)       let othNum = 2
358)     else
359)       let othNum = 1
360)     endif
361)     exe "normal! gF"
362)     let newBuf = bufnr( "%" )
363)     let newLine = line(".")
364)     exe 'hide buf' oldBuf
365)     exe othNum . "wincmd w"
366)     exe 'hide buf' newBuf
367)     exe "normal! " . newLine . "G"
368)   endif
369) endfunc
370) 
371) nmap <silent> <leader>F :call OpenInOtherWindow()<cr>
dblume Make OpenInOtherWindow easier.

dblume authored 2 years ago

372) nmap <silent> <leader>f :call OpenInOtherWindow()<cr>
David Blume Add OpenInOtherWindow to .v...

David Blume authored 8 years ago

373) 
David Blume first commit

David Blume authored 8 years ago

374) if has("autocmd")
375)   autocmd BufWrite *.py :call DeleteTrailingWS()  " Delete trailing whitespace
376)   " Don't let smartindent unindent the # character in Python files
377)   autocmd FileType python  inoremap # X<c-h>#
dblume Whitespace.

dblume authored 2 years ago

378)   autocmd FileType c,cpp,php,brs,sh  set expandtab  " Use spaces instead of tabs
David Blume first commit

David Blume authored 8 years ago

379)   autocmd Filetype make    setl noexpandtab       " ...not for files that use tabs.
380) 
381)   " Use the vim command %retab before applying the following
382)   " two with files that have 8-space tabs.
David Blume Add .vimrc tab values for ....

David Blume authored 8 years ago

383)   autocmd FileType c,cpp,python,php  set tabstop=4
dblume Remove some lines, allow mo...

dblume authored 2 years ago

384)   autocmd FileType c,cpp,php  set shiftwidth=4
David Blume first commit

David Blume authored 8 years ago

385) 
386)   autocmd FileType python  set foldmethod=indent  " 'za' to fold
387) 
David Blume Disable vim-airline whitesp...

David Blume authored 6 years ago

388)   autocmd FileType c,cpp nmap <buffer> <leader>s :call SwitchSourceHeader()<cr>
David Blume first commit

David Blume authored 8 years ago

389)   autocmd FileType c,cpp set foldmethod=syntax
390) 
dblume Change filetype from roku t...

dblume authored 1 year ago

391)   " autocmd FileType rokulog :let g:airline_extensions = []
392)   " autocmd FileType rokulog :let g:airline_section_warning = airline#section#create([])
393)   autocmd FileType rokulog :let g:airline#extensions#whitespace#enabled = 0
David Blume Disable vim-airline whitesp...

David Blume authored 6 years ago

394) 
David Blume first commit

David Blume authored 8 years ago

395)   if v:version >= 703
396)     " I toggle out of relative number when Vim's focus is lost, because
397)     " if I'm not editing, then I may be referring to errors with line numbers.
398)     autocmd FocusLost * if &relativenumber | set number | endif
399)     autocmd FocusGained * if &number | set relativenumber | endif
400)   endif
401) 
dblume Remove some lines, allow mo...

dblume authored 2 years ago

402)   autocmd BufRead *.txt set wrap linebreak   " "soft" wrap of existing lines
403)   autocmd BufRead README set wrap linebreak  " "soft" wrap of existing lines
dblume Add .local/bin to $PATH

dblume authored 1 year ago

404)   autocmd BufRead *.rs :setlocal tags=./rusty-tags.vi;/
David Blume first commit

David Blume authored 8 years ago

405) 
406)   " When editing a file, always jump to the last cursor position
407)   autocmd BufReadPost *
dblume Exempt gitcommit filetype f...

dblume authored 1 year ago

408)   \ if &ft != "p4changelist" && &ft != "gitcommit" && line("'\"") > 0 && line ("'\"") <= line("$") |
David Blume first commit

David Blume authored 8 years ago

409)   \   exe "normal! g'\"" |
410)   \ endif
411) endif
412) 
413) " This requires vim to be compiled with +python
414) " Use auto complete in insert mode with ctrl-x, ctrl-o
415) " See :help new-omni-completion for more.
416) filetype plugin on
417) set omnifunc=syntaxcomplete#Complete
dblume Completion tweaks

dblume authored 2 years ago

418) 
419) " Torn on whether I like the omni completion preview window left open or not.
420) " autocmd CompleteDone * pclose
421) 
422) " Omni completion via ctrl-space (in addition to ctrl-x ctrl-o)
423) inoremap <Nul> <C-x><C-o>
424) 
David Blume Add cscope support

David Blume authored 6 years ago

425) " cscope
426) if has("cscope")
427)     set cscopetag  " Use both cscope and ctag for 'ctrl-]'
David Blume I prefer ctags to be search...

David Blume authored 6 years ago

428)     set csto=1     " 0=cscope first; 1=ctags first
dblume Use QuickFix for cscope.

dblume authored 2 years ago

429)     set cscopequickfix=s-,c-,d-,i-,t-,e-,a- " cscope to quickfix window
430) 
David Blume Use local cscope.out databa...

David Blume authored 3 years ago

431)     set nocsverb
432)     " add any database in current directory
433)     if filereadable("cscope.out")
434)         cs add cscope.out
435)     " else add database pointed to by environment
436)     elseif $CSCOPE_DB != ""
437)         cs add $CSCOPE_DB
438)     endif
439)     set csverb
David Blume Add cscope support

David Blume authored 6 years ago

440) endif
441) 
David Blume Sort QuickFix tool by filen...

David Blume authored 3 years ago

442) " From https://stackoverflow.com/questions/15393301/how-to-automatically-sort-quickfix-entries-by-line-text-in-vim
443) " :grep term %
444) " :grep -r term path/
445) " :cw
446) " :ccl (or C-w,q)
dblume QuickFix window: only sort...

dblume authored 2 years ago

447) autocmd! QuickfixCmdPost * call MaybeSortQuickfix('QfStrCmp')
448) 
449) function! MaybeSortQuickfix(fn)
450) "    exe 'normal! '  " Doesn't work. Wanted to jump back to where we were.
451)     let t = getqflist({'title': 1}).title
dblume QuickFix sorts for 'vimgrep...

dblume authored 2 years ago

452)     " Only sort the files if for search-style commands, not "make".
dblume Follow up integrate ripgrep...

dblume authored 2 years ago

453)     if stridx(t, "cs ") == 0 || stridx(t, ":gr") == 0 || stridx(t, ":vim") == 0 || stridx(t, ":rg") == 0
dblume QuickFix window: only sort...

dblume authored 2 years ago

454)         call setqflist(sort(getqflist(), a:fn), 'r')
455)         call setqflist([], 'r', {'title': t})
456)     endif
457)     cwindow
David Blume Sort QuickFix tool by filen...

David Blume authored 3 years ago

458) endfunction
459) 
460) function! QfStrCmp(e1, e2)
461)     let [t1, t2] = [bufname(a:e1.bufnr), bufname(a:e2.bufnr)]
462)     return t1 <# t2 ? -1 : t1 ==# t2 ? 0 : 1
463) endfunction
464) 
dblume Integrate ripgrep into vim.

dblume authored 2 years ago

465) " Use ripgrep for search instead of grep
466) if executable('rg')
467)     " set grepprg=rg\ --vimgrep\ --hidden\ —glob '!.git'
468)     set grepprg=rg
469) endif
470) " Navigate quickfix list with ease
471) nnoremap <silent> [q :cprevious<CR>
472) nnoremap <silent> ]q :cnext<CR>
473) 
David Blume Add tip for using Roboto Mo...

David Blume authored 6 years ago

474) " I use Roboto Mono from https://github.com/powerline/fonts
David Blume Change from vim-powerline t...

David Blume authored 6 years ago

475) " On iTerm2, Preferences -> Profiles -> Text -> Font
David Blume Add tip for using Roboto Mo...

David Blume authored 6 years ago

476) " Cygwin64 won't let you choose it. Launch Cygwin64 as follows:
477) " C:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico -o Font="Roboto Mono for Powerline" -
David Blume Change from vim-powerline t...

David Blume authored 6 years ago

478) 
David Blume Remove NERDTree and use net...

David Blume authored 4 years ago

479) " Settings that make netrw more like NERDTree
480) let g:netrw_banner = 0
481) let g:netrw_liststyle = 3
David Blume Use netrw Vexplore to assur...

David Blume authored 3 years ago

482) let g:netrw_browse_split = 4
David Blume Remove NERDTree and use net...

David Blume authored 4 years ago

483) let g:netrw_altv = 1
David Blume Use netrw Vexplore to assur...

David Blume authored 3 years ago

484) " set g:netrw_winsize to negative for absolute width, positive for relative
485) let g:netrw_winsize = -36
486) " let g:netrw_winsize = 35
David Blume Remove NERDTree and use net...

David Blume authored 4 years ago

487) " sort is affecting only: directories on the top, files below
488) let g:netrw_sort_sequence = '[\/]$,*'
David Blume Change from vim-powerline t...

David Blume authored 6 years ago

489) 
490) " When using vim-airline
491) let g:airline_powerline_fonts = 1
David Blume Use vim-airline characters...

David Blume authored 4 years ago

492) if !exists('g:airline_symbols')
493)     let g:airline_symbols = {}
494) endif
495) let g:airline_symbols.whitespace = '✖'
496) let g:airline_symbols.linenr = 'Ξ'
David Blume Make vim easier to tweak wh...

David Blume authored 3 years ago

497) let g:airline_symbols.maxlinenr = ''
dblume Add better readonly char op...

dblume authored 2 years ago

498) " If using a powerline font, don't override .readonly. Otherwise pick one.
499) "let g:airline_symbols.readonly = '◆'
500) "let g:airline_symbols.readonly = '🔒'
David Blume Make vim easier to tweak wh...

David Blume authored 3 years ago

501) 
502) " If no "...for Powerline" font is available, uncomment these four:
David Blume tmux status line pane refin...

David Blume authored 3 years ago

503) let g:airline_left_sep = '▌'
504) let g:airline_right_sep = '▐'
505) let g:airline_left_alt_sep = '|'
506) let g:airline_right_alt_sep = '|'
David Blume Make vim easier to tweak wh...

David Blume authored 3 years ago

507) 
David Blume Change from vim-powerline t...

David Blume authored 6 years ago

508) let g:airline_theme = 'powerlineish'
David Blume Disable vim-airline wordcount.

David Blume authored 6 years ago

509) let g:airline#extensions#wordcount#enabled = 0
David Blume Disable vim-airline whitesp...

David Blume authored 6 years ago

510) " let g:airline_exclude_filetypes = []
dblume Added vim-rooter.

dblume authored 2 years ago

511) 
512) " Experimenting with vim-rooter
513) let g:rooter_patterns = ['.git', 'Makefile', 'builds/']
dblume Make vim-rooter manual.

dblume authored 2 years ago

514) let g:rooter_cd_cmd = 'lcd'
515) let g:rooter_manual_only = 1