138fc9e14cc949565f5a5046f87c82c45cab9213
dblume Soften the status line colo...

dblume authored 2 months ago

1) " Version 2024-03-17.1 - status line color tweak
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 1 year ago

12) set listchars+=tab:>-,precedes:<,extends:>,nbsp:· " for :set list
dblume Add - as a word character

dblume authored 5 months ago

13) set iskeyword+=-    " Add - to list of non-word-breaking chars.
dblume Starting trial with vim 'in...

dblume authored 4 months ago

14) set incsearch       " Navigate to matched strings while typing. Toggle: :set is!
dblume Set scrolloff to 0, EC2 def...

dblume authored 2 months ago

15) set scrolloff=0     " EC2 defaults to 5. Set explicitly to be consistent
dblume Vim to delete comment char...

dblume authored 1 month ago

16) set formatoptions+=j " Delete comment character when joining commented lines.
dblume Improve Esc key reaction, f...

dblume authored 1 month ago

17) set ttimeoutlen=100 " Affects Esc key, not leader.
dblume .vimrc needs explicit "noru...

dblume authored 1 month ago

18) set noruler         " Don't show cursor pos on right side of status bar
dblume Simplify vim titlestring: p...

dblume authored 2 weeks ago

19) " Set the title of the terminal window. Consider changing titlestring, %t, %M
20) set title titlestring=%f%m\ -\ vim
dblume Don't use unnamed register...

dblume authored 2 weeks ago

21) 
22) " Yank and put into the system Clipboard (register + or *)
23) " Otherwise make explicit commands "+yy "+y "+Y (or * instead of + as needed)
24) " N.B. Don't use unnamed register for clipboard (set clipboard=unnamed)
25) "      Delete operations would overwrite clipboard before pasting.
26) nnoremap <leader>c "+
27) vnoremap <leader>c "+
David Blume first commit

David Blume authored 8 years ago

28) 
29) if v:version >= 703
30)   " Do save the undo tree to file, but not in the local directory.
31)   " Don't forget to mkdir ~/.vim_undo
32)   set undodir=~/.vim_undo,.
33)   set undofile        " undo even after closing and reopening a file
34) endif
35) 
David Blume vimrc key remappings. jk as...

David Blume authored 6 years ago

36) " Make j and k move to the next row, not file line
37) nnoremap j gj
38) nnoremap k gk
39) 
40) " From Steve Losh: http://learnvimscriptthehardway.stevelosh.com/chapters/10.html
dblume Use j and k for navigating...

dblume authored 1 year ago

41) " Map jk to ESC in insert mode (except when navigating popup menu)
42) inoremap <expr> jk pumvisible() ? '' : '<esc>'
43) inoremap <expr> j pumvisible() ? '<Down>' : 'j'
44) inoremap <expr> k pumvisible() ? '<Up>' : 'k'
dblume Map Tab and CR to pull-up-m...

dblume authored 1 month ago

45) inoremap <expr> <Tab> pumvisible() ? '<Down>' : '<Tab>'
46) inoremap <expr> <S-Tab> pumvisible() ? '<Up>' : '<S-Tab>'
47) inoremap <expr> <cr> pumvisible() ? '<C-y>' : '<cr>'
David Blume vimrc key remappings. jk as...

David Blume authored 6 years ago

48) 
dblume Add easier window navigation.

dblume authored 2 years ago

49) " https://stevelosh.com/blog/2010/09/coming-home-to-vim/#s3-why-i-came-back-to-vim
50) nnoremap <leader>v <C-w>v<C-w>l
51) nnoremap <C-h> <C-w>h
52) nnoremap <C-j> <C-w>j
53) nnoremap <C-k> <C-w>k
54) nnoremap <C-l> <C-w>l
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 Have terminal emulator send...

dblume authored 2 weeks ago

59) " tmux 3.2+ doesn't send C-i, so have Alacritty iTerm2 map C-i to <leader>i
60) " iTerm2: Settings > Keys > Key Bindings > + > Shortcut:^i Action:Send Text "\i"
61) nnoremap <leader>i <C-i>
62) " Use (Shift-)Tab to navigate buffers, retain C-i/C-o for jumps.
dblume bash PROMPT_COMMAND to set...

