94ed7ebe7b8bc250229dc19d7f2f1586d97ac796
dblume Soften the status line colo...

dblume authored 10 months ago

1) " Version 2024-03-17.1 - status line color tweak
David Blume 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
dblume Better fold settings for zA

dblume authored 1 year ago

9) set foldlevel=99
David Blume first commit

David Blume authored 9 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
dblume Starting trial with vim 'in...

dblume authored 1 year ago

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

dblume authored 11 months ago

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

dblume authored 10 months ago

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

dblume authored 10 months ago

16) set ttimeoutlen=100 " Affects Esc key, not leader.
dblume Decided I usually wanted ru...

dblume authored 2 months ago

17) set ruler           " Show cursor pos on right side of status bar
dblume Simplify vim titlestring: p...

dblume authored 9 months ago

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

dblume authored 9 months ago

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

David Blume authored 9 years ago

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

David Blume authored 6 years ago

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

dblume authored 2 years ago

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

dblume authored 9 months ago

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

David Blume authored 6 years ago

47) 
dblume Add easier window navigation.

dblume authored 2 years ago

48) " https://stevelosh.com/blog/2010/09/coming-home-to-vim/#s3-why-i-came-back-to-vim
49) nnoremap <leader>v <C-w>v<C-w>l
50) nnoremap <C-h> <C-w>h
51) nnoremap <C-j> <C-w>j
52) nnoremap <C-k> <C-w>k
53) nnoremap <C-l> <C-w>l
54) 
David Blume vimrc key remappings. jk as...

David Blume authored 6 years ago

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

David Blume authored 9 years ago

57) 
dblume Have terminal emulator send...

dblume authored 9 months ago

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

dblume authored 9 months ago

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

dblume authored 9 months ago

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

dblume authored 9 months ago

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

dblume authored 9 months ago

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

dblume authored 1 year ago

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

dblume authored 10 months ago

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

David Blume authored 9 years ago

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

dblume authored 10 months ago

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

David Blume authored 4 years ago

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

David Blume authored 9 years ago

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

David Blume authored 6 years ago

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

David Blume authored 9 years ago

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

dblume authored 10 months ago

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

dblume authored 9 months ago

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

dblume authored 10 months ago

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

dblume authored 2 years ago

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

David Blume authored 9 years ago

104) endif
dblume Better statusline color.

dblume authored 2 years ago

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

dblume authored 10 months ago

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

dblume authored 10 months ago

107) 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 1 year ago

108) 
dblume ghostty theme Monokai Pro S...

dblume authored 3 weeks ago

109) set mouse=nvi  " Matches neovim's default
dblume vim: Don't move cursor when...

dblume authored 5 days ago

110) 
111) " Don't move the cursor when activating window (incompatible on PuTTY)
112) augroup NO_CURSOR_MOVE_ON_FOCUS
113)   au!
114)   au FocusLost * let g:oldmouse=&mouse | set mouse=
115)   au FocusGained * if exists('g:oldmouse') | let &mouse=g:oldmouse | unlet g:oldmouse | endif
116) augroup END
117) 
dblume Set prev jump point on mous...

dblume authored 3 weeks ago

118) " Set jump point from before mouse click.
119) nnoremap <LeftMouse> m'<LeftMouse>
David Blume first commit

David Blume authored 9 years ago

120) 
121) set tags=tags;/
122) 
dblume Make vim StatuslineGit() re...

dblume authored 10 months ago

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

dblume authored 1 year ago

124) set laststatus=2
125) 
dblume Retrieve git branch only on...

dblume authored 10 months ago

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

dblume authored 10 months ago

127)   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 9 months ago

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

dblume authored 1 year ago

129) endfunction
130) 
dblume Only show encoding and form...

dblume authored 10 months ago

131) function! EncodingAndFormat()
132)   if (len(&fileencoding) && &fileencoding != 'utf-8') || &fileformat != 'unix'
133)     return &fileencoding?&fileencoding:&encoding .'['. &fileformat . '] │ '
134)   endif
135)   return ''
136) endfunction
137) 
dblume Make "set ruler!" change st...

dblume authored 10 months ago

138) function! OnRuler()
139)   if &ruler
140)     return '│ '.line('.').':'.col('.').' '
141)   endif
142)   return ''
143) endfunction
144) 
dblume Default to mode() if not in...

dblume authored 1 year ago

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

