Wednesday, April 8, 2009

Vim - Reduce Backslashing



Appending a "\v" reduces the amount of backslashing the search expressions.

/codes\(\n\|\s\)*where : normal regexp
/\vcodes(\n|\s)*where : very magic


source :
http://vim.wikia.com/wiki/Best_Vim_Tips

Tuesday, April 7, 2009

Vim - Open Current File in Explorer or Command Prompt

Put the following two lines in your vimrc files under window to get F11 and F12 to work as "command prompt here" and "explorer here" !


map :silent !start cmd.exe /k pushd %:p:h
map :silent !start explorer.exe %:p:h


source for tip1

"http://vim.wikia.com/wiki/Open_the_folder_containing_the_currently_open_file"

source for tip2

A variant of tip 1 using windows trick of adding a registry for folders to open a command prompt 

Note : % represents the file open in current buffer

Monday, April 6, 2009

Oracle dba_jobs : Breaking

exec dbms_job.broken(690,true);

where 690 is the job number obtained from
select * from dba_jobs

Oracle databases - startup and shutdown

Shutdown:

$ export ORACLE_SID=db_sid
$ sqlplus /nolog
sql> connect / as sysdba
sql> shutdown immediate

Startup :

$ export ORACLE_SID=db_sid
$ sqlplus /nolog
sql> connect / as sysdba
sql> startup mount
sql> alter database open;

Note: This needs to be done by logging on the machine where oracle database is installed

Tuesday, February 24, 2009

marks in vim - bookmarks

- Go to a line where you want a mark and press mx - this will create a bookmark

( x can be any alphabet from a-z)

- Now navigate away from that place. If you need to get back to the earlier cursor location press "`x" (back-tick and x)

- You can set multiple "marks" in a single file and navigate using back-tick and the alphabet used to create a mark

Monday, February 16, 2009

Cron entry for other users

Execute the following as root :

cat /var/spool/cron/ssinghal

where ssinghal is the user name

Friday, February 6, 2009

Sed - Deleting lines matching a pattern

sed -i '/.*log$/d' file_names.txt

Deletes all the lines ending with "log" from the file "file_names.txt"