Guest User

Untitled

a guest
Jan 18th, 2026
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.26 KB | None | 0 0
  1. colorscheme koehler
  2. syntax on
  3. set nowrap
  4. set tabstop=2
  5. set expandtab
  6. set shiftwidth=2
  7. set smartindent
  8. set noswapfile
  9.  
  10. set undodir=~/.vimdir/undodir
  11. set undofile
  12. set history=9999
  13. set hidden
  14.  
  15. " Put plugins and dictionaries in this dir (also on Windows)
  16. let vimDir = '$HOME/.vim'
  17.  
  18. if stridx(&runtimepath, expand(vimDir)) == -1
  19. " vimDir is not on runtimepath, add it
  20. let &runtimepath.=','.vimDir
  21. endif
  22.  
  23. " Keep undo history across sessions by storing it in a file
  24. if has('persistent_undo')
  25. let myUndoDir = expand(vimDir . '/undodir')
  26. " Create dirs
  27. call system('mkdir ' . vimDir)
  28. call system('mkdir ' . myUndoDir)
  29. let &undodir = myUndoDir
  30. set undofile
  31. endif
  32.  
  33. " set guifont=Lucida_Console:h9:cANSI
  34.  
  35. " Set the search scan to wrap around the file
  36. set wrapscan
  37.  
  38.  
  39. " Make command line two lines high
  40. set ch=2
  41.  
  42. " Allow backspacing over indent, eol, and the start of an insert
  43. set backspace=2
  44.  
  45. " See :help 'cpoptions' for these ones. 'cpoptions' has a huge
  46. " set of possible options
  47. set cpoptions=ces$
  48.  
  49. " Set the status line the way I like it
  50. set stl=%f\ %m\ %r\ Line:\ %l/%L[%p%%]\ Col:\ %c\ Buf:\ #%n\ [%b][0x%B]
  51.  
  52. " tell Vim to always put a status line in, even if there is only one
  53. " window
  54. set laststatus=2
  55.  
  56. set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
  57.  
  58. " Hide the mouse pointer while typing
  59. set mousehide
  60.  
  61. " This is the timeout used while waiting for user input on a
  62. " multi-keyed macro or while just sitting and waiting for another
  63. " key to be pressed measured in milliseconds.
  64. "
  65. " i.e. for the ",d" command, there is a "timeoutlen" wait
  66. " period between the "," key and the "d" key. If the
  67. " "d" key isn't pressed before the timeout expires,
  68. " one of two things happens: The "," command is executed
  69. " if there is one (which there isn't) or the command aborts.
  70. "
  71. " The idea here is that if you have two commands, say ",dv" and
  72. " ",d" that it will take 'timeoutlen' milliseconds to recognize
  73. " that you're going for ",d" instead of ",dv"
  74. "
  75. " In general you should endeavour to avoid that type of
  76. " situation because waiting 'timeoutlen' milliseconds is
  77. " like an eternity.
  78. set timeoutlen=500
  79.  
  80. " Keep some stuff in the history
  81. set history=1000
  82.  
  83. " These commands open folds
  84. set foldopen=block,insert,jump,mark,percent,quickfix,search,tag,undo
  85.  
  86. " When the page starts to scroll, keep the cursor 8 lines from
  87. " the top and 8 lines from the bottom
  88. set scrolloff=8
  89.  
  90. " Allow the cursor to go in to "invalid" places
  91. "set virtualedit=all
  92.  
  93. " For how *I* code these are the best types of settings for
  94. " completion but I get rid of some neat things that you might
  95. " like
  96. set complete=.,w,b,t
  97.  
  98. " Incrementally match the search. I orignally hated this
  99. " but someone forced me to live with it for a while and told
  100. " me that I would grow to love it after getting used to it...
  101. " turns out he was right :)
  102. set incsearch
  103.  
  104. " Syntax coloring lines that are too long just slows down the world
  105. set synmaxcol=2048
  106.  
  107. map  :bnext <CR>
  108. map  :bprev <CR>
  109.  
  110. :hi StatusLine ctermbg=red ctermfg=green
  111.  
  112.  
  113. "set showcmd
  114. "fun! TrimWhitespace()
  115. " let l:save = winsaveview()
  116. " %s/\s\+$//e
  117. " call winrestview(l:save)
  118. "endfun
  119. "autocmd BufWritePre * :call TrimWhitespace()
  120.  
  121. filetype plugin indent on
  122.  
  123. :set hidden
  124. :set confirm
  125.  
  126. set ts=2
  127. set sw=2
  128. :autocmd Filetype c set ts=4
  129. :autocmd Filetype c set sw=4
  130.  
  131. " Auto-format C++ files to 2-space tabs on open
  132. function! AutoFormat2Spaces()
  133. " Only for C++ files
  134. if &filetype == 'cpp' || expand('%:e') =~ '^\(cpp\|hpp\|h\|cc\|cxx\)$'
  135. " Save cursor position
  136. let l:save = winsaveview()
  137.  
  138. " Set to 2-space tabs
  139. setlocal ts=2 sw=2 et
  140.  
  141. " Reindent the entire file
  142. normal! gg=G
  143.  
  144. " Restore cursor position
  145. call winrestview(l:save)
  146. endif
  147. endfunction
  148.  
  149. syn match Oddlines "^.*$" contains=ALL nextgroup=Evenlines skipnl
  150. syn match Evenlines "^.*$" contains=ALL nextgroup=Oddlines skipnl
  151.  
  152. hi Oddlines ctermfg=white
  153. hi Evenlines ctermfg=grey
  154.  
  155.  
  156. set visualbell
  157. set t_vb=
  158. vnoremap <C-g> :norm
  159.  
  160. autocmd FileType * set formatoptions-=o
  161. autocmd FileType * set formatoptions-=r
  162.  
  163. highlight jsonString ctermfg=196 cterm=bold
  164. highlight Comment ctermfg=green
  165.  
  166. noremap <S-q> <Nop>
  167. map <S-:> <Nop>
  168.  
  169. " Enable Ctrl-C and Ctrl-V for copy and paste
  170. " Visual mode: Ctrl-C to copy
  171. vnoremap <C-c> "+y
  172. " Normal mode: Ctrl-V to paste after cursor
  173. "nnoremap <C-v> "+p
  174. " Visual mode: Ctrl-V to paste (replace selection)
  175. "vnoremap <C-v> "+p
  176. " Insert mode: Ctrl-V to paste
  177. "inoremap <s-C-v> <Esc>"+pa
  178.  
  179. " ============================================================================
  180. " libeen-cpp project ctags configuration
  181. " ============================================================================
  182.  
  183. " Auto-load libeen-cpp tags from repository root, build, and install locations
  184. set tags+=./tags,./build/tags,./build_local/tags,/usr/local/share/libeen-cpp/tags,/usr/share/libeen-cpp/tags,/opt/een/share/libeen-cpp/tags
  185.  
  186. " Function to load cscope database if it exists
  187. function! LoadLibeenCscopeDB()
  188. " Try build directory first
  189. if filereadable("build/cscope.out")
  190. cs add build/cscope.out
  191. elseif filereadable("build_local/cscope.out")
  192. cs add build_local/cscope.out
  193. " Try installed location
  194. elseif filereadable("/usr/local/share/libeen-cpp/cscope.out")
  195. cs add /usr/local/share/libeen-cpp/cscope.out
  196. elseif filereadable("/usr/share/libeen-cpp/cscope.out")
  197. cs add /usr/share/libeen-cpp/cscope.out
  198. elseif filereadable("/opt/een/share/libeen-cpp/cscope.out")
  199. cs add /opt/een/share/libeen-cpp/cscope.out
  200. endif
  201. endfunction
  202.  
  203. " Load cscope database on startup if available
  204. if has("cscope")
  205. set csprg=/usr/bin/cscope
  206. set csto=0
  207. set cst
  208. set nocsverb
  209. " Load project-specific database
  210. call LoadLibeenCscopeDB()
  211. set csverb
  212. endif
  213.  
  214. " Function to find project root (looks for CMakeLists.txt)
  215. function! FindLibeenProjectRoot()
  216. let root = findfile("CMakeLists.txt", ".;")
  217. if !empty(root)
  218. let rootdir = fnamemodify(root, ":p:h")
  219. " Check if this is libeen-cpp project
  220. if filereadable(rootdir . "/libs/core/een++/core.h")
  221. return rootdir
  222. endif
  223. endif
  224. return ""
  225. endfunction
  226.  
  227. " Auto-load tags based on project root when entering libeen-cpp project
  228. function! AutoLoadLibeenTags()
  229. let root = FindLibeenProjectRoot()
  230. if !empty(root)
  231. " Add build/tags relative to project root
  232. exe "set tags+=" . root . "/build/tags"
  233. exe "set tags+=" . root . "/build_local/tags"
  234.  
  235. " Try to load cscope from project root
  236. if has("cscope") && filereadable(root . "/build/cscope.out")
  237. exe "cs add " . root . "/build/cscope.out " . root
  238. endif
  239. endif
  240. endfunction
  241.  
  242. " Call when entering a buffer
  243. autocmd BufEnter *.cpp,*.hpp,*.h,*.ipp call AutoLoadLibeenTags()
  244.  
  245. " Cscope key mappings for quick navigation
  246. " Find symbol
  247. nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
  248. " Find definition
  249. nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>
  250. " Find functions calling this function
  251. nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>
  252. " Find functions called by this function
  253. nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>
  254. set cursorline
  255.  
Advertisement
Add Comment
Please, Sign In to add comment