Tuesday, January 19, 2010

Using ctags with Vim

I have been using vim for all my coding related tasks for a year now. I heard of ctags a while ago but I never tried using it. But recently I got tired of moving between files manually -looking for functions and other stuff- so I decided to give ctags a try. I never expected for it to be so simple. Just install ctags:
sudo apt-get install ctags
Generate tags file. To do this go to the main directory of your source tree. There just issue the command:
ctags -R
this will recursively traverse the source directory and generate a tags file containing information about all symbols -functions and variable- in the source files.
Using Vim with ctags is straight forward. Vim has builtin support for ctags so now you just need to issue vim command from the directory where you generated the tags file using ctags.
vim src/asdf/test.c
Now in the file move a cursor to some function or variable and press Ctrl-]. This will take you to the definition of that function or variable. To go back to where you came from press Ctrl-T, this will take you back to where your were before pressing Ctrl-]

If you have more than one tags files or you dont want to always use vim from one directory then add following line to your .vimrc file in your home directory:
set tags=tags;/

Monday, January 18, 2010

Connect To PTCL EVDO(Evo) from Ubuntu Linux

PTCL Evo connection comes with ZTE AC2726 USB modem. Its really easy to use it on Windows and Mac as there drivers are provided in the modem's memory but to use it on Linux is a bit tricky. Recently I succeeded in installing and configuring it on Ubuntu 9.10 and below are the steps which worked for me.
When you attach the modem to your linux machine it gets detected as a usb storage device and not as a usb modem. To use it as usb modem we need to convert it from usb-storage device to usbserial device in ubuntu. To do this I used -modeswitch utility which can be installed using following command:
sudo apt-get install usb-modeswitch
Unplug the modem and plug it back in. Use lsusb command to see list of usb devices attached to your system. You should see a line similar to
Bus xxx Device xxx: ID 19d2:fff1
Here 19d2 is vendor id for ZTE and fff1 is the device id for AC2726. If you dont see this line or see one with device id fff5 then you will need to restart your system. Now issue following command to load proper driver module in kernel:
sudo modprobe usbserial vendor=0x19d2 product=0xfff1
And thats it. Your modem is ready to be used. You will now need a dialer app to dial and establish the connection. I used gnome-ppp as it has the ability to dock. To install gnome-ppp issue following command:
sudo apt-get install gnome-ppp
You can now run gnome-ppp. You will need to run it as root. After it starts click on setup. On setup window click Detect so that it can detect your usb modem. Set type to be USB MODEM and speed to be 460800. Set phone line to Tone and volume to off. Now go to options tab and check the following:

  • Dock in notification area
  • Auto reconnect
  • Ignore terminal strings..
Now click close. You will be taken back to smaller window. Enter vwireless@ptcl.com as user name and ptcl as password. Enter #777 as phone number and click connect. and you will get connected to ptcl evo service.

UPDATE: if you are using Ubuntu 10.04 or later you can use a simpler method mentioned here