How to hardcode Zebra label substitution in this script? - zebra-printers

I am familiar with some label formatting but having an issue with this task. In the image, there is a table that should populate in the middle area when there are locations (up to 10), with columns for location, size description, TOT To SER, Description, and UN Number. I need to hardcode some values so I can see them in a ZPL viewer and mess with the formatting. How can I hardcode those values so I see atleast the row for location_1 with table borders? Thanks in advance for any help! I know the code is long but I think I just need to hardcode the location_1 body the middle of the code to anything. Like LOCATIONXYZ
#parse("version.vm")
#if ($PrintMode == "Bartender" || $PrintMode == "MarkMagic")
^XA~TA000~JSN^LT0^MNW^MTT^PON^PMN^LH0,0^JMA^PR2,2~SD15^JUS^LRN^CI0^XZ
^XA
^MMT
## crtncnts.vm - Carton Content Label (6x8 inches 203 dpi)
## in:
## /appli/manh/wms/profile-root/runtime/data/labels/ZE1
## /appli/manh/wms/distribution/data/labels/ZE1
## version:
^FX crtncnts.vm - 2017/09/07 - v4.1 ^FS
## change:
## 2017/08/29 - v3.1 - add comments and versionning
## 2017/09/06 - v3.2 - change of date format
## 2017/09/07 - v4.0 - suppression of "origin" column + set "UN Number" column to cust_sku_n
## 2017/09/07 - v4.1 - use of $vendor_item_nbr_n instead of $cust_sku_n in "UN Number" column
## Label size for 203 dpi (with 6+6 margin space)
^PW1224
^LL1632
## Framework (origin is 33x33)
^FO33,33^GB1167,1567,7^FS ^FX Global frame ^FS
^FO160,33^GB220,527,7^FS ^FX Bloc 4 (right) ^FS
^FO160,553^GB220,527,7^FS ^FX Bloc 3 (middle) ^FS
^FO160,1073^GB220,527,7^FS ^FX Bloc 2 (left) ^FS
^FO953,33^GB247,1567,7^FS ^FX Bloc 6 (footer) ^FS
## Blocs in read direction
## Bloc 1 (header)
^FT120,547^A0B,67,60^FB487,1,0,R^FD$!{carton_nbr}^FS
^FT120,1073^A0B,67,60^FB520,1,0,C^FDPicking List^FS
^FT107,1573^A0B,33,31^FC%,#,*^FD%m/%d/%Y %H:%M:%S^FS
## Bloc 2 (left)
^FT200,1573^A0B,33,31^FDCustomer:^FS
^FT247,1553^A0B,33,31^FD$!{d_facility_name}^FS
#set ($Max_NbChar=31) #if ($!{ship_to_name.length()} > $Max_NbChar) #set ($ship_to_name=$ship_to_name.substring(0,$Max_NbChar)) #end
^FT287,1553^A0B,33,31^FD$!{ship_to_name}^FS
## Bloc 3 (middle)
^FT200,1053^A0B,33,31^FDConstituting a Parcel: $!{carton_type}^FS
#set ($Max_NbChar=14) #if ($!{orders_ref_field3.length()} > $Max_NbChar) #set ($orders_ref_field3=$orders_ref_field3.substring(0,$Max_NbChar))
#end
^FT247,1053^A0B,33,31^FDType of Shipment: $!{orders_ref_field3}^FS
## Bloc 4 (right)
#set ($Max_NbChar=18) #if ($!{po_nbr.length()} > $Max_NbChar) #set ($po_nbr=$po_nbr.substring(0,$Max_NbChar)) #end
^FT200,540^A0B,33,31^FDOrder Number: $!{po_nbr}^FS
^FT247,540^A0B,33,31^FDDelivery Number: $!{distro_number}^FS
^FT333,520^BY3,3,73^BCB,,Y,N^FD>:$!{distro_number}^FS
## Bloc 5 (list): columns are ordered A to E in reading direction
## Bloc 5 (list): header framework (FWK)
#set($FWK_Offset_x=387)
#set($FWK_Offset_y_E=53)
#set($FWK_Offset_y_D=253)
#set($FWK_Offset_y_C=1013)
#set($FWK_Offset_y_B=1160)
#set($FWK_Offset_y_A=1373)
#set($FWK_Size_x=53)
#set($FWK_Size_y_E=203)
#set($FWK_Size_y_D=762)
#set($FWK_Size_y_C=149)
#set($FWK_Size_y_B=216)
#set($FWK_Size_y_A=209)
#set($FWK_Thickness=3)
^FO$FWK_Offset_x,$FWK_Offset_y_E ^GB$FWK_Size_x,$FWK_Size_y_E,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_D ^GB$FWK_Size_x,$FWK_Size_y_D,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_C ^GB$FWK_Size_x,$FWK_Size_y_C,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_B ^GB$FWK_Size_x,$FWK_Size_y_B,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_A ^GB$FWK_Size_x,$FWK_Size_y_A,$FWK_Thickness ^FS
## Bloc 5 (list): header content (CNT)
#set($CNT_size_x=23)
#set($CNT_Size_y=21)
#set($CNT_Offset_y_E=240)
#set($CNT_Offset_y_D=999)
#set($CNT_Offset_y_C=1146)
#set($CNT_Offset_y_B=1360)
#set($CNT_Offset_y_A=1567)
#set($CNT_offset_x=420)
^FT$CNT_offset_x,$CNT_Offset_y_E ^A0B,$CNT_size_x,$CNT_Size_y ^FDUN_Number^FS
^FT$CNT_offset_x,$CNT_Offset_y_D ^A0B,$CNT_size_x,$CNT_Size_y ^FDDescription^FS
^FT$CNT_offset_x,$CNT_Offset_y_C ^A0B,$CNT_size_x,$CNT_Size_y ^FDTOT TO SER^FS
^FT$CNT_offset_x,$CNT_Offset_y_B ^A0B,$CNT_size_x,$CNT_Size_y ^FDSize Description^FS
^FT$CNT_offset_x,$CNT_Offset_y_A ^A0B,$CNT_size_x,$CNT_Size_y ^FDLocation^FS
## Max number of character for each column (ordered A to E in reading direction)
#set($Max_NbChar_E=16)
#set($Max_NbChar_D=64)
#set($Max_NbChar_C=11)
#set($Max_NbChar_B=17)
#set($Max_NbChar_A=17)
## Shift between each line (Step)
#set($Step=51)
## Bloc 5 (list): line 1
#if ($location_1)
#set($FWK_Offset_x=$FWK_Offset_x+$Step)
^FO$FWK_Offset_x,$FWK_Offset_y_E ^GB$FWK_Size_x,$FWK_Size_y_E,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_D ^GB$FWK_Size_x,$FWK_Size_y_D,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_C ^GB$FWK_Size_x,$FWK_Size_y_C,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_B ^GB$FWK_Size_x,$FWK_Size_y_B,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_A ^GB$FWK_Size_x,$FWK_Size_y_A,$FWK_Thickness ^FS
#set($CNT_offset_x=$CNT_offset_x+$Step)
#if ($!{vendor_item_nbr_1.length()} > $Max_NbChar_E) #set ($vendor_item_nbr_1=$vendor_item_nbr_1.substring(0,$Max_NbChar_E)) #end
#if ($!{sku_desc_1.length()} > $Max_NbChar_D) #set ($sku_desc_1=$sku_desc_1.substring(0,$Max_NbChar_D)) #end
#if ($!{qty_1.length()} > $Max_NbChar_C) #set ($qty_1=$qty_1.substring(0,$Max_NbChar_C)) #end
#if ($!{dsp_sku_1.length()} > $Max_NbChar_B) #set ($dsp_sku_1=$dsp_sku_1.substring(0,$Max_NbChar_B)) #end
#if ($!{location_1.length()} > $Max_NbChar_A) #set ($location_1=$location_1.substring(0,$Max_NbChar_A)) #end
^FT$CNT_offset_x,$CNT_Offset_y_E ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{vendor_item_nbr_1}^FS
^FT$CNT_offset_x,$CNT_Offset_y_D ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{sku_desc_1}^FS
^FT$CNT_offset_x,$CNT_Offset_y_C ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{qty_1}^FS
^FT$CNT_offset_x,$CNT_Offset_y_B ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{dsp_sku_1}^FS
^FT$CNT_offset_x,$CNT_Offset_y_A ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{location_1}^FS
#end
## Bloc 5 (list): line 2
#if ($location_2)
#set($FWK_Offset_x=$FWK_Offset_x+$Step)
^FO$FWK_Offset_x,$FWK_Offset_y_E ^GB$FWK_Size_x,$FWK_Size_y_E,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_D ^GB$FWK_Size_x,$FWK_Size_y_D,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_C ^GB$FWK_Size_x,$FWK_Size_y_C,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_B ^GB$FWK_Size_x,$FWK_Size_y_B,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_A ^GB$FWK_Size_x,$FWK_Size_y_A,$FWK_Thickness ^FS
#set($CNT_offset_x=$CNT_offset_x+$Step)
#if ($!{vendor_item_nbr_2.length()} > $Max_NbChar_E) #set ($vendor_item_nbr_2=$vendor_item_nbr_2.substring(0,$Max_NbChar_E)) #end
#if ($!{sku_desc_2.length()} > $Max_NbChar_D) #set ($sku_desc_2=$sku_desc_2.substring(0,$Max_NbChar_D)) #end
#if ($!{qty_2.length()} > $Max_NbChar_C) #set ($qty_2=$qty_2.substring(0,$Max_NbChar_C)) #end
#if ($!{dsp_sku_2.length()} > $Max_NbChar_B) #set ($dsp_sku_2=$dsp_sku_2.substring(0,$Max_NbChar_B)) #end
#if ($!{location_2.length()} > $Max_NbChar_A) #set ($location_2=$location_2.substring(0,$Max_NbChar_A)) #end
^FT$CNT_offset_x,$CNT_Offset_y_E ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{vendor_item_nbr_2}^FS
^FT$CNT_offset_x,$CNT_Offset_y_D ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{sku_desc_2}^FS
^FT$CNT_offset_x,$CNT_Offset_y_C ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{qty_2}^FS
^FT$CNT_offset_x,$CNT_Offset_y_B ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{dsp_sku_2}^FS
^FT$CNT_offset_x,$CNT_Offset_y_A ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{location_2}^FS
#end
## Bloc 5 (list): line 3
#if ($location_3)
#set($FWK_Offset_x=$FWK_Offset_x+$Step)
^FO$FWK_Offset_x,$FWK_Offset_y_E ^GB$FWK_Size_x,$FWK_Size_y_E,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_D ^GB$FWK_Size_x,$FWK_Size_y_D,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_C ^GB$FWK_Size_x,$FWK_Size_y_C,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_B ^GB$FWK_Size_x,$FWK_Size_y_B,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_A ^GB$FWK_Size_x,$FWK_Size_y_A,$FWK_Thickness ^FS
#set($CNT_offset_x=$CNT_offset_x+$Step)
#if ($!{vendor_item_nbr_3.length()} > $Max_NbChar_E) #set ($vendor_item_nbr_3=$vendor_item_nbr_3.substring(0,$Max_NbChar_E)) #end
#if ($!{sku_desc_3.length()} > $Max_NbChar_D) #set ($sku_desc_3=$sku_desc_3.substring(0,$Max_NbChar_D)) #end
#if ($!{qty_3.length()} > $Max_NbChar_C) #set ($qty_3=$qty_3.substring(0,$Max_NbChar_C)) #end
#if ($!{dsp_sku_3.length()} > $Max_NbChar_B) #set ($dsp_sku_3=$dsp_sku_3.substring(0,$Max_NbChar_B)) #end
#if ($!{location_3.length()} > $Max_NbChar_A) #set ($location_3=$location_3.substring(0,$Max_NbChar_A)) #end
^FT$CNT_offset_x,$CNT_Offset_y_E ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{vendor_item_nbr_3}^FS
^FT$CNT_offset_x,$CNT_Offset_y_D ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{sku_desc_3}^FS
^FT$CNT_offset_x,$CNT_Offset_y_C ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{qty_3}^FS
^FT$CNT_offset_x,$CNT_Offset_y_B ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{dsp_sku_3}^FS
^FT$CNT_offset_x,$CNT_Offset_y_A ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{location_3}^FS
#end
## Bloc 5 (list): line 4
#if ($location_4)
#set($FWK_Offset_x=$FWK_Offset_x+$Step)
^FO$FWK_Offset_x,$FWK_Offset_y_E ^GB$FWK_Size_x,$FWK_Size_y_E,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_D ^GB$FWK_Size_x,$FWK_Size_y_D,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_C ^GB$FWK_Size_x,$FWK_Size_y_C,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_B ^GB$FWK_Size_x,$FWK_Size_y_B,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_A ^GB$FWK_Size_x,$FWK_Size_y_A,$FWK_Thickness ^FS
#set($CNT_offset_x=$CNT_offset_x+$Step)
#if ($!{vendor_item_nbr_4.length()} > $Max_NbChar_E) #set ($vendor_item_nbr_4=$vendor_item_nbr_4.substring(0,$Max_NbChar_E)) #end
#if ($!{sku_desc_4.length()} > $Max_NbChar_D) #set ($sku_desc_4=$sku_desc_4.substring(0,$Max_NbChar_D)) #end
#if ($!{qty_4.length()} > $Max_NbChar_C) #set ($qty_4=$qty_4.substring(0,$Max_NbChar_C)) #end
#if ($!{dsp_sku_4.length()} > $Max_NbChar_B) #set ($dsp_sku_4=$dsp_sku_4.substring(0,$Max_NbChar_B)) #end
#if ($!{location_4.length()} > $Max_NbChar_A) #set ($location_4=$location_4.substring(0,$Max_NbChar_A)) #end
^FT$CNT_offset_x,$CNT_Offset_y_E ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{vendor_item_nbr_4}^FS
^FT$CNT_offset_x,$CNT_Offset_y_D ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{sku_desc_4}^FS
^FT$CNT_offset_x,$CNT_Offset_y_C ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{qty_4}^FS
^FT$CNT_offset_x,$CNT_Offset_y_B ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{dsp_sku_4}^FS
^FT$CNT_offset_x,$CNT_Offset_y_A ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{location_4}^FS
#end
## Bloc 5 (list): line 5
#if ($location_5)
#set($FWK_Offset_x=$FWK_Offset_x+$Step)
^FO$FWK_Offset_x,$FWK_Offset_y_E ^GB$FWK_Size_x,$FWK_Size_y_E,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_D ^GB$FWK_Size_x,$FWK_Size_y_D,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_C ^GB$FWK_Size_x,$FWK_Size_y_C,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_B ^GB$FWK_Size_x,$FWK_Size_y_B,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_A ^GB$FWK_Size_x,$FWK_Size_y_A,$FWK_Thickness ^FS
#set($CNT_offset_x=$CNT_offset_x+$Step)
#if ($!{vendor_item_nbr_5.length()} > $Max_NbChar_E) #set ($vendor_item_nbr_5=$vendor_item_nbr_5.substring(0,$Max_NbChar_E)) #end
#if ($!{sku_desc_5.length()} > $Max_NbChar_D) #set ($sku_desc_5=$sku_desc_5.substring(0,$Max_NbChar_D)) #end
#if ($!{qty_5.length()} > $Max_NbChar_C) #set ($qty_5=$qty_5.substring(0,$Max_NbChar_C)) #end
#if ($!{dsp_sku_5.length()} > $Max_NbChar_B) #set ($dsp_sku_5=$dsp_sku_5.substring(0,$Max_NbChar_B)) #end
#if ($!{location_5.length()} > $Max_NbChar_A) #set ($location_5=$location_5.substring(0,$Max_NbChar_A)) #end
^FT$CNT_offset_x,$CNT_Offset_y_E ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{vendor_item_nbr_5}^FS
^FT$CNT_offset_x,$CNT_Offset_y_D ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{sku_desc_5}^FS
^FT$CNT_offset_x,$CNT_Offset_y_C ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{qty_5}^FS
^FT$CNT_offset_x,$CNT_Offset_y_B ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{dsp_sku_5}^FS
^FT$CNT_offset_x,$CNT_Offset_y_A ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{location_5}^FS
#end
## Bloc 5 (list): line 6
#if ($location_6)
#set($FWK_Offset_x=$FWK_Offset_x+$Step)
^FO$FWK_Offset_x,$FWK_Offset_y_E ^GB$FWK_Size_x,$FWK_Size_y_E,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_D ^GB$FWK_Size_x,$FWK_Size_y_D,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_C ^GB$FWK_Size_x,$FWK_Size_y_C,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_B ^GB$FWK_Size_x,$FWK_Size_y_B,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_A ^GB$FWK_Size_x,$FWK_Size_y_A,$FWK_Thickness ^FS
#set($CNT_offset_x=$CNT_offset_x+$Step)
#if ($!{vendor_item_nbr_6.length()} > $Max_NbChar_E) #set ($vendor_item_nbr_6=$vendor_item_nbr_6.substring(0,$Max_NbChar_E)) #end
#if ($!{sku_desc_6.length()} > $Max_NbChar_D) #set ($sku_desc_6=$sku_desc_6.substring(0,$Max_NbChar_D)) #end
#if ($!{qty_6.length()} > $Max_NbChar_C) #set ($qty_6=$qty_6.substring(0,$Max_NbChar_C)) #end
#if ($!{dsp_sku_6.length()} > $Max_NbChar_B) #set ($dsp_sku_6=$dsp_sku_6.substring(0,$Max_NbChar_B)) #end
#if ($!{location_6.length()} > $Max_NbChar_A) #set ($location_6=$location_6.substring(0,$Max_NbChar_A)) #end
^FT$CNT_offset_x,$CNT_Offset_y_E ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{vendor_item_nbr_6}^FS
^FT$CNT_offset_x,$CNT_Offset_y_D ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{sku_desc_6}^FS
^FT$CNT_offset_x,$CNT_Offset_y_C ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{qty_6}^FS
^FT$CNT_offset_x,$CNT_Offset_y_B ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{dsp_sku_6}^FS
^FT$CNT_offset_x,$CNT_Offset_y_A ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{location_6}^FS
#end
## Bloc 5 (list): line 7
#if ($location_7)
#set($FWK_Offset_x=$FWK_Offset_x+$Step)
^FO$FWK_Offset_x,$FWK_Offset_y_E ^GB$FWK_Size_x,$FWK_Size_y_E,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_D ^GB$FWK_Size_x,$FWK_Size_y_D,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_C ^GB$FWK_Size_x,$FWK_Size_y_C,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_B ^GB$FWK_Size_x,$FWK_Size_y_B,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_A ^GB$FWK_Size_x,$FWK_Size_y_A,$FWK_Thickness ^FS
#set($CNT_offset_x=$CNT_offset_x+$Step)
#if ($!{vendor_item_nbr_7.length()} > $Max_NbChar_E) #set ($vendor_item_nbr_7=$vendor_item_nbr_7.substring(0,$Max_NbChar_E)) #end
#if ($!{sku_desc_7.length()} > $Max_NbChar_D) #set ($sku_desc_7=$sku_desc_7.substring(0,$Max_NbChar_D)) #end
#if ($!{qty_7.length()} > $Max_NbChar_C) #set ($qty_7=$qty_7.substring(0,$Max_NbChar_C)) #end
#if ($!{dsp_sku_7.length()} > $Max_NbChar_B) #set ($dsp_sku_7=$dsp_sku_7.substring(0,$Max_NbChar_B)) #end
#if ($!{location_7.length()} > $Max_NbChar_A) #set ($location_7=$location_7.substring(0,$Max_NbChar_A)) #end
^FT$CNT_offset_x,$CNT_Offset_y_E ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{vendor_item_nbr_7}^FS
^FT$CNT_offset_x,$CNT_Offset_y_D ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{sku_desc_7}^FS
^FT$CNT_offset_x,$CNT_Offset_y_C ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{qty_7}^FS
^FT$CNT_offset_x,$CNT_Offset_y_B ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{dsp_sku_7}^FS
^FT$CNT_offset_x,$CNT_Offset_y_A ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{location_7}^FS
#end
## Bloc 5 (list): line 8
#if ($location_8)
#set($FWK_Offset_x=$FWK_Offset_x+$Step)
^FO$FWK_Offset_x,$FWK_Offset_y_E ^GB$FWK_Size_x,$FWK_Size_y_E,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_D ^GB$FWK_Size_x,$FWK_Size_y_D,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_C ^GB$FWK_Size_x,$FWK_Size_y_C,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_B ^GB$FWK_Size_x,$FWK_Size_y_B,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_A ^GB$FWK_Size_x,$FWK_Size_y_A,$FWK_Thickness ^FS
#set($CNT_offset_x=$CNT_offset_x+$Step)
#if ($!{vendor_item_nbr_8.length()} > $Max_NbChar_E) #set ($vendor_item_nbr_8=$vendor_item_nbr_8.substring(0,$Max_NbChar_E)) #end
#if ($!{sku_desc_8.length()} > $Max_NbChar_D) #set ($sku_desc_8=$sku_desc_8.substring(0,$Max_NbChar_D)) #end
#if ($!{qty_8.length()} > $Max_NbChar_C) #set ($qty_8=$qty_8.substring(0,$Max_NbChar_C)) #end
#if ($!{dsp_sku_8.length()} > $Max_NbChar_B) #set ($dsp_sku_8=$dsp_sku_8.substring(0,$Max_NbChar_B)) #end
#if ($!{location_8.length()} > $Max_NbChar_A) #set ($location_8=$location_8.substring(0,$Max_NbChar_A)) #end
^FT$CNT_offset_x,$CNT_Offset_y_E ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{vendor_item_nbr_8}^FS
^FT$CNT_offset_x,$CNT_Offset_y_D ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{sku_desc_8}^FS
^FT$CNT_offset_x,$CNT_Offset_y_C ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{qty_8}^FS
^FT$CNT_offset_x,$CNT_Offset_y_B ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{dsp_sku_8}^FS
^FT$CNT_offset_x,$CNT_Offset_y_A ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{location_8}^FS
#end
## Bloc 5 (list): line 9
#if ($location_9)
#set($FWK_Offset_x=$FWK_Offset_x+$Step)
^FO$FWK_Offset_x,$FWK_Offset_y_E ^GB$FWK_Size_x,$FWK_Size_y_E,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_D ^GB$FWK_Size_x,$FWK_Size_y_D,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_C ^GB$FWK_Size_x,$FWK_Size_y_C,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_B ^GB$FWK_Size_x,$FWK_Size_y_B,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_A ^GB$FWK_Size_x,$FWK_Size_y_A,$FWK_Thickness ^FS
#set($CNT_offset_x=$CNT_offset_x+$Step)
#if ($!{vendor_item_nbr_9.length()} > $Max_NbChar_E) #set ($vendor_item_nbr_9=$vendor_item_nbr_9.substring(0,$Max_NbChar_E)) #end
#if ($!{sku_desc_9.length()} > $Max_NbChar_D) #set ($sku_desc_9=$sku_desc_9.substring(0,$Max_NbChar_D)) #end
#if ($!{qty_9.length()} > $Max_NbChar_C) #set ($qty_9=$qty_9.substring(0,$Max_NbChar_C)) #end
#if ($!{dsp_sku_9.length()} > $Max_NbChar_B) #set ($dsp_sku_9=$dsp_sku_9.substring(0,$Max_NbChar_B)) #end
#if ($!{location_9.length()} > $Max_NbChar_A) #set ($location_9=$location_9.substring(0,$Max_NbChar_A)) #end
^FT$CNT_offset_x,$CNT_Offset_y_E ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{vendor_item_nbr_9}^FS
^FT$CNT_offset_x,$CNT_Offset_y_D ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{sku_desc_9}^FS
^FT$CNT_offset_x,$CNT_Offset_y_C ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{qty_9}^FS
^FT$CNT_offset_x,$CNT_Offset_y_B ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{dsp_sku_9}^FS
^FT$CNT_offset_x,$CNT_Offset_y_A ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{location_9}^FS
#end
## Bloc 5 (list): line 10
#if ($location_10)
#set($FWK_Offset_x=$FWK_Offset_x+$Step)
^FO$FWK_Offset_x,$FWK_Offset_y_E ^GB$FWK_Size_x,$FWK_Size_y_E,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_D ^GB$FWK_Size_x,$FWK_Size_y_D,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_C ^GB$FWK_Size_x,$FWK_Size_y_C,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_B ^GB$FWK_Size_x,$FWK_Size_y_B,$FWK_Thickness ^FS
^FO$FWK_Offset_x,$FWK_Offset_y_A ^GB$FWK_Size_x,$FWK_Size_y_A,$FWK_Thickness ^FS
#set($CNT_offset_x=$CNT_offset_x+$Step)
#if ($!{vendor_item_nbr_10.length()} > $Max_NbChar_E) #set ($vendor_item_nbr_10=$vendor_item_nbr_10.substring(0,$Max_NbChar_E)) #end
#if ($!{sku_desc_10.length()} > $Max_NbChar_D) #set ($sku_desc_10=$sku_desc_10.substring(0,$Max_NbChar_D)) #end
#if ($!{qty_10.length()} > $Max_NbChar_C) #set ($qty_10=$qty_10.substring(0,$Max_NbChar_C)) #end
#if ($!{dsp_sku_10.length()} > $Max_NbChar_B) #set ($dsp_sku_10=$dsp_sku_10.substring(0,$Max_NbChar_B)) #end
#if ($!{location_10.length()} > $Max_NbChar_A) #set ($location_10=$location_10.substring(0,$Max_NbChar_A)) #end
^FT$CNT_offset_x,$CNT_Offset_y_E ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{vendor_item_nbr_10}^FS
^FT$CNT_offset_x,$CNT_Offset_y_D ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{sku_desc_10}^FS
^FT$CNT_offset_x,$CNT_Offset_y_C ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{qty_10}^FS
^FT$CNT_offset_x,$CNT_Offset_y_B ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{dsp_sku_10}^FS
^FT$CNT_offset_x,$CNT_Offset_y_A ^A0B,$CNT_size_x,$CNT_Size_y ^FD$!{location_10}^FS
#end
## Bloc 6 (footer)
^FT993,1573^A0B,33,31^FDParcel #:^FS
^FT993,1453^A0B,33,31^FD$!{carton_nbr}^FS
^FT1087,1453^BY4,3,87^BCB,,Y,N^FD>:$!{carton_nbr}^FS
^FT1087,540^A0B,33,31^FDTheoretical weight: $!{Est_Wt} KgG^FS
^FT1167,1573^A0B,33,31^FDYour parcel was thoughtfully prepared by:^FS
^PQ1,0,1,Y
^XZ
#end
#*
__START_FIELD_LIST_BARTENDER__
carton_nbr
carton_type
current_date
current_time
d_facility_name
distro_nbr
distro_number
dsp_sku_1
dsp_sku_2
dsp_sku_3
dsp_sku_4
dsp_sku_5
dsp_sku_6
dsp_sku_7
dsp_sku_8
dsp_sku_9
dsp_sku_10
location_1
location_2
location_3
location_4
location_5
location_6
location_7
location_8
location_9
location_10
orders_ref_field3
po_nbr
qty_1
qty_2
qty_3
qty_4
qty_5
qty_6
qty_7
qty_8
qty_9
qty_10
ship_to_name
sku_desc_1
sku_desc_2
sku_desc_3
sku_desc_4
sku_desc_5
sku_desc_6
sku_desc_7
sku_desc_8
sku_desc_9
sku_desc_10
vendor_item_nbr_1
vendor_item_nbr_2
vendor_item_nbr_3
vendor_item_nbr_4
vendor_item_nbr_5
vendor_item_nbr_6
vendor_item_nbr_7
vendor_item_nbr_8
vendor_item_nbr_9
vendor_item_nbr_10
__END_FIELD_LIST_BARTENDER__
*#
Label Image