dblume authored 2 weeks ago

63) " Test with this:
dblume typo: .vimrc to use vim, no...

dblume authored 2 weeks ago

64) " vim -Nu NONE +'nno <C-i> :echom "C-i pressed"<cr>' +'nno <tab> :echom "Tab pressed"<cr>'
dblume Have terminal emulator send...

dblume authored 2 weeks ago

65) "if stridx(expand($TERM), 'xterm') == 0
66)   nnoremap <C-i> <C-i>
67)   nmap <Tab> :bn<cr>
68) "endif
dblume Restore Ctrl-i (Tab) to mea...

dblume authored 4 weeks ago

69) nnoremap <S-Tab> :bp<cr>
dblume tab key navigation of buffers

dblume authored 1 year ago

70) 
dblume Remap Y to yank to end of l...

dblume authored 2 months ago

71) " Use yy to yank a whole line, use Y to yank to end of line like C and D
72) nnoremap Y y$
73) 
David Blume first commit

David Blume authored 8 years ago

74) syntax on
75) 
76) set t_Co=256
77) if v:version >= 703
78)   set colorcolumn=80
79) endif
80) if has('gui_running') " Didn't work: if &term != 'builtin_gui'
81)   " Light backgrounds for GUI experiences
82)   set background=light
83)   " colorscheme peaksea                        " install peaksea
84)   colorscheme tolerable                        " install tolerable
85)   if v:version >= 703
86)     highlight ColorColumn ctermbg=255 guibg=#F6F6F6
87)   endif
dblume nvim ColorColumn was inverted

dblume authored 2 months ago

88)   highlight statusline   ctermfg=17 ctermbg=Gray  " override scheme
89)   highlight statuslineNC ctermfg=20 ctermbg=LightGray  " override scheme
David Blume Specify a font for gvim on...

David Blume authored 3 years ago

90)   if has('win32')
91)     set guifont=DejaVu_Sans_Mono_for_Powerline:h10:cANSI:qDRAFT
92)   endif
David Blume first commit

David Blume authored 8 years ago

93)   set lines=50 columns=100
94) else
95)   " Dark backgrounds for tty experiences
96)   set background=dark
97)   colorscheme desert                           " install desert
98)   if v:version >= 703
David Blume Windows PuTTY shows ctermbg...

David Blume authored 5 years ago

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

David Blume authored 8 years ago

100)   endif
dblume Make the normal statusbar m...

dblume authored 1 month ago

101)   highlight statusline   ctermfg=23 ctermbg=250  " override scheme
dblume Change hightlight of curren...

dblume authored 1 month ago

102) "  highlight User1        ctermfg=250 ctermbg=30
dblume Soften the status line colo...

dblume authored 2 months ago

103)   highlight statuslineNC ctermfg=237 ctermbg=Gray  " override scheme
dblume Better statusline color.

dblume authored 2 years ago

104)   highlight MatchParen   term=reverse ctermbg=23  " 23 is more subtle than default
David Blume first commit

David Blume authored 8 years ago

105) endif
dblume Better statusline color.

dblume authored 2 years ago

106) 
dblume Vim insert mode's blue shou...

dblume authored 1 month ago

107) au InsertEnter * hi statusline guibg=Cyan ctermfg=25 guifg=Black ctermbg=248
dblume Make the normal statusbar m...

dblume authored 1 month ago

108) au InsertLeave * hi statusline term=bold,reverse cterm=bold,reverse ctermfg=23 ctermbg=250 guifg=black guibg=#c2bfa5
dblume Maybe I like these statusli...

dblume authored 6 months ago

109) 
David Blume first commit

David Blume authored 8 years ago

110) " set mouse=v     " visual mode, not working great for PuTTY
111) 
112) set tags=tags;/
113) 
dblume Make vim StatuslineGit() re...

dblume authored 2 months ago

114) set history=500
dblume Update vim statusline to pr...

dblume authored 6 months ago

115) set laststatus=2
116) 
dblume Retrieve git branch only on...

dblume authored 2 months ago

117) function! GitBranch()
dblume Make vim StatuslineGit() re...

dblume authored 2 months ago

