title

fire chief's random developer tidbits

Friday, December 17, 2010

Extremely useful vim settings

make the mouse work like it should by default:
:set mouse=a

make vim use vim improvements instead of defaulting to older vi behavior
:set nocompatible

show hidden characters like dos carriage returns (^M)
:set list

Debugging remotely and waiting for debugger attachment

Starting with Java 5, you can run a java program this way and have it suspended until you attach a debugger remotely:

-agentlib:jdwp=suspend=y,server=y,transport=dt_socket,address=HOST:PORT

More info here:

Thursday, December 16, 2010

Crazy Vim Stuff

Given a huge text file you want to extract some things from, here's how to delete all the lines that DON'T start with a regex in Vim:

:%s/^\(\(search text\)\@!.\)*$//g

then remove all the blank lines:

:g/^$/ d
(there's a space before the d)

then sort it with:
:sort

Help came from these pages:
http://vim.wikia.com/wiki/Search_and_replace
http://www.computing.net/answers/unix/delete-blank-line-thro-vi-editor/4552.html