Just take the code you have, replace all the variables with actual values, and then it should work. Mess with it till you get what you want. Then replace all the hard coded values with the variables again.
All if the ZPL commands the printer reads start with ^XYa,b,c, where ^ is the command prefix, XY would be the command, and abc would be different variables. You can look up the ^XY commands in the ZPL guide from Zebra. Things like "$CNT_offset_x" need to be replace with numbers. And "$!{vendor_item_nbr_1}" with text.
You'd do yourself a HUGE favor if you made one "line" section, and put that in a loop, rather than 10 distinct line sections. Then in the loop, you could take the line height, and multiply that by the line number, and add the starting position. Use that for all the vertical positioning pixel counts. So much easier than positioning every variable. Then if you need to change something, you can change it once, rather than 10 times.

Related

Facing the problem with ENDIF in algorithm using latex

I want to use the IF else in my code using LaTeX. But I am unable to end the if-else. I have used the ENDIF and the commands like this \newcommand\sIf[2]{ \If{#1}#2\EndIf}. I want to print the END if at the end of the if-else. The following is the code and its output.
\documentclass[a4paper]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\begin{document}
\begin{algorithm}
\caption{Calculating Speed Using GPS}\label{alg1}
\begin{algorithmic}[1]
\State $distance\gets 0 $
\State $time\gets 0 $
\State $speedGPS \gets 0 $
\If{$location.hasSpeed()$}
\State $speedGPS\gets location.getSpeed()$
\Else
\State $speedGPS \gets dist / time$
\EndIf
\State $counter \gets (counter + 1) \% data_points$
\State $speedGPS \gets speedGPS * 3.6d$
\end{algorithmic}
\end{algorithm}
\end{document}
Drop the noend option you're passing to algpseudocode:
\documentclass{article}
\usepackage{algorithm,algpseudocode}
\begin{document}
\begin{algorithm}
\caption{Calculating Speed Using GPS}
\begin{algorithmic}[1]
\State $distance\gets 0 $
\State $time\gets 0 $
\State $speedGPS \gets 0 $
\If{$location.hasSpeed()$}
\State $speedGPS\gets location.getSpeed()$
\Else
\State $speedGPS \gets dist / time$
\EndIf
\State $counter \gets (counter + 1) \% data_points$
\State $speedGPS \gets speedGPS \times 3.6d$
\end{algorithmic}
\end{algorithm}
\end{document}

how to clean the text from emoticons using bash

Is there a way to remove anything that's not either a token, punctuation or a special character from text using awk or sed? What I really want to get rid off are the emoticons and the 󾌧 like symbols.
Sample input:
Si tú no estáss yo no voy a lloraar por tiii🎶🎶
Me respondes porfavor?? 😭❤ piensas venir a Ecuador
cosas veredes!!!! Ay Papá. 😂😂😂
👀 🔵🔴 what y'all know about this?
🇲🇽👑❤️‼️ 🇲🇽👑❤️‼️ tag they make the final decision 🇲🇽🙏🏼👑
Vähän on twiitattavaa muuta kuin että aijjai ja oijjoi sekä nannaa. 😉👍👏👏👏🇫🇮💕
Binta On est arrivé au chicken elle voulait pleuré carrément tellement elle était heureuse 😂😂😂😂😭
ja mir fällt nix mehr ein😂😂
Někdo v pátek semnou na flédu na Moju reč??? 󾌧
Sample output:
Si tú no estáss yo no voy a lloraar por tiii
Me respondes porfavor?? piensas venir a Ecuador
cosas veredes!!!! Ay Papá.
what y'all know about this?
‼️ ‼️ tag they make the final decision
Vähän on twiitattavaa muuta kuin että aijjai ja oijjoi sekä nannaa.
Binta On est arrivé au chicken elle voulait pleuré carrément tellement elle était heureuse
ja mir fällt nix mehr ein
Někdo v pátek semnou na flédu na Moju reč???
My best solution is using Python, the Python file must be in UTF-8.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
text = u"""Si tú no estáss yo no voy a lloraar por tiii🎶🎶
Me respondes porfavor?? 😭❤ piensas venir a Ecuador
cosas veredes!!!! Ay Papá. 😂😂😂
👀 🔵🔴 what y'all know about this?
🇲🇽👑❤️‼️ 🇲🇽👑❤️‼️ tag they make the final decision 🇲🇽🙏🏼👑
Vähän on twiitattavaa muuta kuin että aijjai ja oijjoi sekä nannaa. 😉👍👏👏👏🇫🇮💕
Binta On est arrivé au chicken elle voulait pleuré carrément tellement elle était heureuse 😂😂😂😂😭
ja mir fällt nix mehr ein😂😂
Někdo v pátek semnou na flédu na Moju reč???
"""
emoji_pattern = re.compile(
"["
u"\U0001F600-\U0001F64F" # emoticons
u"\U0001F300-\U0001F5FF" # symbols & pictographs
u"\U0001F680-\U0001F6FF" # transport & map symbols
u"\U0001F1E0-\U0001F1FF" # flags (iOS)
u"\U00002760-\U0000276F" # emoticons
"]+", flags=re.UNICODE
)
print(emoji_pattern.sub(r'', text))
Out
Si tú no estáss yo no voy a lloraar por tiii
Me respondes porfavor?? piensas venir a Ecuador
cosas veredes!!!! Ay Papá.
what y'all know about this?
‼️ ️‼️ tag they make the final decision
Vähän on twiitattavaa muuta kuin että aijjai ja oijjoi sekä nannaa.
Binta On est arrivé au chicken elle voulait pleuré carrément tellement elle était heureuse
ja mir fällt nix mehr ein
Někdo v pátek semnou na flédu na Moju reč???
This command will remove every character that is not alphabetic, numeric, punctuation or white space:
sed 's/[^[:alnum:][:punct:][:space:]]//g' input
Limitation: Note that some of those funny characters that you see might be valid unicode alphabetic characters for which your computer lacks an installed font. This won't remove them.
How it works
[:alnum:], [:punct:], and [:space:] are character classes that match, respectively any alphanumeric, punctuation, or white space character. The regex [^[:alnum:][:punct:][:space:]] matches any character that does not belong to one of those three classes. The sed substitution command s/[^[:alnum:][:punct:][:space:]]//g does global search-and-replace that finds any character not in one of those classes and replaces it with nothing, that is, removes it.
You might be able to use tr:
% tr -dc '[:print:]' < emoji.txt
Si t no estss yo no voy a lloraar por tiiiMe respondes porfavor?? piensas venir a Ecuadorcosas veredes!!!! Ay Pap. what y'all know about this? tag they make the final decision Vhn on twiitattavaa muuta kuin ett aijjai ja oijjoi sek nannaa. Binta On est arriv au chicken elle voulait pleur carrment tellement elle tait heureuse ja mir fllt nix mehr einNkdo v ptek semnou na fldu na Moju re???
As you can see this will also remove newline characters, this can be prevented with:
% tr -dc '[:print:]\n' < emoji.txt
Si t no estss yo no voy a lloraar por tiii
Me respondes porfavor?? piensas venir a Ecuador
cosas veredes!!!! Ay Pap.
what y'all know about this?
tag they make the final decision
Vhn on twiitattavaa muuta kuin ett aijjai ja oijjoi sek nannaa.
Binta On est arriv au chicken elle voulait pleur carrment tellement elle tait heureuse
ja mir fllt nix mehr ein
Nkdo v ptek semnou na fldu na Moju re???

Split a text file if two consecutive lines almost identical

I need to split a text file (using a .bat command) based on the content of the string of the previous line (from position 2 to 13) and the content of the string of the current line (from position 2 to 13)...
I explain:
My file looks like that:
IA1234567890A XX33 AZE
bla1 XX34 DES
bla2 XX34 DES
bla3 XX34 DES
FA1234567890A XX35 AZE
IA1234567890A XX36 AZE
bla4 XX34 DES
bla5 XX34 DES
bla6 XX34 DES
FA1234567890A XX37 AZE
IB0987654321A XX38 AZE
bla7 XX34 DES
bla8 XX34 DES
bla9 XX34 DES
FB0987654321A XX39 AZE
I want to split the file when the first 12 characters of one line starting with "I" (without taking into account the "I") are different than the first 12 characters of the previous line (which is always starting with a "F" except for the first line, but the comparison should not take into account the "F").
So I would not split the file between these two lines:
FA1234567890A XX35 AZE
IA1234567890A XX36 AZE
but I would split the file between these two lines:
FA1234567890A XX37 AZE
IB0987654321A XX38 AZE
I know how to split a file using a delimiter, but I am totally lost with this comparison thing...
I would really appreciate if one of you could help me of this tricky case...
Thanks!
This reads from data.txt and creates output1.txt, output2.txt, ... outputn.txt:
#echo off
setlocal enabledelayedexpansion
set outputcount=0
set previousblock=
for /f "delims=" %%s in (data.txt) do (
set line=%%s
set currentblock=!line:~1,13!
if "!line:~0,1!" EQU "I" (
if "!previousblock!" NEQ "!currentblock!" (
set /A outputcount=!outputcount!+1
)
)
echo !line!>>output!outputcount!.txt
set previousblock=!currentblock!
)
e.g.
D:\scripts>splitfile.bat
D:\scripts>type output*
output1.txt
IA1234567890A XX33 AZE
bla1 XX34 DES
bla2 XX34 DES
bla3 XX34 DES
FA1234567890A XX35 AZE
IA1234567890A XX36 AZE
bla4 XX34 DES
bla5 XX34 DES
bla6 XX34 DES
FA1234567890A XX37 AZE
output2.txt
IB0987654321A XX38 AZE
bla7 XX34 DES
bla8 XX34 DES
bla9 XX34 DES
FB0987654321A XX39 AZE
Edit
updated code to make it work.
If the input file is large, this method should run faster because it does not check all the lines. It also correctly process lines with special Batch characters.
#echo off
setlocal EnableDelayedExpansion
rem Read the first line, and create a dummy previous "endLine" with same name
set /P "endName=" < test.txt
set "endName=F%endName:~1%"
set startLine=1
set "startName="
rem Redirect the input file to a code block, in order to read it
< test.txt (
rem Locate all lines that start with "I" or "F"
for /F "tokens=1,2 delims=: " %%a in ('findstr /N /B "I F" test.txt') do (
if not defined startName (
set "startName=%%b"
if "!startName:~1,12!" neq "!endName:~1,12!" (
rem New section starts: copy it to its own file
set /A lines=endLine-startLine+1
(for /L %%i in (1,1,!lines!) do (
set /P "line="
echo !line!
)) > "Part !endName:~1,12!.txt"
set "endName=F%startName:~1%"
set "startLine=%%a"
)
) else (
set "endLine=%%a"
set "endName=%%b"
set "startName="
)
)
rem Copy last section to its own file
findstr "^" > "Part !endName:~1,12!.txt"
)
Output:
C:\> type Part*.txt
Part A1234567890A.txt
IA1234567890A XX33 AZE
bla1 XX34 DES
bla2 XX34 DES
bla3 XX34 DES
FA1234567890A XX35 AZE
IA1234567890A XX36 AZE
bla4 XX34 DES
bla5 XX34 DES
bla6 XX34 DES
FA1234567890A XX37 AZE
Part B0987654321A.txt
IB0987654321A XX38 AZE
bla7 XX34 DES
bla8 XX34 DES
bla9 XX34 DES
FB0987654321A XX39 AZE
Try this:
#!/bin/sh
## clean any split files (got created in previous runs)
rm split.*;
## define variables, ct=counter for reading next line, cnt=counter for creating split.X file and file=split filename
ct=2
cnt=1
file="split.$cnt";
## Read line with spaces, IFS=''
IFS=''
while read lineP
do
## Read next line and increment ct variable
lineN="$(sed -n "${ct}p" inputfile.txt)" && ((ct++))
## Read first character of two lines and the next 12 characters
lineP121=${lineP:0:1} && lineN121=${lineN:0:1}
lineP1212=${lineP:1:12} && lineN1212=${lineN:1:12}
## Match / Condition
if [[ "$lineP1212" != "$lineN1212" && ( "$lineP121" == "F" && "$lineN121" == "I" ) ]];
then
echo "${lineP}:" >> $file;
((++cnt));
file="split.$cnt";
else
echo -e "$lineP\n" >> $file;
fi
done < inputfile.txt
echo -e "\n\nFile created are (with contents in split.X files):\n\n"
ls -l split.* && echo && grep -n . split.* && echo
Output is: No. of files created 2 split.1 and split.2 files (as per the inputfile).
File created are (with contents in split.X files. Output generated by grep -n command. You can use simple cat command if you want):
-rw-r--r-- 1 koba loki 450 Jun 3 19:01 split.1
-rw-r--r-- 1 koba loki 225 Jun 3 19:01 split.2
split.1:1:IA1234567890A XX33 AZE
split.1:3:bla1 XX34 DES
split.1:5:bla2 XX34 DES
split.1:7:bla3 XX34 DES
split.1:9:FA1234567890A XX35 AZE
split.1:11:IA1234567890A XX36 AZE
split.1:13:bla4 XX34 DES
split.1:15:bla5 XX34 DES
split.1:17:bla6 XX34 DES
split.1:19:FA1234567890A XX37 AZE:
split.2:1:IB0987654321A XX38 AZE
split.2:3:bla7 XX34 DES
split.2:5:bla8 XX34 DES
split.2:7:bla9 XX34 DES
split.2:9:FB0987654321A XX39 AZE

How to format text file as it can be seen in man pages (justifying text, nothing more) using bash

What I would like to do is the following.
Text file content :
This is a simple text file
containing lines of text
with different width
but I would like to justify
them. Any idea ?
Expected result :
This is a simple text file containing
lines of text with different width
but I would like to justify them.
Any Idea ?
I already can split my files at the required width using :
cat textfile|fmt -s -w 37
But in that case, there is no justification...
EDIT : Using par as suggested, I found a problem with accented chars.
This is what gives par 37j1 for me :
This is à simplé text file
containing lines of tèxt with
different wïdth but I woùld like to
justîfy them. Any idéà ?
Not justified anymore... But spaces are altered anyway...
Thanks for your help,
Slander
You can employ nroff as using it man.
(echo '.ll 37'
echo '.pl 0'
cat orig.txt) | nroff
from your input produces:
This is a simple text file containing
lines of text with different width
but I would like to justify them. Any
idea ?
The above WORKS ONLY WITH ASCII.
EDIT
If you want handle utf8 text with a nroff, you can try the next:
cat orig.txt | ( #yes, i know - UUOC
echo '.ll 37' #line length
echo '.pl 0' #page length (0-disables empty lines)
echo '.nh' #no hypenation
preconv -e utf8 -
) | groff -Tutf8
From this utf8 encoded input:
Voix ambiguë d'un cœur qui au zéphyr préfère les jattes de kiwi.
Voyez le brick géant que j'examine près du wharf.
Monsieur Jack, vous dactylographiez bien mieux que votre ami Wolf.
Eble ĉiu kvazaŭ-deca fuŝĥoraĵo ĝojigos homtipon..
Laŭ Ludoviko Zamenhof bongustas freŝa ĉeĥa manĝaĵo kun spicoj.
Nechť již hříšné saxofony ďáblů rozezvučí síň úděsnými tóny waltzu, tanga a
quickstepu.
produces:
Voix ambiguë d’un cœur qui au zéphyr
préfère les jattes de kiwi. Voyez le
brick géant que j’examine près du
wharf. Monsieur Jack, vous
dactylographiez bien mieux que votre
ami Wolf. Eble ĉiu kvazaŭ‐deca
fuŝĥoraĵo ĝojigos homtipon.. Laŭ
Ludoviko Zamenhof bongustas freŝa
ĉeĥa manĝaĵo kun spicoj. Nechť již
hříšné saxofony ďáblů rozezvučí síň
úděsnými tóny waltzu, tanga a
quickstepu.
If you delete the line
echo '.nh' #no hypenation
you will get hypenated text
Voix ambiguë d’un cœur qui au zéphyr
préfère les jattes de kiwi. Voyez le
brick géant que j’examine près du
wharf. Monsieur Jack, vous dactylo‐
graphiez bien mieux que votre ami
Wolf. Eble ĉiu kvazaŭ‐deca fuŝĥoraĵo
ĝojigos homtipon.. Laŭ Ludoviko Za‐
menhof bongustas freŝa ĉeĥa manĝaĵo
kun spicoj. Nechť již hříšné saxo‐
fony ďáblů rozezvučí síň úděsnými
tóny waltzu, tanga a quickstepu.
You could use par:
par -j -w37 < inputfile
The -j option would justify paragraphs.
-w denotes max output line length.
For your input, it'd produce:
This is a simple text file containing
lines of text with different width
but I would like to justify them. Any
idea ?
An alternative would be to use emacs:
emacs -batch inputfile --eval '(set-fill-column 37)' --eval '(fill-region (point-min) (point-max))' -f save-buffer
This would also produce:
This is a simple text file containing
lines of text with different width
but I would like to justify them. Any
idea ?

Why ctags doesn't work for me?

I try to work with ctags and it simply doesn't work.
I follow this screencast : http://www.youtube.com/watch?v=4f3AENLrdYo. When I press Ctrl + ], it does not matter.
This is my .vimrc :
" vim:set ts=2 sts=2 sw=2 expandtab:
call pathogen#runtime_append_all_bundles()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" BASIC EDITING CONFIGURATION
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
scriptencoding utf-8
set encoding=utf-8
set fileencoding=utf-8
set number
set nocompatible
" allow unsaved background buffers and remember marks/undo for them
set hidden
" remember more commands and search history
set history=10000
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
set autoindent
set laststatus=2
set showmatch
set incsearch
set hlsearch
" make searches case-sensitive only if they contain upper-case characters
set ignorecase smartcase
" highlight current line
set cursorline
set cmdheight=2
set switchbuf=useopen
set numberwidth=5
set showtabline=2
set winwidth=85
set shell=bash
" Prevent Vim from clobbering the scrollback buffer. See
" http://www.shallowsky.com/linux/noaltscreen.html
set t_ti= t_te=
" keep more context when scrolling off the end of a buffer
set scrolloff=3
" Store temporary files in a central spot
set backup
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" display incomplete commands
set showcmd
" Enable highlighting for syntax
syntax on
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" use emacs-style tab completion when selecting files, etc
set wildmode=longest,list
" make tab completion for files/buffers act like bash
set wildmenu
let mapleader=","
let g:ctrlp_max_height = 40
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" CUSTOM AUTOCMDS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
augroup vimrcEx
" Clear all autocmds in the group
autocmd!
autocmd FileType text setlocal textwidth=78
" Jump to last cursor position unless it's invalid or in an event handler
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
"for ruby, autoindent with two spaces, always expand tabs
autocmd FileType ruby,haml,eruby,yaml,html,javascript,sass,cucumber set ai sw=2 sts=2 et
autocmd FileType python set sw=4 sts=4 et
autocmd! BufRead,BufNewFile *.sass setfiletype sass
autocmd BufRead *.mkd set ai formatoptions=tcroqn2 comments=n:>
autocmd BufRead *.markdown set ai formatoptions=tcroqn2 comments=n:>
" Indent p tags
autocmd FileType html,eruby if g:html_indent_tags !~ '\\|p\>' | let g:html_indent_tags .= '\|p\|li\|dt\|dd' | endif
" Don't syntax highlight markdown because it's often wrong
autocmd! FileType mkd setlocal syn=off
augroup END
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" COLOR
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
:set t_Co=256 " 256 colors
:set background=dark
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" STATUS LINE
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
:set statusline=%<%f\ (%{&ft})\ %-4(%m%)%=%-19(%3l,%02c%03V%)
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" MISC KEY MAPS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <leader>y "*y
" Move around splits with <c-hjkl>
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
" Insert a hash rocket with <c-l>
imap <c-l> <space>=><space>
" Can't be bothered to understand ESC vs <c-c> in insert mode
imap <c-c> <esc>
" Clear the search buffer when hitting return
:nnoremap <CR> :nohlsearch<cr>
nnoremap <leader><leader> <c-^>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ARROW KEYS ARE UNACCEPTABLE
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <Left> :echo "no!"<cr>
map <Right> :echo "no!"<cr>
map <Up> :echo "no!"<cr>
map <Down> :echo "no!"<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" MULTIPURPOSE TAB KEY
" Indent if we're at the beginning of a line. Else, do completion.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
inoremap <s-tab> <c-n>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" OPEN FILES IN DIRECTORY OF CURRENT FILE
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
cnoremap %% <C-R>=expand('%:h').'/'<cr>
map <leader>e :edit %%
map <leader>v :view %%
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" RENAME CURRENT FILE
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! RenameFile()
let old_name = expand('%')
let new_name = input('New file name: ', expand('%'), 'file')
if new_name != '' && new_name != old_name
exec ':saveas ' . new_name
exec ':silent !rm ' . old_name
redraw!
endif
endfunction
map <leader>n :call RenameFile()<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" PROMOTE VARIABLE TO RSPEC LET
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! PromoteToLet()
:normal! dd
" :exec '?^\s*it\>'
:normal! P
:.s/\(\w\+\) = \(.*\)$/let(:\1) { \2 }/
:normal ==
endfunction
:command! PromoteToLet :call PromoteToLet()
:map <leader>p :PromoteToLet<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" EXTRACT VARIABLE (SKETCHY)
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! ExtractVariable()
let name = input("Variable name: ")
if name == ''
return
endif
" Enter visual mode (not sure why this is needed since we're already in
" visual mode anyway)
normal! gv
" Replace selected text with the variable name
exec "normal c" . name
" Define the variable on the line above
exec "normal! O" . name . " = "
" Paste the original selected text to be the variable value
normal! $p
endfunction
vnoremap <leader>rv :call ExtractVariable()<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" INLINE VARIABLE (SKETCHY)
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! InlineVariable()
" Copy the variable under the cursor into the 'a' register
:let l:tmp_a = #a
:normal "ayiw
" Delete variable and equals sign
:normal 2daW
" Delete the expression into the 'b' register
:let l:tmp_b = #b
:normal "bd$
" Delete the remnants of the line
:normal dd
" Go to the end of the previous line so we can start our search for the
" usage of the variable to replace. Doing '0' instead of 'k$' doesn't
" work; I'm not sure why.
normal k$
" Find the next occurence of the variable
exec '/\<' . #a . '\>'
" Replace that occurence with the text we yanked
exec ':.s/\<' . #a . '\>/' . #b
:let #a = l:tmp_a
:let #b = l:tmp_b
endfunction
nnoremap <leader>ri :call InlineVariable()<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" MAPS TO JUMP TO SPECIFIC COMMAND-T TARGETS AND FILES
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <leader>gr :topleft :split config/routes.rb<cr>
function! ShowRoutes()
" Requires 'scratch' plugin
:topleft 100 :split __Routes__
" Make sure Vim doesn't write __Routes__ as a file
:set buftype=nofile
" Delete everything
:normal 1GdG
" Put routes output in buffer
:0r! rake -s routes
" Size window to number of lines (1 plus rake output length)
:exec ":normal " . line("$") . _ "
" Move cursor to bottom
:normal 1GG
" Delete empty trailing line
:normal dd
endfunction
map <leader>gR :call ShowRoutes()<cr>
map <leader>gv :CtrlPClearCache<cr>\|:CtrlP app/views<cr>
map <leader>gc :CtrlPClearCache<cr>\|:CtrlP app/controllers<cr>
map <leader>gm :CtrlPClearCache<cr>\|:CtrlP app/models<cr>
map <leader>gh :CtrlPClearCache<cr>\|:CtrlP app/helpers<cr>
map <leader>gl :CtrlPClearCache<cr>\|:CtrlP lib<cr>
map <leader>gp :CtrlPClearCache<cr>\|:CtrlP public<cr>
map <leader>gs :CtrlPClearCache<cr>\|:CtrlP spec<cr>
map <leader>gf :CtrlPClearCache<cr>\|:CtrlP features<cr>
map <leader>gg :topleft 100 :split Gemfile<cr>
map <leader>gt :CtrlPClearCache<cr>\|:CtrlPTag<cr>
map <leader>f :CtrlPClearCache<cr>\|:CtrlP<cr>
map <leader>F :CtrlPClearCache<cr>\|:CtrlP %%<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" SWITCH BETWEEN TEST AND PRODUCTION CODE
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! OpenTestAlternate()
let new_file = AlternateForCurrentFile()
exec ':e ' . new_file
endfunction
function! AlternateForCurrentFile()
let current_file = expand("%")
let new_file = current_file
let in_spec = match(current_file, '^spec/') != -1
let going_to_spec = !in_spec
let in_app = match(current_file, '\<controllers\>') != -1 || match(current_file, '\<models\>') != -1 || match(current_file, '\<views\>') != -1
if going_to_spec
if in_app
let new_file = substitute(new_file, '^app/', '', '')
end
let new_file = substitute(new_file, '\.rb$', '_spec.rb', '')
let new_file = 'spec/' . new_file
else
let new_file = substitute(new_file, '_spec\.rb$', '.rb', '')
let new_file = substitute(new_file, '^spec/', '', '')
if in_app
let new_file = 'app/' . new_file
end
endif
return new_file
endfunction
nnoremap <leader>. :call OpenTestAlternate()<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" RUNNING TESTS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! RunTests(filename)
" Write the file and run tests for the given filename
:w
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
:silent !echo;echo;echo;echo;echo;echo;echo;echo;echo;echo
if match(a:filename, '\.feature$') != -1
exec ":!script/features " . a:filename
else
if filereadable("script/test")
exec ":!script/test " . a:filename
elseif filereadable("Gemfile")
exec ":!bundle exec rspec --color " . a:filename
else
exec ":!rspec --color " . a:filename
end
end
endfunction
function! SetTestFile()
" Set the spec file that tests will be run for.
let t:grb_test_file=#%
endfunction
function! SetLineNumber()
" set the spec file that tests will be run for.
let t:spec_line_number=line('.')
endfunction
function! RunTestFileWithBacktrace(...)
if a:0
let command_suffix = a:1
else
let command_suffix = ""
endif
" Run the tests for the previously-marked file.
let in_test_file = match(expand("%"), '\(.feature\|_spec.rb\)$') != -1
if in_test_file
call SetTestFile()
elseif !exists("t:grb_test_file")
return
end
call RunTests(t:grb_test_file . command_suffix . " -b")
endfunction
function! RunTestFile(...)
if a:0
let command_suffix = a:1
else
let command_suffix = ""
endif
" Run the tests for the previously-marked file.
let in_test_file = match(expand("%"), '\(.feature\|_spec.rb\)$') != -1
if in_test_file
call SetTestFile()
elseif !exists("t:grb_test_file")
return
end
call RunTests(t:grb_test_file . command_suffix)
endfunction
function! RunNearestTest()
let in_test_file = match(expand("%"), '\(.feature\|_spec.rb\)$') != -1
if in_test_file
call SetLineNumber()
end
call RunTestFile(":" . t:spec_line_number )
endfunction
function! RunNearestTestWithBacktrace()
let spec_line_number = line('.')
call RunTestFile(":" . spec_line_number )
endfunction
map <leader>T :call RunTestFile()<cr>
map <leader>t :call RunNearestTest()<cr>
map <leader>B :call RunTestFileWithBacktrace()<cr>
map <leader>b :call RunNearestTestWithBacktrace()<cr>
map <leader>a :call RunTests('')<cr>
map <leader>c :w\|:!script/features<cr>
map <leader>w :w\|:!script/features --profile wip<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Md5 COMMAND
" Show the MD5 of the current buffer
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
command! -range Md5 :echo system('echo '.shellescape(join(getline(<line1>, <line2>), '\n')) . '| md5')
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" OpenChangedFiles COMMAND
" Open a split for each dirty file in git
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! OpenChangedFiles()
only " Close all windows, unless they're modified
let status = system('git status -s | grep "^ \?\(M\|A\)" | cut -d " " -f 3')
let filenames = split(status, "\n")
exec "edit " . filenames[0]
for filename in filenames[1:]
exec "sp " . filename
endfor
endfunction
command! OpenChangedFiles :call OpenChangedFiles()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" InsertTime COMMAND
" Insert the current time
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
command! InsertTime :normal a<c-r>=strftime('%F %H:%M:%S.0 %z')<cr>
And this is my vim version :
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled May 5 2012 20:53:55)
Included patches: 1-154
Compiled by dougui#osacar
Huge version without GUI. Features included (+) or not (-):
+arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset +cindent
-clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
+conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con +diff +digraphs
-dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path
+find_in_path +float +folding -footer +fork() -gettext -hangul_input +iconv
+insert_expand +jumplist +keymap +langmap +libcall +linebreak +lispindent
+listcmds +localmap -lua +menu +mksession +modify_fname +mouse -mouseshape
+mouse_dec -mouse_gpm -mouse_jsbterm +mouse_netterm -mouse_sysmouse
+mouse_xterm +multi_byte +multi_lang -mzscheme +netbeans_intg -osfiletype
+path_extra -perl +persistent_undo +postscript +printer +profile -python
-python3 +quickfix +reltime +rightleft +ruby +scrollbind +signs +smartindent
-sniff +startuptime +statusline -sun_workshop +syntax +tag_binary
+tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title
-toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo
+vreplace +wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp
-xterm_clipboard -xterm_save
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/usr/local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -I/usr/local/include -g -O2 -D_FORTIFY_SOURCE=1
Linking: gcc -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -rdynamic -Wl,-export-dynamic -L/usr/local/lib -Wl,--as-needed -o vim -lm -ltinfo -lnsl -ldl -lruby1.8 -lpthread -lrt -ldl -lcrypt -lm
What can I do?
Thanks!
I apologize. It was just a problem with my key board. With my french canadian configuration I must to do Ctrl + Alt Car + ]. I will map this keys.
Some simple tests :
To use tags, you must first generate a tag file (which index all the symbols). This is done by executing ctags -R . from the command line or :!ctags -R .from Vim.
After you have executed the command, check that a tag file has been created in the directory. This is a test file, so you can check if the list of symbols looks sensible.
Lastly, you can only jump on a tag, if Vim find the tag file in the path. This is achieve by setting the tags option in your .vimrc
I use the following option:
" search first in current directory then file directory for tag file
set tags=tags,../tags

Resources