Search For The Word Under The Cursor In VIM

If you want to search a word in vim, you’ll probably use “/” (forward) and “?” (backward) followed by the word you want to search.

What if you want to look for the word currently under the cursor?
Obviously, you can use the above method. But a shorter one is: just hit “*” to search forwards, and “#” to search backwards.
So short, so efficient.

Surviving sed When Replacing Slashes

Usually, searching and replacing using sed looks something like this:

sed -e ‘s/abc/yyy/g’ file.txt

Now, how would we for example modify a string of the form:

to become

We can use something like this:

sed -e ‘s/:\/\//::/g;s/\//::/g’ file.txt

But who said that we have to use a slash as a separator when our regular expression is full of slashes?
The following is equivalent but much cleaner:

sed -e ‘s#://#::#g;s#/#::#g’ file.txt

You can use any character as a separator.


Clang Analyzer – A Great Cross-Platform C Static Analyzer

Clang Analyzer is a Static Code Analyzer for C and Objective-C.

Why it’s great:
1. It works on Mac, and Linux.
2. Running it is as easy as:

scan-build -V gcc -o prog prog.c


scan-build -V make

3. It gives great looking HTML reports.

4. You can easily report all or part of the errors as bugs:

Note (If you’re using Xcode):
Clang is built-in Xcode as of version 3.2. Run “Build and Analyze” to analyze your programs.