Saturday, June 16, 2007

VIM note: viewport

It's sometimes necessary to split the view of a file into many windows. Below is a cheatsheet copied from here.

:sp will split the Vim window horizontally. Can be written out entirely as :split .
:vsp will split the Vim window vertically. Can be written out as :vsplit .
Ctrl-w Ctrl-w moves between Vim viewports.
Ctrl-w j moves one viewport down.
Ctrl-w k moves one viewport up.
Ctrl-w h moves one viewport to the left.
Ctrl-w l moves one viewport to the right.
Ctrl-w = tells Vim to resize viewports to be of equal size.
Ctrl-w - reduce active viewport by one line.
Ctrl-w + increase active viewport by one line.
Ctrl-w q will close the active window.
Ctrl-w r will rotate windows to the right.
Ctrl-w R will rotate windows to the left.

Tuesday, June 12, 2007

C++ note: mix with C code

The easiest way to make use of C modules is including the header files with

extern "C"
{
#include <a_c_module.h>
}

Then the C++ compiler knows that the header defines the structures in the c way, and will compile references in the C++ module in a compatible way.

For the standard libraries name "cblabla", extern "C" is already included in the header files. This is the reason why modules etc can be included directly.

For the linker, different vendors might have different standards to mangle the refernece names. Therefore, it needs to be confirmed that the C modules are compiled in a compatible way as the C++ module.

Making use of C++ modules from C modules is harder than the other way around. For the C++ programmers, it might be possible to turn some necessary C files into the C++ format and then compile the whole project as C++. Many files can be kept as the C modules and linked explicitly.

Monday, June 04, 2007

Javascript note: about the regular expressions

Javascript supports regular expressions as a built in language feature. Regular expressions are enclosed between two "/".

Here is a tutorial.