118)   let l:branchname = system("git -C " . expand('%:p:h') . " rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'")
dblume vim to use the "git branch"...

dblume authored 1 month ago

119)   return strlen(l:branchname) > 0 ? '  │  '.l:branchname : ''
dblume Update vim statusline to pr...

dblume authored 6 months ago

120) endfunction
121) 
dblume Only show encoding and form...

dblume authored 1 month ago

122) function! EncodingAndFormat()
123)   if (len(&fileencoding) && &fileencoding != 'utf-8') || &fileformat != 'unix'
124)     return &fileencoding?&fileencoding:&encoding .'['. &fileformat . '] │ '
125)   endif
126)   return ''
127) endfunction
128) 
dblume Make "set ruler!" change st...

dblume authored 1 month ago

129) function! OnRuler()
130)   if &ruler
131)     return '│ '.line('.').':'.col('.').' '
132)   endif
133)   return ''
134) endfunction
135) 
dblume Default to mode() if not in...

dblume authored 5 months ago

136) function! Current_mode()
137)   let l:currentmode={
dblume Update vim statusline to pr...

dblume authored 6 months ago

138)     \ 'n'  : 'NORMAL',
139)     \ 'v'  : 'VISUAL',
140)     \ 'V'  : 'V·LINE',
141)     \ '' : 'V·BLOCK',
142)     \ 's'  : 'SELECT',
143)     \ 'S'  : 'S·LINE',
144)     \ 'i'  : 'INSERT',
dblume Default to mode() if not in...

dblume authored 5 months ago

145)     \ 'r'  : 'I·REPLACE',
dblume Update vim statusline to pr...

dblume authored 6 months ago

146)     \ 'R'  : 'REPLACE',
147)     \ 'Rv' : 'V·REPLACE',
148)     \ 'c'  : 'COMMAND',
149)     \}
dblume Default to mode() if not in...

dblume authored 5 months ago

150)     return get(l:currentmode, mode(), mode())
151) endfunction
dblume Update vim statusline to pr...

dblume authored 6 months ago

152) 
153) function! Trim_brackets(fn)
dblume Support older vim on raspi

dblume authored 6 months ago

154)   if v:version > 800
155)     return trim(a:fn, "[]")
156)   else
157)     return a:fn
158)   endif
dblume Update vim statusline to pr...

dblume authored 6 months ago

159) endfunction
160) 
dblume Default to mode() if not in...

dblume authored 5 months ago

161) set statusline=\ %{Current_mode()}
dblume Update vim statusline to pr...

dblume authored 6 months ago

162) set statusline+=%{&paste?'\ \ ·\ PASTE':''}
dblume Retrieve git branch only on...

dblume authored 2 months ago

163) set statusline+=%{b:git_branch}
dblume vimrc use box drawing vertical

dblume authored 4 months ago

164) set statusline+=\ │\ %f
dblume Default to mode() if not in...

dblume authored 5 months ago

165) set statusline+=%m
166) set statusline+=\ %r
167) set statusline+=\ %=
dblume Update vim statusline to pr...

dblume authored 6 months ago

168) set statusline+=%h
dblume Default to mode() if not in...

dblume authored 5 months ago

169) set statusline+=\ %{Trim_brackets(&filetype)}
170) set statusline+=\ %#StatusLineNC#
dblume Only show encoding and form...

dblume authored 1 month ago

171) set statusline+=\ %{b:enc_fmt}
172) set statusline+=%p%%\ of
dblume Drop column and line number...

dblume authored 1 month ago

173) set statusline+=\ %L\ 
dblume Make "set ruler!" change st...

dblume authored 1 month ago

174) set statusline+=%{OnRuler()}
David Blume first commit

David Blume authored 8 years ago

175) 
176) set encoding=utf-8
177) 
dblume No comments after key mappi...

dblume authored 1 year ago

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

David Blume authored 8 years ago

180) " I use relative number for cursor movement.
181) nmap <leader>r :set relativenumber!<cr>
182) nmap <leader>n :set number!<cr>
183) 
184) " Useful mappings for managing tabs
dblume Remove bad vim mappings for...

dblume authored 1 year ago

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

David Blume authored 8 years ago

