Various skills for using textpad to edit code

Source: Internet
Author: User
Tags word wrap

It is not easy to find a proper syntax highlighting plug-in. With the help of tiger_zhao these two days, I found a method to insert the syntax highlighting code in livewriter and word using textpad, A simple record is as follows. At the end of the article, I added some tips for using textpad.

The general idea is to first use the syntax highlighting and editing functions of textpad to obtain the HTML code corresponding to the correctly colored code segment, and then copy the code to the source code segment of livewriter, then copy the code to the color text in the word. It's a bit confusing. 1. Obtain the correct colored VB code segment in textpad(1) download and install textpad. This software is a shared version, and all functions of unregistered versions are complete, but a dialog box pops up from time to time asking you to register. I don't think it is very important. (2) Make a syntax highlight file. Download a SYN file of VB6 from this address and open it in textpad. Follow the steps on the 5th and 7th floors of this post to modify it (thanks to Zhao Tiao, who is extremely careful and patient). Save it in the system subdirectory of the textpad installation directory. Remember to back up this fileIn the future, you do not need to repeat it. (3) Add the VB6 document class. For details, see the section "help" how to create a new document class "of textpad. Specify the syntax to highlight the file in step (2) in the newly added document class. In addition, remember to set the color of the brackets to Black (originally red), and set the color of keyword1 to dark blue (originally baby blue ). Remember to add the associated suffix at least *. Bas. By the way, you can set the base color of currentline to yellow (originally white), which can be set in the default document class so that all document classes can have this easy-to-edit setting. (4) now open an empty. Bas file and copy the code snippet from Visual Studio. How is it? Is the effect satisfactory? Now, you can correctly color the VB code in textpad. 2. Obtain the correct colored VB code segment in livewriterFirst, obtain the HTML source code corresponding to the syntax highlight code in textpad: (1) generate the HTML code initially. Select the VB code displayed in step (4) above, click Edit-> copy other-> As a HTML page, open a blank document, and press Ctrl + v. In this way, we get the HTML code corresponding to this section of the coloring code. (2) Modify tags of HTML code. Use the replace tool on the textpad toolbar to replace the following HTML code:
Replace all span classes with font color
Replace all </span> with </font>
Replace all CSS keywords marked at the beginning of a field with corresponding color values. For example, replace all tptext with #000000 and all tpkeyword1 with #000080. (3) modify the pre Row Height and font. This is optional. I like to add the style modifier after the pre and change it to the following: (4) copy the HTML source code. Run Ctrl + C as the source code between <PRE> </PRE> and copy the HTML source code corresponding to the syntax highlighting code. Then paste it into livewriter. This is simple. Open livewriter, switch to the source code view, CTRL + V, and then switch to the edit view. How about this? Are you satisfied with the results? By the way, you can record (1) + (2) as a macro in textpad and (3) as another macro, in this way, you only need to click the mouse to complete all the above operations. In addition, sometimes the automatically generated HTML code is marked by <body> rather than <PRE>. In this case, you need to add the <PRE> mark and style Mark (same as above) before the code segment to delete all <p>
Replace all </P> deletions with </body> </PRE>. You can also record the preceding steps as a macro. In addition, if your program code is indented, you also need to replace the padding label with a corresponding number of spaces, such as all <P style = "padding-left: 4ex; "> four English spaces are replaced. 3. Obtain the correct colored VB code segment in WordNow copy and paste the pretty code snippet into the word document from the livewriter editing view. The color is correct. However, if the line spacing is incorrect, select the code segment and adjust it as follows: (1) set the spacing of the section to yahei las hybrid (2:
0 before, 0 after
Remove (not selected) "alignment grid if document mesh is defined ".
Set the value to 0.75 (3). You can also set the border and shading according to your preferences. I usually set the shading to "grayscale-5%", and select "shadow" for the border to apply to paragraphs. You can also record step (1)-(3) as a macro and drag the macro to the toolbar so that you can set the code format by clicking the mouse. By the way, sometimes you do the toolbar settings in word, and then re-open the settings, but it is lost. This is because you didn't save these settings in normal. Dot. The solution is simple. After the settings are complete, Shift + File, Select Save all. Finally, I enjoyed the beautiful code in the last word. 4. Back up textpadAfter so much hard work, we 'd better back up the data and try again after the system is reinstalled next time. What do I need to back up? (1) back up the SYN file. The VB6 syntax highlight File Created in step 2 of Section 1st should be backed up. In the system subdirectory of the textpad installation directory, reinstall the system and copy it back. In addition, the cliplibrary file under the sample directory (see the following section) can also be backed up to save repeated values. (2) backup document class. Export the Registry item HKEY_CURRENT_USER/software/Helios/textpad 5/document classes/VB6, reinstall the system, and then re-import it. (3) Back up macro files. The hard-recorded Macros in section 2nd should be backed up, usually under C:/Documents and Settings/current user name/Application Data/Helios/textpad/5.0. You can back up both the config. xml file and macro file. A friend who loves to ask questions like me may say, what is the retention method of Macros in word? In this case, use the "user settings save wizard" in "Microsoft Office Tools. 5. Other textpad skills(1) Save the workspace, so that when you open textpad, you can open all the files you opened last time. (2) use clipliabrary to speed up the input. Here you can download the clip plug-in (thanks to patrickkong ). Tiger_zhao shared the following experience: the "ASCII character" library can be used for convenient encoding. You can use libraries such as "HTML characters" to help you remember them. It is more convenient to enter them directly after you are proficient. Databases such as "Transact-SQL" can be used as templates. Some libraries also provide genuine clipboard functions, such as "VBScript templates ". (3) set automatic line feed: Click the s icon on the toolbar, or click "config/Word Wrap" in the menu ". (4) select text by column: for example Several rowsRemove all four spaces in front of the Code. Choose "config/block select mode" or select the lines of text "Shift + TAB ".

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.