Documentation/XHP Code Snippets for KDE Editors

From The Document Foundation Wiki
Jump to navigation Jump to search

KDE text editor engine (KTextEditor) contains a code snippet helper that insert text (code) fragments in the file being edited.

KTextEditor is used in KDE's Kate and KDevelop editors.

Download and install to get XHP code snippets to simplify LibreOffice Help files editing


  • Automatic generation of unique IDs of paragraphs and other elements that requires ID unicity.
  • Saves typing time
  • Potentially reduce typing errors.
Kate Code Snippet Panel on the right


  1. Quit Kate or KDevelop applications
  2. Download this file:
  3. Unzip and move it to $HOME/.local/share/ktexteditor_snippets/data/
  4. Restart Kate or KDevelop
  5. Enable code snippets in Kate or KDevelop


  • Place the cursor in the location where the code snippet is to be inserted
  • Double click on the desired code snippet.
  • Fill the fields indicated in color. Use Tab and Shift Tab keys to move from field to field and backward.
  • When all fields are edited, press ESC to move cursor to the end of the snippet.


  • You can add, customize or remove snippets
  • You can assign a keyboard shortcut to insert the snippet. Edit the snippet and assign a keyboard shortcut.

Special XHP snippets


Creates a new XHP page.


  1. Create a new file
  2. Save it in the right place (<- Important !!!)
  3. Double click in the NewXHP code snippet
    1. The <filename> path is automatically inserted
    2. fill the topic and title fields
<?xml version="1.0" encoding="UTF-8"?>
<helpdocument version="1.0">
    * This file is part of the LibreOffice project.
    * This Source Code Form is subject to the terms of the Mozilla Public
    * License, v. 2.0. If a copy of the MPL was not distributed with this
    * file, You can obtain one at
        <topic id="page_topic" indexer="include" status="PUBLISH">
            <title id="tit" xml-lang="en-US">page_ttile</title>


Insert a section with a page title (Heading 1) wrapped in a link, bookmarks and bookmark values entries

<section id="section name">
    <bookmark xml-lang="en-US" branch="hid/hid path or command" id="bm_id1506899031966" localize="false"/>
    <paragraph id="hd_id1506899031966" role="heading" level="1" xml-lang="en-US"><link href="/text/schart/myTestFile.xhp" name="command name">command name</link></paragraph>
    <paragraph id="par_id1506899031966" role="paragraph" xml-lang="en-US"><variable id="variable name"><ahelp hid="hid path or command">ahelp text</ahelp> </variable></paragraph>


Insert a 3C x 2L table with pre-filled cell. The first row is a tablehead row and the second is a tablecontent row

Edit the fields and use TableRow and TableCell snippets to add rows and cells

<table id="tab_id1506899261716">
            <paragraph id="par_id1506899261716" role="tablehead" xml-lang="en-US" localize="false">Table Head A</paragraph>
            <paragraph id="par_id1506899261717" role="tablehead" xml-lang="en-US" localize="false">Table Head B</paragraph>
            <paragraph id="par_id1506899261717" role="tablehead" xml-lang="en-US" localize="false">Table Head C</paragraph>
            <paragraph id="par_id1506899261717" role="tablecontent" xml-lang="en-US">Table Head A</paragraph>
            <paragraph id="par_id1506899261717" role="tablecontent" xml-lang="en-US">Table contents B</paragraph>
            <paragraph id="par_id1506899261717" role="tablecontent" xml-lang="en-US">Table contents C</paragraph>