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

Firefox: Open diverted links in new background tab instead of new window

This has frustrated me for a long time... something I really liked about Opera. Go to 'about:config' url and set: browser.tabs.loadInBackground to true (should be already) browser.tabs.showSingleWindowModePrefs to true browser.tabs.loadDivertedInBac kground to true Then in advanced preferences is a new option: 'Force links that open a new window to:' can be used for immesdiate effect.

Why torrent low-ratio banning is killing the network and is generally a bad idea.

It seems a growing trend for people to get banned for low share ratios. Now I can understand how this would appeal to some people`s sense of (in)justice as there are people out there who do not understand that not sharing while you download will ultimately make you download yours slower as you supply bits to other people who would otherwise been supplied by the seeder, making it possible for you to download from open slots at the seeder. These are typlically low-intellect `kiddies` who don`t do math and then download hacked clients because they are just stupid. I agree that these people are evil. But putting a share-ratio of 0.9 and higher as mandatory is just insane. (IMHO 0.1 is the absolute maximum) Take the following example (using mathematical induction and taking values to extremes) if I limited my download to 1k/s and my upload to 25k/s (I have a 256/256 connection) my share ratio inexorably tends to go to sub-1.0. In fact, I find that only the T1 people seems to...

Creating a SSH tunnel to the internet.

Ever been at a client with Orwellian access restrictions on the internet? Why not use what they provide you to the max without cracking their security. What you will need: 1. Access/login to a linux machine with ssh running on port 80 (or 443) (See UnixShell - They're grrreat!) 2. The proxytunnel client program . Creating the tunnel: Firstly you will need to create a TCPIP tunnel through your proxy server. For my example I'm running OS X (on my shiny MacBook Pro). To do this, add the following (2 lines) to your ~/.ssh/config file: Host shell.my-host.com ProxyCommand /Users/teuton/bin/proxytunnel -N -p "local-proxy:8080" -u "proxy-user" -s "proxy-pass" -d "shell.my-host.com:443" Great! We are all set! You may need to tweak these settings depending on your local proxy server type and configuration (NTML auth etc) Now the easy part. Creating the proxy: To ssh into your machine simply type: > ssh teuton@shell.my-host.com To make...