187) nmap <leader>tn :tabnew
188) nmap <leader>to :tabonly<cr>
189) nmap <leader>tc :tabclose<cr>
190) nmap <leader>tm :tabmove
dblume Add shortcuts for tab selec...

dblume authored 1 year ago

191) nmap <leader>1 1gt
192) nmap <leader>2 2gt
193) nmap <leader>3 3gt
194) nmap <leader>4 4gt
195) nmap <leader>5 5gt
196) nmap <leader>6 6gt
197) nmap <leader>7 7gt
198) nmap <leader>8 8gt
199) nmap <leader>9 9gt
dblume Use <leader>o OpenCurrentAs...

dblume authored 2 years ago

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

dblume authored 2 years ago

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

dblume authored 2 years ago

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

dblume authored 2 years ago

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

dblume authored 2 years ago

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

David Blume authored 8 years ago

209) 
210) " pastetoggle
211) nmap <leader>p :set invpaste paste?<cr>
212) 
David Blume Add mapping to paste onto n...

David Blume authored 5 years ago

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

David Blume authored 3 years ago

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

David Blume authored 3 years ago

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

David Blume authored 3 years ago

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

David Blume authored 3 years ago

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

David Blume authored 3 years ago

223)         return
224)       endif
225)     endfor
226)   endif
David Blume Use netrw Vexplore to assur...

David Blume authored 3 years ago

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

David Blume authored 3 years ago

228) endfunction
229) nmap <leader>e :call ToggleNetrw()<cr>
230) 
dblume No comments after key mappi...

dblume authored 1 year ago

231) " install taglist
232) let Tlist_GainFocus_On_ToggleOpen = 1  " Jump to taglist window on open
233) let Tlist_Exit_OnlyWindow = 1          " if you are the last, kill yourself
234) let Tlist_Close_On_Select = 1          " Close taglist window on select
dblume Update taglist to 4.6 in vi...

dblume authored 1 month ago

235) let Tlist_Inc_Winwidth = 0             " Only needed for neovim in tmux
dblume No comments after key mappi...

dblume authored 1 year ago

236) nmap <leader>l :TlistToggle<cr>
237) 
238) " install vim-bbye
239) nmap <leader>bd :Bdelete<cr>
David Blume first commit

David Blume authored 8 years ago

