Skip to main content

Using OmniCppComplete and vim for C++ auto-completion

Get OmniCppComplete

Then install it: (It may overwrite some stuff... take care!)

ckdir ~/.vim/
cd ~/.vim/
unzip cppcomplete.zip


Then create and set your common tags file: (correct for your local installation locations)

~> ctags –R --c++-kinds=+p --fields=+iaS --extra=+q \
-f ~/vim/commontags \
~/dev/myTools/include \
/usr/include \
/use/lib/boost/include /usr/lib/qt3/include

------- .vimrc:
set tags+=~/vim/commontags
-------






Add mapping to create/update local (CWD) project tags files:

------- .vimrc:
map :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .
set tags+=./tags
-------






Set up some default options:

------- .vimrc:
" OmniCompletionOptions
set completeopt=menu,menuone
let OmniCpp_NamespaceSearch=2
let OmniCpp_ShowPrototypeInAbbr=1
" let OmniCpp_MayCompleteScope=1
-------






Then add any convenience macros:

------- .vimrc:
" Smart VS-type <tab-completion>
function! CompleteTab(direction)
let prec = strpart( getline('.'), 0, col('.')-1 )
if prec =~ '^\s*$'
if "backward" == a:direction
return "\<bs>"
else
return "\<tab>"
endif
endif

if exists('&omnifunc') && &omnifunc == 'omni#cpp#complete#Main' && prec =~ '[\.>]\s*[~]\?[a-zA-Z_]*[(]\?$'
" Class completion... use normal direction
" Use this with omniCompletion
if "backward" == a:direction
return "\<c-p>"
else
return "\<c-n>"
endif
endif

" else use generic completion: last-seen / reverse-order
if "backward" == a:direction
return "\<c-n>"
else
return "\<c-p>"
endif
endfunction

inoremap <tab><c-r>=CompleteTab("forward")<cr>
inoremap <s-tab><c-r>=CompleteTab("backward")<cr>
-------

Comments

Popular posts from this blog

My Custom Mechanical 60% Keyboard Build

My Custom Mechanical 60% Keyboard Build All the parts   1x GH60 (Satan) board - $35 61x Cherry Clear switches  - $35 2x Cherry Blue switches - $3 10x Cherry Red switches - $10 1x PCB Stabilizer set (6.25 space) - $6 1x Royal Oak Glam 60% case (Black Walnut) - $78 1x Aluminium 60% plate - $19 1x SA profile Choclatier keycaps - $102 ( base, modifiers, and novelties ) 1x Braided Nylon USB cable - $15 Solder, Tools, Risers, Labor, etc. Total: ± $300 (Other single switch types added as needed) Testing the board I had my helper do the work here. We needed to test the board before applying any solder. Assembling Add the stabilizers first Add the plate (using a few switches as spacers) Then add the rest Solder solder solder... And test again: The casing The casing I received did to have built-in risers: So I added my own: Then Assemble (using temporary spare GMK Carbon Cherry-profile k...

Lock Screen on Mac OS X using keyboard shortcut.

1. Download "Global Hotkey" 2. Create a folder "Global Hotkey" and copy contents of downloaded DMG to that. 3. In a terminal do: cd "/Applications/Global Hotkey" ln -s /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app "command f10" 4. Make sure Screensaver is set to prompt for password (you may need to relog for this to take effect) 5. Preferences -> Accounts -> -> Login Items : Add "Global Hotkey.app" 6. Launch the app as well

The story of my Amiga A1200's new lease on life.

Ok, so I rummaged through my storage in South Africa and found my old Amiga once again. This was not the original one I used to have, this is an Amiga A1200, where I used to have the Amiga A500 back in 1986. A bit of history, I started out with a Atari 2600 back in 1983 (was 10 years old at the time), then saw an advertisement for a cartridge that could do programming... this concept fascinated me, but we could never find it anywhere (it was hard finding the good stuff in South Africa). I settled for a VIC-20 soon afterwards (I sold my Atari), then upgraded to a Commodore C64 soon thereafter. This lasted until 1986 (age 13) when, after countless months of pouring over Commodore User magazines, I decided I wanted an Amiga. I had the choice between an IBM compatible XT (with two floppy disc drives but no graphics) or an Amiga. Both seemingly the same price, but due to the then apartheid-era restrictions and taxes, the Amiga turned out to be very troublesome t...