User Tools

Site Tools


Sidebar

Index

Action disabled: revisions
ide:netbeans-12-no-code-completion-on-templates

Netbeans 12 no completion on code templates

In the previous version of Netbeans, PHP, JS, CSS, HTML had no code completion on custom code templates. At a certain point (I don't remember the version) the NB team added that for PHP and Javascript. For these 2 languages can now be activated using the checkbox located in the templates section into the tab “Contexts”.

However the problem is still here for HTML and CSS. So, again, we have to resort in a script to set the contexts in the config files. The following is the upgraded version of the script already presented here: Netbeans 8 no completion on php code template

nbtemplate.sh
#!/bin/bash
# set the contexts on every template that hasn't one yet
 
VER="12.0"
 
FILEPHP=~/.netbeans/$VER/config/Editors/text/x-php5/CodeTemplates/org-netbeans-modules-editor-settings-CustomCodeTemplates.xml
FILEJS=~/.netbeans/$VER/config/Editors/text/javascript/CodeTemplates/org-netbeans-modules-editor-settings-CustomCodeTemplates.xml
FILEHTM=~/.netbeans/$VER/config/Editors/text/html/CodeTemplates/org-netbeans-modules-editor-settings-CustomCodeTemplates.xml
FILECSS=~/.netbeans/$VER/config/Editors/text/css/CodeTemplates/org-netbeans-modules-editor-settings-CustomCodeTemplates.xml
 
sed -i -e 's/ contexts="php-code"//gI' $FILEPHP
sed -i -e 's/xml:space="preserve">/xml:space="preserve" contexts="php-code">/gI' $FILEPHP
 
#"JavaScript-Code" must be written this way, not my bad! :-)
sed -i -e 's/ contexts="JavaScript-Code"//gI' $FILEJS
sed -i -e 's/xml:space="preserve">/xml:space="preserve" contexts="JavaScript-Code">/gI' $FILEJS
 
sed -i -e 's/ contexts="html-code"//gI' $FILEHTM
sed -i -e 's/xml:space="preserve">/xml:space="preserve" contexts="html-code">/gI' $FILEHTM
 
sed -i -e 's/ contexts="css-code"//gI' $FILECSS
sed -i -e 's/xml:space="preserve">/xml:space="preserve" contexts="css-code">/gI' $FILECSS

Since in Netbeans 11 or 12 the tag “contexts” could already exist for PHP and JS, this script deletes the tag before adding it. This prevents a double tag in the config files that would result no templates at all.

The code completion on HTML templates works only for .php files, not for .html. Must be a Netbeans bug.

ide/netbeans-12-no-code-completion-on-templates.txt · Last modified: 2020/08/17 18:19 by rik