dblume authored 1 year ago

147)     \ 'n'  : 'NORMAL',
148)     \ 'v'  : 'VISUAL',
149)     \ 'V'  : 'V·LINE',
150)     \ '' : 'V·BLOCK',
151)     \ 's'  : 'SELECT',
152)     \ 'S'  : 'S·LINE',
153)     \ 'i'  : 'INSERT',
dblume Default to mode() if not in...

dblume authored 1 year ago

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

dblume authored 1 year ago

155)     \ 'R'  : 'REPLACE',
156)     \ 'Rv' : 'V·REPLACE',
157)     \ 'c'  : 'COMMAND',
158)     \}
dblume Default to mode() if not in...

dblume authored 1 year ago

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

dblume authored 1 year ago

161) 
162) function! Trim_brackets(fn)
dblume Support older vim on raspi

dblume authored 1 year ago

163)   if v:version > 800
164)     return trim(a:fn, "[]")
165)   else
166)     return a:fn
167)   endif
dblume Update vim statusline to pr...

dblume authored 1 year ago

168) endfunction
169) 
dblume Default to mode() if not in...

dblume authored 1 year ago

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

dblume authored 1 year ago

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

dblume authored 10 months ago

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

dblume authored 1 year ago

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

dblume authored 1 year ago

174) set statusline+=%m
175) set statusline+=\ %r
176) set statusline+=\ %=
dblume Update vim statusline to pr...

dblume authored 1 year ago

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

dblume authored 1 year ago

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

dblume authored 10 months ago

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

dblume authored 10 months ago

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

dblume authored 10 months ago

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

David Blume authored 9 years ago

184) 
185) set encoding=utf-8
186) 
dblume No comments after key mappi...

dblume authored 2 years ago

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

David Blume authored 9 years ago

189) " I use relative number for cursor movement.
190) nmap <leader>r :set relativenumber!<cr>
191) nmap <leader>n :set number!<cr>
192) 
193) " Useful mappings for managing tabs
dblume Remove bad vim mappings for...

dblume authored 2 years ago

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

David Blume authored 9 years ago

196) nmap <leader>tn :tabnew
197) nmap <leader>to :tabonly<cr>
198) nmap <leader>tc :tabclose<cr>
199) nmap <leader>tm :tabmove
dblume Add shortcuts for tab selec...

dblume authored 2 years ago

200) nmap <leader>1 1gt
201) nmap <leader>2 2gt
202) nmap <leader>3 3gt
203) nmap <leader>4 4gt
204) nmap <leader>5 5gt
205) nmap <leader>6 6gt
206) nmap <leader>7 7gt
207) nmap <leader>8 8gt
208) nmap <leader>9 9gt
dblume Use <leader>o OpenCurrentAs...

dblume authored 2 years ago

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

dblume authored 2 years ago

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

dblume authored 2 years ago

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

dblume authored 2 years ago

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

dblume authored 2 years ago

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

David Blume authored 9 years ago

218) 
219) " pastetoggle
220) nmap <leader>p :set invpaste paste?<cr>
221) 
David Blume Add mapping to paste onto n...

David Blume authored 6 years ago

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

David Blume authored 3 years ago

225) " Make netrw's Explore behave a little like NERDTreeToggle
226) " 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

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

David Blume authored 3 years ago

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

David Blume authored 3 years ago

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

David Blume authored 3 years ago

232)         return
233)       endif
234)     endfor
235)   endif
David Blume Use netrw Vexplore to assur...

David Blume authored 3 years ago

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

David Blume authored 4 years ago

237) endfunction
238) nmap <leader>e :call ToggleNetrw()<cr>
239) 
dblume No comments after key mappi...

dblume authored 2 years ago

240) " install taglist
241) let Tlist_GainFocus_On_ToggleOpen = 1  " Jump to taglist window on open
242) let Tlist_Exit_OnlyWindow = 1          " if you are the last, kill yourself
243) let Tlist_Close_On_Select = 1          " Close taglist window on select
dblume Update taglist to 4.6 in vi...

dblume authored 9 months ago

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

dblume authored 2 years ago

245) nmap <leader>l :TlistToggle<cr>
246) 
247) " install vim-bbye
248) nmap <leader>bd :Bdelete<cr>
David Blume first commit

David Blume authored 9 years ago

