Saturday, July 28, 2012

VIM as IDE

Install CTags for VIM
-------------------------------------
     sudo apt-get install exuberant-ctags

Install Cscope for VIM
--------------------------------------
    sudo apt-get install cscope

Install the following plugins for VIM
------------------------------------------------------------
1. Automatic Display of Declarations in the Context Window on the bottom in the (G)VIM window using the script named 'Source Explorer(srcexpl.vim)' :
    http://www.vim.org/scripts/script.php?script_id=2179

2. Symbol Windows For Each File on the left in the (G)VIM window (G)VIM using the script named 'taglist.vim':
    http://www.vim.org/scripts/script.php?script_id=273

3. Quick Access to All Files on the right in the (G)VIM window using the script named 'The NERD tree(NERD_tree.vim)':
    http://www.vim.org/scripts/script.php?script_id=1658

4. Cscope maps the keyboard shortcuts for various commands in cscope using the script named '(cscope_maps.vim)':
    http://cscope.sourceforge.net/cscope_maps.vim

4. Trinity manages all the above plugins and fit them in VIM to get the feel of source insight IDE using the script named '(trinity.vim)':
    http://www.vim.org/scripts/script.php?script_id=2347

4. You can change various options of each plugin in trinity.vim according to you request.


Additonal Info:
-------------------------
          After installing cscope its mandatory to build cscope DB for your project inorder to execute the commands inside VIM. If your project is c,cc,cpp project the following command will generate you a basic database. However you can tweak the same for your project requirements. Execute the following command at the top level project directory.

    find . -regex '.*\.\(c\|cpp\|h\)$' > cscope.files

    cscope -b

the above commands should generate a cscope.out DB file in your current working directory. If successfull, open VIM and type the following command

    :cscope add /home/xyz/cscope.out

some useful cscope commands:
  • Find this definition - :cs f g
  • Find functions called by this function - :cs f d
  • Find functions calling this function - :cs f c
  • Find this text string - :cs f t
  • Find this file - :cs f f
  • Find files #including this file - :cs f i
  • Find this C symbol - :cs f s
  • Find this egrep pattern - :cs f e

- Done and now you are ready to go. Happy VIM'ing.

Thursday, July 19, 2012

Chromium depot_tools download


During download of depot_tools of chromium browser using git in linux, we may get the following error

-------------------------------------------------------------------------------------------------------------------------
root@aphone-ubuntu:~/chromium_src# git clone https://git.chromium.org/chromium/tools/depot_tools.git
Initialized empty Git repository in /root/Chromium_Src/depot_tools/.git/
error: Couldn't resolve host 'git.chromium.org' while accessing https://git.chromium.org/chromium/tools/depot_tools.git/info/refs

fatal: HTTP request failed

--------------------------------------------------------------------------------------------------------------------------

this error may occur due to http proxy or firewall behind which we are trying to use git. Try setting the global htty proxy config for git. It worked for me.

git config --global http.proxy http://proxy:8080
// To check the proxy settings
git config --get http.proxy

After setting the above try  #git clone "url" .