Thursday, October 22, 2009

Cscope with vim

today I came to know the best way of using cscope with vim(I mean through ex editor commands).

SHORTCUT:
Ctrl-b will browse through history of cscope searches that u performed earlier at the cscope prompt.

first set the default editor to vim
export EDITOR=vim
  • 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
if you see problem in building the cscope database or facing problem like "E567: no cscope connections" then use:

:cs add cscope.out
as described under ":help cscope-howtouse"

Is the screen getting unresponsive/blocked/can't reattach, then try setting following command next time:
:nonblock on (or) -- default is 1 second.
:nonblock 5 

To browse the code through commands instead of typing ":cs f x",
download the following file:
http://cscope.sourceforge.net/cscope_maps.vim
copy it to:
~/.vim/plugin directory (assuming u are using >=vim6) and follow the following command options and I can tell you it's worth trying and with this options cscope became best browsing tool for me:
  • To jump to a result type the results number (+ enter)
  • Use tags commands to return after a jump to a result: ctrl-t
    To return to same spot as departure, use ctrl-o
  • To use "tags" navigation to search for words under the cursor (ctrl-\ or ctrl-])
  • CTRL-\ s/g/c/f..etc for key board shortcuts
  • "CTRL-spacebar s". This time, your Vim window will split in two horizontally , and the Cscope search result will be put in the new window. [if you've never used multiple Vim windows before: move between windows via 'CTRL-W w' (or CTRL-W arrow key, or CTRL-W h/j/k/l for left/up/down/right), close a window via 'CTRL-W c' (or good old ':q'), make the current window the only one via 'CTRL-W o', split a window into two via 'CTRL-W s' (or 'CTRL-W v' for a vertical split), open a file in a new window via ':spl[it] filename']
  • "CTRL-spacebar CTRL-spacebar s" (just hold down the CTRL key and tap the spacebar twice). If you have trouble hitting the keys fast enough for this to work, go into the cscope_maps.vim script and change Vim's timeout settings as described in the comments This time your Vim window will be split vertically

To get the help from vim :help cscope or :cs help
Command to see the runtimepath of vim :set runtimepath

Building cscope database on readonly workspace

Create cross reference file with readonly directories or files by giving complete path:
1. cscope -R -s dir,dir,dir -f cross-reference.file --- if this doesn't work, try the following:
     Go to one of the directories for which you need to build database, because -s option seems to take including the current directory to build database. Here lets think you are in dirpath1
    cscope -R -s  dirpath2/* dirpath3/*  -f cross-reference.file
2. cscope -R /complete-path/file1.c /complete-path/file.h -f cross-reference.file
3. find `pwd` -name [*.ch] | sort > file
cscope -R -i file -f cross-reference.file

To just start with cross-reference file
cscope -d -f cross-reference.file

To display last n elements of the path name:
cscope -pn 



To set the cscope tags:
set cst


>>>>>>
set csprg=/router/bin/cscope



References:
http://vimdoc.sourceforge.net/htmldoc/if_cscop.html
http://www.swaroopch.com/notes/Vim_en:Programmers_Editor
http://vim.dindinx.net/orig/html/if_cscop.txt.php
http://www.uic.edu/depts/accc/software/unixgeneral/vi101.html
http://vim.sourceforge.net/scripts/script.php?script_id=213
http://www.vim.org/scripts/script.php?script_id=1638
http://www.vim.org/scripts/script.php?script_id=2502
http://www.yolinux.com/TUTORIALS/LinuxTutorialAdvanced_vi.html
http://cscope.sourceforge.net/cscope_vim_tutorial.html
http://uw714doc.sco.com/en/SDK_cdebug/B_CmdLnOpts.html
http://unix.stackexchange.com/questions/46568/gnu-screen-freezes-trying-to-reattach

Wednesday, September 16, 2009

c errors

incompatible types in assignment
example:
int a[10];
a = malloc(10);

Thursday, September 10, 2009

About VNC

vncserver -- Starting vnc server.
vncserver : 1 -- Starting vnc server with specific session.
vncserver -kill :1 -- Killing the vncsession.
vncconfig & -- to make copy paste work b/w remote to local vice versa.

On linux to have VNC connection to current session:
For this you need to install x11vnc:
x11vnc -display :0 -auth ~/.Xauthority



We can start the vnc during bootup aswell. Please google it for this.


Following is the config file which I use in ~user/.vnc/xstartup file:
**************************
#!/bin/sh
if [ `/bin/uname` = "SunOS" ] ; then
xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic -nowin&
xterm -geometry 80x24+10+10 -sb -ls -sl 8000 -title "$VNCDESKTOP Desktop" &
blackbox &
else # Linux
vncconfig -nowin -set AlwaysShared=on &
PATH=$PATH:/usr/X11R6/bin:/usr/bin:/usr/cisco/bin:/usr/X11R6/bin
export PATH
WM=/usr/bin/startxfce4
#WM=/usr/X11R6/bin/twm
#WM=/usr/bin/gnome-session
#WM=/usr/bin/startkde
fi
if [ ! -x $WM ] ; then
# failsafe window manager choice
WM=twm
fi
if [ -r $HOME/.Xdefaults ] ; then
xrdb -merge $HOME/.Xdefaults
fi
## following config is for copy/paste from vnc viewer.
if [ -x /usr/bin/vncconfig ]; then
/usr/bin/vncconfig -nowin &
elif [ -x /usr/cisco/bin/autocutsel ] ; then
/usr/cisco/bin/autocutsel &
fi
exec $WM
*******************************

References:
http://www.karlrunge.com/x11vnc/
http://ubuntuforums.org/showthread.php?t=944187

Sunday, September 6, 2009

Linux Bash Commands

1. echo $SHELL -- to know the current shell
2. chsh -s /bin/bash - to change the current shell.
3. echo $SHELLOPTS - Which shell mode is being used (vi or emacs)
4. set -o emacs - to set shell mode to emacs
5. By default bash doesn't check it's window size after every command. The good thing is that you can make it. Add "shopt -s checkwinsize" to your ~/.bashrc or /etc/profile.
echo "shopt -s checkwinsize" >> ~/.bashrc (or /etc/profile)
source ~/.bashrc
try again
6. Problem: rm: cannot chdir from `festival/' to `config': Permission denied
Solution: chmod -R u+rwx * in the directory
7. Yet to come.

Bash Shell Keyboard Shortcuts:
Moving around:
Ctrl-b - Move a character backwards.
Ctrl-f - Move a character forward.
Alt-b - Move cursor backward one word on the current line.
Alt-f - Move cursor forward one word on the current line.
Ctrl-a - Move to the beginning of the current line.
Ctrl-e - Move to the end of the current line.
Ctrl-x-x - to the start, and to the end again

Cut, copy and paste:
Ctrl-d - Delete the character the cursor is on.
Ctrl-h - Delete a character before the cursor.
Ctrl-u - Delete from the cursor back to the line start.
Ctrl-k - Delete from the cursor to the end of the line.
Ctrl-x Backspace - Delete all characters in the line up till the current cursor position.
Alt-d - Delete the word, starting at the current cursor position.
Alt-Backspace - Delete every character from the current cursor position to the first character of a word that is encountered.
Ctrl-w - Delete the word, untill after the previous word boundary.
Ctrl-y - Yank/Paste previous killed text at the cursor position.
Alt-y - Yank/Paste previous previous killed text at the cursor position.

History
Ctrl-p - Move in history to the previous line.
Ctrl-n - Move in history to the next line.
Ctrl-r - Incrementally search the line history, Backwardly.
Ctrl-s - Incrementally search the line history, Forwardly.
Ctrl-J - End an incremental search.
Ctrl-G - Abort an incremental search and restore the original line.
Alt-Ctrl-y - Yank/Paste arg. 1 of prev. cmnd at the cursor position.
Alt-. OR Alt-_ - Yank/Paste last arg of prev. cmnd at the cursor position.

Undo
Ctrl-_ OR Ctrl-x OR Ctrl-u - Undo the last editing command; you can undo all the way back to an empty line.
Alt-r - Undo all changes made to this line.
Ctrl-l - Clear the screen, reprinting the current line at the top

Completion
TAB - Auto-complete a name.
Alt-/ - Auto-complete a name (without smart completion).
Alt-? - List the possible completions of the preceeding text.
Alt-* - Insert all possible completions of the preceeding text.

Transpose
Ctrl-t - Swap (transpose) the characters the cursor is on, and the character before the cursor.
Alt-t - Swap (transpose) the current word with the previous word.

CASE
Alt-u - Make the word uppercase, starting at the current cursor position.
Alt-l - Make the word lowercase, starting at the current cursor position.
Alt-c - Capitalize the current word character or the next word character that is encountered.

Use "set t_ti= t_te=" in .vimrc
if you don't want clear vim output after exit vim.


References:
http://www.slackbasics.org/html/chap-shell.html

http://faq.programmerworld.net/misc/linux-keyboard-shortcuts.html
http://article.gmane.org/gmane.linux.gentoo.user/57011
http://www.linuxquestions.org/questions/linux-general-1/disable-the-clear-after-you-close-vi-657233/#post3221832
http://www.bigsmoke.us/readline/shortcuts

Thursday, August 20, 2009

oldest eatery in Bangalore

1. Udupi Krishna Bhavan, Chickpet
2. Malabar, Chickpet
3. New Modern Café, Near Minerva cisrcle
4. Vidyarthi Bhavan, Basavanagudi -- special for dosas
5. MTR, Lalbagh Gate
6. Veena Stores, Malleshwaram
7. Sri Sagar, Malleshwaram
8. Surya Stores, Malleshwaram
9. Hotel Janata, Maleeshwaram
10. Brahmins Coffee Bar in Shankarpuram -- special for idlis
11. New modern hotel (NMH) near minerva circle
12. Dwarka Bhavan in NR Colony
13. SLV hotel near ramakrishna ashrama -- special for kharabath
14. Iyer Mess in malleswaram -- for south indian meals
15. Janatha Hotel (Masala Dose) in Malleswaram
16. Ragiguda SLV in Jayanagar-- for ravva idli
17. Siddappa Hotel (Butter dosa)-- (you need to take left on the Corporation signal after Pallavi Theater. Move around close to 100ft and take another left. Pass a Govt.. school which kinda semi-circle and you’ll be in front of the hotel.)
18. Muddanna (Idlys & Pulav) in Cubbon pet - Near Town Hall
19. Chikkana (Dosas with Ghee) - in Cubbon Pet
20. Food Street (south indian & north indian) - VV Puram
21. Indian Coffe house - (Snacks) - Vidhan Soudha
22. Gundappa Hotel -- (Badam halwa and mouth watering mysore pak)
23. Hotel Gopika (also called as New Krishna Bhavan) opp to Mantri Greens(Known for authentic and unique karavali food (Neer Dose, Green Masala idle, Kotte kadubu, gojju avalakki, paddu))

links:
http://www.triphobo.com/blog/best-dosa-joints-in-bangalore
http://www.triphobo.com/blog/restaurants-in-bangalore-serving-kannada-food

Wednesday, August 19, 2009

Melodies

Yamuna Thatilo --- Dalapathi
Alanaati --- Murari
Kammani --- Guna
Paruvam vaanala --- Roja