249) 
250) " Visual mode mappings
251) """
252) 
253) " map sort function to a key
254) vnoremap <leader>s :sort<cr>
255) 
256) "easier moving of code blocks
David Blume vimrc key remappings. jk as...

David Blume authored 6 years ago

257) vnoremap < <gv
258) vnoremap > >gv
David Blume first commit

David Blume authored 9 years ago

259) 
dblume Improve comment for visual-...

dblume authored 4 months ago

260) " Match Vim 8.2 and greater, where P does not yank to unnamed register
261) if v:version < 802
262)     vnoremap P "_dP
263) endif
dblume Vim to match nvim's visual P

dblume authored 4 months ago

264) 
David Blume first commit

David Blume authored 9 years ago

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

David Blume authored 8 years ago

303) function! OpenInOtherWindow()
304)   if winnr('$') == 1
305)     exe "wincmd F"
306)   else
307)     let curNum = winnr()
308)     let oldBuf = bufnr( "%" )
309)     if curNum == 1
310)       let othNum = 2
311)     else
312)       let othNum = 1
313)     endif
314)     exe "normal! gF"
315)     let newBuf = bufnr( "%" )
316)     let newLine = line(".")
317)     exe 'hide buf' oldBuf
318)     exe othNum . "wincmd w"
319)     exe 'hide buf' newBuf
320)     exe "normal! " . newLine . "G"
321)   endif
322) endfunc
323) 
324) nmap <silent> <leader>F :call OpenInOtherWindow()<cr>
dblume Make OpenInOtherWindow easier.

dblume authored 2 years ago

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

David Blume authored 8 years ago

326) 
David Blume first commit

David Blume authored 9 years ago

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

dblume authored 1 year ago

331)   autocmd FileType python,c,cpp,php,brs,sh  set expandtab  " Use spaces instead of tabs
dblume Make "-" a non-breaking cha...

dblume authored 3 months ago

332)   autocmd FileType make    setl noexpandtab                " ...not for files that use tabs.
333)   autocmd FileType markdown  set iskeyword+=-  " Add - to list of non-word-breaking chars.
David Blume first commit

David Blume authored 9 years ago

334) 
335)   " Use the vim command %retab before applying the following
336)   " two with files that have 8-space tabs.
David Blume Add .vimrc tab values for ....

David Blume authored 8 years ago

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

dblume authored 2 years ago

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

David Blume authored 9 years ago

339) 
340)   autocmd FileType python  set foldmethod=indent  " 'za' to fold
341) 
David Blume Disable vim-airline whitesp...

David Blume authored 6 years ago

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

David Blume authored 9 years ago

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

dblume authored 10 months ago

345) " https://jeffkreeftmeijer.com/vim-number/
dblume Decided I usually wanted ru...

dblume authored 2 months ago

346) " Disabling for now, just keep the mode that was explicitly requested.
347) "augroup numbertoggle
348) "  autocmd!
349) "  autocmd BufEnter,FocusGained,InsertLeave,WinEnter * if &nu && mode() != "i" | set rnu   | endif
350) "  autocmd BufLeave,FocusLost,InsertEnter,WinLeave   * if &nu                  | set nornu | endif
351) "augroup END
David Blume first commit

David Blume authored 9 years ago

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

dblume authored 2 years ago

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

dblume authored 2 years ago

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

David Blume authored 9 years ago

356) 
dblume Always start on first line...

dblume authored 10 months ago

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

David Blume authored 9 years ago

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

dblume authored 10 months ago

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

dblume authored 9 months ago

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

David Blume authored 9 years ago

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

dblume authored 10 months ago

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

dblume authored 10 months ago

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

dblume authored 10 months ago

364) 
dblume Only show encoding and form...

dblume authored 10 months ago

365)   autocmd BufNewFile,BufReadPost *
366)   \ let b:git_branch = GitBranch() |
367)   \ let b:enc_fmt = EncodingAndFormat()
368)   autocmd BufEnter *
369)   \ let b:git_branch = GitBranch() |
370)   \ let b:enc_fmt = EncodingAndFormat()
David Blume first commit

David Blume authored 9 years ago

371) endif
372) 
373) " This requires vim to be compiled with +python
374) " Use auto complete in insert mode with ctrl-x, ctrl-o
375) " See :help new-omni-completion for more.
376) filetype plugin on
377) set omnifunc=syntaxcomplete#Complete
dblume Completion tweaks

dblume authored 2 years ago

378) 
379) " Torn on whether I like the omni completion preview window left open or not.
380) " autocmd CompleteDone * pclose
381) 
382) " Omni completion via ctrl-space (in addition to ctrl-x ctrl-o)
383) inoremap <Nul> <C-x><C-o>
384) 
dblume Add commands SynStack and H...

dblume authored 9 months ago

385) " These two commands display syntax/highlight info for what's under the cursor.
386) if exists(":SynStack") != 2
387)     command SynStack :echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
388) endif
389) 
390) function! SynGroup()
391)     let l:s = synID(line('.'), col('.'), 1)
392)     echo synIDattr(l:s, 'name') . ' -> ' . synIDattr(synIDtrans(l:s), 'name')
393) endfun
394) command Hi :call SynGroup()
395) 
David Blume Add cscope support

David Blume authored 7 years ago

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

David Blume authored 7 years ago

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

dblume authored 2 years ago

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

David Blume authored 3 years ago

402)     set nocsverb
403)     " add any database in current directory
404)     if filereadable("cscope.out")
405)         cs add cscope.out
406)     " else add database pointed to by environment
407)     elseif $CSCOPE_DB != ""
408)         cs add $CSCOPE_DB
409)     endif
410)     set csverb
David Blume Add cscope support

David Blume authored 7 years ago

411) endif
412) 
David Blume Sort QuickFix tool by filen...

David Blume authored 3 years ago

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

dblume authored 2 years ago

418) autocmd! QuickfixCmdPost * call MaybeSortQuickfix('QfStrCmp')
419) 
420) function! MaybeSortQuickfix(fn)
421) "    exe 'normal! '  " Doesn't work. Wanted to jump back to where we were.
422)     let t = getqflist({'title': 1}).title
dblume QuickFix sorts for 'vimgrep...

dblume authored 2 years ago

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

dblume authored 2 years ago

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

425)         call setqflist(sort(getqflist(), a:fn), 'r')
426)         call setqflist([], 'r', {'title': t})
427)     endif
428)     cwindow
David Blume Sort QuickFix tool by filen...

David Blume authored 3 years ago

429) endfunction
430) 
431) function! QfStrCmp(e1, e2)
432)     let [t1, t2] = [bufname(a:e1.bufnr), bufname(a:e2.bufnr)]
433)     return t1 <# t2 ? -1 : t1 ==# t2 ? 0 : 1
434) endfunction
435) 
dblume Integrate ripgrep into vim.

dblume authored 2 years ago

436) " Use ripgrep for search instead of grep
437) if executable('rg')
438)     " set grepprg=rg\ --vimgrep\ --hidden\ —glob '!.git'
439)     set grepprg=rg
440) endif
441) " Navigate quickfix list with ease
442) nnoremap <silent> [q :cprevious<CR>
443) nnoremap <silent> ]q :cnext<CR>
444) 
dblume Add DiffOrig from the vim h...

dblume authored 10 months ago

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

dblume authored 10 months ago

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

dblume authored 10 months ago

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

dblume authored 10 months ago

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

dblume authored 10 months ago

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

David Blume authored 6 years ago

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

David Blume authored 6 years ago

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

David Blume authored 6 years ago

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

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

David Blume authored 4 years ago

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

David Blume authored 3 years ago

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

David Blume authored 4 years ago

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

David Blume authored 3 years ago

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

David Blume authored 4 years ago

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

David Blume authored 6 years ago

466) 
dblume Added vim-rooter.

dblume authored 2 years ago

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

dblume authored 2 years ago

469) let g:rooter_cd_cmd = 'lcd'
470) let g:rooter_manual_only = 1
dblume Better filename expansion f...

dblume authored 1 year ago

471) 
dblume Move nvim rainbow plugin in...

dblume authored 8 months ago

472) " 'Rainbow Parentheses Improved' https://github.com/luochen1990/rainbow/
dblume Exclude filetype rokulog fr...

dblume authored 7 months ago

473) let g:rainbow_conf = {
474) \   'ctermfgs': ['223', 'lightblue', '180', 'green', 'yellow', '111'],
475) \   'separately': { 'rokulog': 0 }
476) \ }
dblume Add "rainbow" plugin for co...

dblume authored 8 months ago

477) let g:rainbow_active = 1 "set to 0 if you want to enable it later via :RainbowToggle
478)