Monday, March 31, 2008

Testplan plugin in Confluence WIKI

Recently in our organization, we started to use Confluence WIKI for documentation purpose. This wiki has a plugin called TestPlan. I liked this plugin very much as it allows us to maintain our test cases and get the test case execution status.
Below is the screenshot of sample testplan:





Below is the wiki markup for above sample:
{testplan:Release includeJiraLinks=false useFailMacro=false}
^Feature1
//This is comment
Test1
Test2
^Feature2
//This is comment
Test3
Test4
{testplan}

Wednesday, March 26, 2008

vi Examples

s/pat/text/ substitute 1st match of pat with text

s/pat/text/g substitute every match of pat with text

s/pat/text/n substitute the nth occurrence of pat with text

:%!sort or :1,$!sort sort current file

:5,10s/foo/bar/2 change the second occurrence of foo with bar on lines 5-10

:map g 1G map g to really run 1G

3J Join next 2 lines to current one

3,9m$ move lines 3 through 9 to the end of the file

ab w/o without when w/o is typed change to without

:?foo?,/bar/d delete from the reverse match of foo until the next match of bar

:g/{/,/}/< shift all lines between, and including, a "{" and a "}" left

:$-4,$d delete last five lines of buffer

:%s/^\(.*\) \(.*\)$/\2 \1/ swap everything before and after the first space

d'' delete from current position to line of last jump

Perl matches Perl

^Perl matches Perl at beginning of line

Perl$ matches Perl at end of line

^Perl$ matches Perl as the only word on line

^$ matches the empty line

^..*$ matches a line with at least one character

.* matches any string of characters including none

^[ ^I]*$ as above but line can also contain spaces and/or tabs(^I)

[pP]erl matches perl or Perl

[aA][nN] matches an, aN, An, AN

p[aeiou]g second letter is a vowel

i[^aeiou]g second letter is not a vowel

p.g second letter is anything

^....$ matches a line with exactly four characters

^\. matches any line beginning with a dot

^\.[0-9a-z] same with a lowercase letter or digit following

^[^\.] matches any line that does not begin with a dot

;$ matches a line ending with a semicolon

figs* matches fig, figs, figss, figsss etc.

[a-z][a-z]* matches one or more lowercase letters

[a-zA-Z] matches any character

[^0-9a-zA-Z] matches any symbol (not a letter or number)

\&ltthe matches the, theater, then

the\> matches the, breathe

\&ltthe/> matches the

:%s/\<./\u&/g turn the first letter of all words to uppercase

:%s/\<[a-z][!-~]*\>/\u&/g as above

:%s/\<[a-z]/\u&/g as above

:%s/.*/\L&/ turn entire file to lowercase

:%s/<[^>]*>//g remove strings from file that start with a less than sign and end with a greater than sign (html tags)

:1,$s/1$/0/g Replace 1 to 0 from each line of the file, if last character of the line is 1

:1,$s/^1/0/g Replace 1 to 0 from each line of the file, if first character of the line is 1

Tuesday, March 11, 2008

see the differences between two branches of CVS

To see all of the changes between two branches

1. checkout the source from HEAD/or branch, CD into it
2. run command cvs -q diff --brief -r brach_to_compare | grep Index

Monday, March 10, 2008

vi environment variables

set
you can customize your environment with this command by typing set var=value, this will set the specified var to value for a scalar variable. For boolean varaibles, use set var to set and set novar to unset. You can see which variables are set by just typing the set by its itself. You can see a list of all variables by typing set all. some environment variables are specific to the ex editor and some are specific to the vi editor.

boolean variables:

autoindent(ai)

begin editing next line at same level of indent-ion as this one.

autowrite(aw)

write current buffer before leaving

exrc(ex)

tells vi/ex if it should read the .exrc file in the current directory(this can be a security risk).

errorbells

editor sends a beep to the terminal when an incorrect

flash

inverse the screen on an error instead of producing a bell

ignorecase(ic)

ignore case of characters in searches.

lisp

enter lisp mode

list

place a $ at the end of each line and a ^I on each tab.

magic

allow ., [, and * to be interpreted as special characters in RE's.

modelines

execute the first and last 5 lines of the file if of the form: ex:command: or vi:command:

number(nu)

number lines in left margin

showmatch(sm)

when closing a paren., brace or bracket; move the visual cursor to opening item to check scope

showmode(smd)

show type of insert mode

wrapscan(ws)

when searching and at bottom of file, continue searching from the top


Scalar variables:

directory

the location of the temporary directory used by vi

paragraphs(para)

macros to signify the beginning of a paragraph

report

vi will notify you if you change more lines than the value of report

sections(sect)

macros to signify the beginning of a section

shell

The shell to use when executing the command :sh or :!

shiftwidth(sw)

number of spaces to to insert on a shift operation

showmatch(sm)

show the match of ) and } when typed