240) 
241) " Visual mode mappings
242) """
243) 
244) " map sort function to a key
245) vnoremap <leader>s :sort<cr>
246) 
247) "easier moving of code blocks
David Blume vimrc key remappings. jk as...

David Blume authored 6 years ago

248) vnoremap < <gv
249) vnoremap > >gv
David Blume first commit

David Blume authored 8 years ago

250) 
251) " If too many file system events are getting triggered.
252) set nobackup       " ~ files
253) set nowritebackup  " Don't write buff to temp, delete orig, rename temp to orig
254) set noswapfile     " .swp files
255) 
256) " Allow tags to open another buffer even if this one is modified
257) set hidden
258) 
259) " Switch between source and header files
260) function! SwitchSourceHeader()
261)   let s:ext  = expand("%:e")
262)   let s:base = expand("%:t:r")
263)   let s:cmd  = "find " . s:base
264)   if (s:ext == "cpp" || s:ext == "c")
265)     if findfile(s:base . ".h"  ) != "" | exe s:cmd . ".h"   | return | en
266)     if findfile(s:base . ".hpp") != "" | exe s:cmd . ".hpp" | return | en
267)   else
268)     if findfile(s:base . ".cpp") != "" | exe s:cmd . ".cpp" | return | en
269)     if findfile(s:base . ".c"  ) != "" | exe s:cmd . ".c"   | return | en
270)   endif
271) endfunc
272) 
273) " Demonstrates a way to look in a mirror directory
274) " function! OpenOther()
275) "    if expand("%:e") == "cpp"
276) "      exe "split" fnameescape(expand("%:p:r:s?src?include?").".h")
277) "    elseif expand("%:e") == "h"
278) "      exe "split" fnameescape(expand("%:p:r:s?include?src?").".cpp")
279) "    endif
280) " endfunc
281) 
282) " Delete trailing white space on save, useful for Python and CoffeeScript ;)
283) function! DeleteTrailingWS()
284)   exe "normal mz"
285)   %s/\s\+$//ge
286)   exe "normal `z"
287) endfunc
288) 
David Blume Add OpenInOtherWindow to .v...

David Blume authored 8 years ago

289) function! OpenInOtherWindow()
290)   if winnr('$') == 1
291)     exe "wincmd F"
292)   else
293)     let curNum = winnr()
294)     let oldBuf = bufnr( "%" )
295)     if curNum == 1
296)       let othNum = 2
297)     else
298)       let othNum = 1
299)     endif
300)     exe "normal! gF"
301)     let newBuf = bufnr( "%" )
302)     let newLine = line(".")
303)     exe 'hide buf' oldBuf
304)     exe othNum . "wincmd w"
305)     exe 'hide buf' newBuf
306)     exe "normal! " . newLine . "G"
307)   endif
308) endfunc
309) 
310) nmap <silent> <leader>F :call OpenInOtherWindow()<cr>
dblume Make OpenInOtherWindow easier.

dblume authored 2 years ago

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

David Blume authored 8 years ago

312) 
David Blume first commit

David Blume authored 8 years ago

313) if has("autocmd")
314)   autocmd BufWrite *.py :call DeleteTrailingWS()  " Delete trailing whitespace
315)   " Don't let smartindent unindent the # character in Python files
316)   autocmd FileType python  inoremap # X<c-h>#
dblume expand tabs for Python

dblume authored 8 months ago

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

David Blume authored 8 years ago

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

David Blume authored 7 years ago

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

dblume authored 2 years ago

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

David Blume authored 8 years ago

324) 
325)   autocmd FileType python  set foldmethod=indent  " 'za' to fold
326) 
David Blume Disable vim-airline whitesp...

David Blume authored 6 years ago

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

David Blume authored 8 years ago

328)   autocmd FileType c,cpp set foldmethod=syntax
329) 
dblume Improve focus-based switchi...

dblume authored 1 month ago

330) " https://jeffkreeftmeijer.com/vim-number/
331) augroup numbertoggle
332)   autocmd!
333)   autocmd BufEnter,FocusGained,InsertLeave,WinEnter * if &nu && mode() != "i" | set rnu   | endif
334)   autocmd BufLeave,FocusLost,InsertEnter,WinLeave   * if &nu                  | set nornu | endif
335) augroup END
David Blume first commit

David Blume authored 8 years ago

336) 
dblume Remove some lines, allow mo...

dblume authored 2 years ago

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

dblume authored 1 year ago

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

David Blume authored 8 years ago

340) 
dblume Always start on first line...

dblume authored 2 months ago

341)   " When editing a file, always jump to the last cursor position...
David Blume first commit

David Blume authored 8 years ago

342)   autocmd BufReadPost *
dblume Improve Esc key reaction, f...

dblume authored 1 month ago

343)   \ if &ft != "gitcommit" && line("'\"") > 0 && line ("'\"") <= line("$") |
dblume When openging files jump to...

dblume authored 2 weeks ago

344)   \   exe "normal! g`\"" |
David Blume first commit

David Blume authored 8 years ago

345)   \ endif
dblume Improve Esc key reaction, f...

dblume authored 1 month ago

346)   " ...except for gitcommit where we always want to start at the top (nvim)
dblume Always start on first line...

dblume authored 2 months ago

347)   autocmd FileType gitcommit exe "normal! gg"
dblume Retrieve git branch only on...

dblume authored 2 months ago

348) 
dblume Only show encoding and form...

dblume authored 1 month ago

349)   autocmd BufNewFile,BufReadPost *
350)   \ let b:git_branch = GitBranch() |
351)   \ let b:enc_fmt = EncodingAndFormat()
352)   autocmd BufEnter *
353)   \ let b:git_branch = GitBranch() |
354)   \ let b:enc_fmt = EncodingAndFormat()
David Blume first commit

David Blume authored 8 years ago

355) endif
356) 
357) " This requires vim to be compiled with +python
358) " Use auto complete in insert mode with ctrl-x, ctrl-o
359) " See :help new-omni-completion for more.
360) filetype plugin on
361) set omnifunc=syntaxcomplete#Complete
dblume Completion tweaks

dblume authored 1 year ago

362) 
363) " Torn on whether I like the omni completion preview window left open or not.
364) " autocmd CompleteDone * pclose
365) 
366) " Omni completion via ctrl-space (in addition to ctrl-x ctrl-o)
367) inoremap <Nul> <C-x><C-o>
368) 
dblume Add commands SynStack and H...

dblume authored 1 month ago

369) " These two commands display syntax/highlight info for what's under the cursor.
370) if exists(":SynStack") != 2
371)     command SynStack :echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
372) endif
373) 
374) function! SynGroup()
375)     let l:s = synID(line('.'), col('.'), 1)
376)     echo synIDattr(l:s, 'name') . ' -> ' . synIDattr(synIDtrans(l:s), 'name')
377) endfun
378) command Hi :call SynGroup()
379) 
David Blume Add cscope support

David Blume authored 6 years ago

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

David Blume authored 6 years ago

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

dblume authored 2 years ago

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

David Blume authored 3 years ago

386)     set nocsverb
387)     " add any database in current directory
388)     if filereadable("cscope.out")
389)         cs add cscope.out
390)     " else add database pointed to by environment
391)     elseif $CSCOPE_DB != ""
392)         cs add $CSCOPE_DB
393)     endif
394)     set csverb
David Blume Add cscope support

David Blume authored 6 years ago

395) endif
396) 
David Blume Sort QuickFix tool by filen...

David Blume authored 2 years ago

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

dblume authored 2 years ago

402) autocmd! QuickfixCmdPost * call MaybeSortQuickfix('QfStrCmp')
403) 
404) function! MaybeSortQuickfix(fn)
405) "    exe 'normal! '  " Doesn't work. Wanted to jump back to where we were.
406)     let t = getqflist({'title': 1}).title
dblume QuickFix sorts for 'vimgrep...

dblume authored 2 years ago

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

dblume authored 2 years ago

408)     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

409)         call setqflist(sort(getqflist(), a:fn), 'r')
410)         call setqflist([], 'r', {'title': t})
411)     endif
412)     cwindow
David Blume Sort QuickFix tool by filen...

David Blume authored 2 years ago

413) endfunction
414) 
415) function! QfStrCmp(e1, e2)
416)     let [t1, t2] = [bufname(a:e1.bufnr), bufname(a:e2.bufnr)]
417)     return t1 <# t2 ? -1 : t1 ==# t2 ? 0 : 1
418) endfunction
419) 
dblume Integrate ripgrep into vim.

dblume authored 2 years ago

420) " Use ripgrep for search instead of grep
421) if executable('rg')
422)     " set grepprg=rg\ --vimgrep\ --hidden\ —glob '!.git'
423)     set grepprg=rg
424) endif
425) " Navigate quickfix list with ease
426) nnoremap <silent> [q :cprevious<CR>
427) nnoremap <silent> ]q :cnext<CR>
428) 
dblume Add DiffOrig from the vim h...

dblume authored 1 month ago

429) " From `:help :DiffOrig`.
dblume Make "set ruler!" change st...

dblume authored 1 month ago

430) if exists(":DiffOrig") != 2
431)   command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_
dblume Add DiffOrig from the vim h...

dblume authored 1 month ago

432)     \ | diffthis | wincmd p | diffthis
dblume Make "set ruler!" change st...

dblume authored 1 month ago

433) endif
dblume Add DiffOrig from the vim h...

dblume authored 1 month ago

434) 
David Blume Add tip for using Roboto Mo...

David Blume authored 6 years ago

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

David Blume authored 6 years ago

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

David Blume authored 6 years ago

437) " Cygwin64 won't let you choose it. Launch Cygwin64 as follows:
438) " 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

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

David Blume authored 3 years ago

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

David Blume authored 3 years ago

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

David Blume authored 3 years ago

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

David Blume authored 3 years ago

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

David Blume authored 3 years ago

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

David Blume authored 6 years ago

450) 
dblume Added vim-rooter.

dblume authored 1 year ago

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

dblume authored 1 year ago

453) let g:rooter_cd_cmd = 'lcd'
454) let g:rooter_manual_only = 1