LiClipseText LiClipse

Previous (Specifying indentation) Root Next (Spell Checking)

Templates Code Completion

On LiClipse, it's possible to add new templates for code completion in language files.

Language files may be found at the tracked directories. Preferences > LiClipse has links which show the tracked directories (any file which ends with a .liclipse in that folder is considered a LiClipse language file).

Also, it's possible to extend an existing language to add templates to it. For that, create a '${}.extend.liclipse' file in any of the tracked directories with the structure:

extend: Python # This is the name of the language to be extended to add templates

  # Only available if 'extend' is defined:
  # appends data to the specified items (in this case templates).
  - templates:
    - name: ''
      description: "Surround with try..except"
      pattern: |-

    - name: ''
      description: "Surround with try..finally"
      pattern: |-


The following variables are available for templates:

  • ${cursor}: Position where the cursor should appear after applying the completion.

  • ${indented_block}: This is a block indenting the contents of each line selected.
    Useful for doing a templates with a surround-with.

    templates: #Note: pressing ctrl+space twice will show only the templates
    - name: ''
      description: "Surround with try..except"
      pattern: |-
      auto_insert: false

  • ${selection}: Text selected.

  • ${date}: Current date.

  • ${year}: The current year.

  • ${user}: The current user.

  • ${dollar}: The dollar character.

  • Custom: It's also possible to create custom template variables that allow the user to choose from a list of options.

    template_variables: {
      script_type: ['text/javascript', 'text/coffeescript']
    - name: 'script'
      description: '<script> html element.'
      pattern: '<script type="${script_type}">${cursor}</script>'
      auto_insert: false
      icon: tag #Icons available: class, method, comment, attribute, tag, action (i.e.: LiClipseImageProvider)
      scope: default

The attributes that are available on a template are:
  • name: This is the name of the pattern and the set of chars to be matched to match it in a completion.

  • description: (optional) The description to be shown for the pattern.

  • pattern: The actual completion to be applied. Elements as "${identifier}" will be set as hotspots for the user to edit (and they can only be simple words, characters such as '/' will break it (if you need to use such a char to complete, use a template variable with a single value to be resolved).

  • auto_insert: (optional: true|false) default=true: If true, if the completion is the sole completion in the list, it's applied (otherwise the completion list shows up even with a single element) .

  • icon: (optional: string): The icon to be used for the completion (one of class, method, comment, attribute, tag, action).

  • scope: (optional: string): If given, the completions are only applied at the given scope.

  • match_previous_sub_scope: (optional: [string, string]): If given, a previous context of a given type (the first string passed) will be searched and it will be matched against a value (the second string passed) and the completion will only appear if there's a match.

  • match_current_sub_scope: (optional: [string, string] or [string, '*notempty*']): It's very close to match_previous_sub_scope, but it'll only look for matches inside the current partition while match_previous_sub_scope will match the previous sub scope regardless of where it's in the file (as long as it's before the current offset).

    Note that *notempty* matches any value within the current scope (as long as it's before the current offset).

    Example: the template below will be shown inside any html tag (as long as the tag class is present).
    - name: 'accesskey'
      description: 'accesskey'
      pattern: 'accesskey="${cursor}"'
      icon: 'attribute'
      scope: tag
      match_current_sub_scope: ['tag.class', '*notempty*']
    Example 2: the template below will be shown only for the <a> tag.
    - name: 'href'
      description: "href"
      pattern: 'href="${cursor}"'
      scope: tag
      icon: attribute
      match_current_sub_scope: ['tag.class', 'a']

Previous (Specifying indentation) Root Next (Spell Checking)
LiClipseText development

LiClipseText is open source and depends on your contributions! This may be in the form of bug fixes, answers on stackoverflow, new features... Another option is financially supporting it:


Copyright: Brainwy Software Ltda, 2020-2022