tabstop

the length, in characters, of a tabstop

term

holds the name of the terminal type being used

wrapmargin(wm)

split lines at the column which is equal to the value of wrapmargin

avoid error "Not owner of .exrc or .exrc is group or world writable" in vi

set this environment variable

export EXINIT="set noexrc"

Saturday, March 8, 2008

vi Editor Commands

The VI editor is a screen-based editor used by many Unix users. The VI editor has powerful features to aid programmers, but many beginning users avoid using VI because the different features overwhelm them.

General startup
To use vi: vi
To exit vi and save changes: ZZ or :wq
To exit vi without saving changes: :q!
To enter vi command mode: [esc]
Read the original file back in so that you can start over.: :e!


Counts

A number preceding any vi command tells vi to repeat that command that many times.
Deleting
x delete character under cursor
X delete character before cursor
dd delete line under cursor
dw delete word under cursor
db delete word before cursor
D delete to the end of line from the current cursor position
d^ delete from current cursor position to the beginning of the line
d$ delete from current cursor position to the end of the line

Copy/Paste Text
yy copies line
P paste copied data before cursor
p paste copied data after cursor

Find Commands
? finds a word going backwards
/ finds a word going forwards
f finds a character on the line under the cursor going forward
F finds a character on the line under the cursor going backwards
t find a character on the current line going forward and stop one character before it
T find a character on the current line going backward and stop one character before it
; repeat last f, F, t, T
, repeat last f, F, t, T going backwards
n repeat last search given by ‘/’ or ‘?’
N repeat last search given by ‘/’ or ‘?’ going backwards

Miscellaneous Commands
. repeat last command
u undoes last command issued
U undoes all commands on one line
xp deletes first character and inserts after second (swap)
J join current line with the next line
^G display current line number
% if at one parenthesis, will jump to its mate
mx mark current line with character x
'x find line marked with character x
^^ Go back to last file
READING/WRITING FILES
:r filename Copies filename after cursor in file currently editing
:n Start editing next file in list
:rew rewind file list, start editing 1st file on argument list
:w Saves the current file without quitting

MOVING
:# Move to line #
:$ Move to last line of file


Character/Line Formatting
~ Switch the case of the character under cursor
< Shifts the line upto where to the left by one shiftwidth
<< Shifts the current line to the left, and can be specified with a count
> Shifts the line upto where to the right by one shiftwidth
>> Shifts the current line to the right, and can be specified with a count
J Join the current line with the next one.

SHELL ESCAPE
:!'CMD' Executes CMD as a shell command
:!sh Fork shell in vi; hit ctrl-d to go back to vi

INSERTING
r replace character under cursor with next character typed
R keep replacing character until [esc] is hit
i insert before cursor
I insert from the beginning of line
a append after cursor
A append at end of line
o open line below cursor and enter append mode
O open line above cursor and enter append mode
c change until . "cc" changes the current line
C change to the end of line from the current cursor position
s substitute one character under the cursor and go into insert mode
S change an entire line


Screen Movement
G move to the last line in the file
xG move to line x
z+ move current line to top of screen
z move current line to the middle of screen
z- move current line to the bottom of screen
^F move forward one screen
^B move backward one line
^D move forward one half screen
^U move backward one half screen
^R redraw screen (does not work with vt100 type terminals)
^L redraw screen (does not work with Televideo terminals)

Cursor Movement
h move left
j move down
k move up
l move right
[return] move to the beginning of next line
$ last column on the current line
0 move cursor to the first column on the current line
^ move cursor to the first nonblank column on the current line
w move to the beginning of the previous word or punctuation
W move past the next space
b move to the beginning of the previous word or punctuation mark
B move to the beginning of the previous word, ignores punctuation
e end of next word or punctuation mark
E end of next word, ignoring punctuation
H move cursor to the top of the screen
M move cursor to the middle of the screen
L move cursor to the bottom of the screen
^H move cursor one space to the left
^J move cursor down one line in same column
^M move to the first character on the next line
^N move cursor down one line in same column
^P move cursor up one line in same column
% move cursor to the matching parenthesis or brace
( move cursor to the beginning of a sentence
) move cursor to the beginning of the next sentence
{ move cursor to the preceding paragraph
} move cursor to the next paragraph
| move cursor to the column specified by the count
+ move cursor to the first non-whitespace character in the next line
- move cursor to the first non-whitespace character in the previous line
_ move cursor to the first non-whitespace character in the current line