Cscope tags with Vim: easy setup

These setup steps will help you to browse code efficiently

Steps :

Install Cscope, if you already have ignore this step

apt-get install cscope

Install cscope plugins

mkdir ~/.vim/plugins
cd ~/.vim/plugins

Add this below line in .vimrc file

source ~/.vim/plugins/cscope_maps.vim

In .bashrc file add these lines. This will create an alias which will search and index the file types as mentioned

alias mycscope='export SB=$PWD;find $SB ( -name '.[chs]' -o -name '.cc' -o -name '.cpp' -o -name '.hh' ) > $SB/cscope.files;cscope -b -q -R -i   $SB/cscope.files'

export CSCOPE_DB

Now go to the top directory of your codebase from where you want to build your cscope.

nirweb:/mysandbox/src$ bash
nirweb:/mysandbox/src$ mycscope
nirweb:/mysandbox/src$ ls -l cscope.out

Verify that cscope.out is created. Now run cscope

cscope -q -d

Browse your codebase using these common shortcuts

Jump to definition

Ctrl + ]

To return back

Ctrl + t

To find all references

Ctrl + \s

Note "+" is not a keystroke, it just indicates the combination

Happy browsing.

Some references

Save time by creating multiple Tabs with Linux Screen in the same window

It is tedious to browse through your linux screen windows, by typing “Ctrl a” + ” every-time you want to switch to another window. A better approach, that will save your time is to use multiple Tabs in the same window. You will remember the context and can quickly switch among the tabs.

So let us quickly get the tabs.

Screen Tabs Setup

Open a terminal and first install screen if screen is not already installed

nir@ubuntu:~$ sudo apt-get install screen
nir@ubuntu:~$ which screen

Open your .screenrc file and add the following string and you are set.

nir@ubuntu:~$ cat ~/.screenrc 
caption always "%{= kw}%-w%{= BW}%n %t%{-}%+w %-="

Note it will work for all new screen session you are creating

Test linux screen with multiple tabs

Let us create a new screen session called myShell

nir@ubuntu:~$ screen -S myShell

Once you are in, you can see already at the bottom
a tab is created named “0 bash”

Create couple more by pressing “Ctrl a” + “c”
You can see more tabs getting created.

To go from one tab to next
“Ctrl a” + “n”

To go from one tab to previous
“Ctrl a” + “p”

To rename a tab use
“Ctrl a” + “A”
(note “A” is in CAPS)

Here is a screenshot of what you will get after executing the above commands

linux screen example
linux screen example

To jump to any tabs you can use the number seen along with the tab
“Ctrl a” + n
where n can be 0,1,2 in the above example.