Mapping keys in vi editor

maping key in vi is very helpful to avoid repeat set of command. you can make a map of multiple commands on a single key 

 

EXAMPLE::

 

HTML FILE ::

1:.tableHdr{border-top:.5pt solid windowtext;border-right:none;border-bottom:.5pt solid windowtext;border-left:.5pt solid windowtext;}

2:.rowSpanLeg{width:1.0em;border-top:none;border-right:none;border-bottom:none;border-left:.5pt solid windowtext;}

 3:.tableCell{border-top:.5pt solid windowtext;border-right:none;border-bottom:none;border-left:.5pt solid windowtext;}            

4:.tblCell{border-top:.5pt solid windowtext;border-right:none;border-bottom:.5pt solid windowtext;border-left:.5pt solid windowtext;}

 

you want separate curly braces in next lines then instead of repeat steps you can make map and 

can apply to every line.

 

Command to  make map on q key:

    :map q :.,.s/{/{\r/g<CR>:.,.s/}/\r}/g<CR>

 

 

Use: 

    in command line mode (By press esc key) enter q key on each line

 

 

Output:

    .tableHdr{

border-top:.5pt solid windowtext;border-right:none;border-bottom:.5pt solid windowtext;border-left:.5pt solid windowtext;

}

.rowSpanLeg{

width:1.0em;border-top:none;border-right:none;border-bottom:none;border-left:.5pt solid windowtext;

}

 .tableCell{

border-top:.5pt solid windowtext;border-right:none;border-bottom:none;border-left:.5pt solid windowtext;}            .

tblCell{

border-top:.5pt solid windowtext;border-right:none;border-bottom:.5pt solid windowtext;border-left:.5pt solid windowtext;

}

Comments