Using Notepad Plus Plus as a script editor

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
(How to enable highlighting of Unity "keywords" manually)
Line 38: Line 38:
 
== How to enable highlighting of Unity "keywords" manually ==
 
== How to enable highlighting of Unity "keywords" manually ==
 
# Open "C:\Program Files\Unity\Editor\Data\Tools\UniSciTE\unitykeywords.properties" This text file contains all the unity keywords. ("Program Files (x86)" on 64-bit systems.)
 
# Open "C:\Program Files\Unity\Editor\Data\Tools\UniSciTE\unitykeywords.properties" This text file contains all the unity keywords. ("Program Files (x86)" on 64-bit systems.)
# Open "C:\Program Files\Notepad++\stylers.xml" (If you're using a custom theme, open C:\Program Files\Notepad++\themes and open the theme XML file you are using instead.) NOTE:  For Windows 7 the file is located in \users\yourusername\AppData\Roaming\Notepad++\stylers.xml
+
# Open "C:\Program Files\Notepad++\stylers.xml" If you're using a custom theme, open C:\Program Files\Notepad++\themes and open the theme XML file you are using instead. For Windows 7 the file is located in C:\Users\yourusername\AppData\Roaming\Notepad++\stylers.xml If you're using Windows 7 and editing a custom theme, since it's in Program Files, you'll want to edit that theme XML file with a text editor that is running on admin privileges, or else it won't work.
# In stylers.xml (or your theme's XML file), find: <LexerType name="javascript" desc="Javascript" ext="">
+
# In stylers.xml (or your theme's XML file), find: <LexerType name="javascript" desc="Javascript" ext=""> for UnityScript files, or <LexerType name="cs" desc="C#" ext=""> if you want highlighting to work for C# files.
 
# Find the coressponding: <WordsStyle name="KEYWORD" styleID="47" fgColor="000080" bgColor="F2F4FF" fontName="" fontStyle="3" fontSize="" keywordClass="instre1"> (If there is none, add it)
 
# Find the coressponding: <WordsStyle name="KEYWORD" styleID="47" fgColor="000080" bgColor="F2F4FF" fontName="" fontStyle="3" fontSize="" keywordClass="instre1"> (If there is none, add it)
# Insert all the unity keywords (found from the unitykeywords.properties you opened earlier) inside that <WordsStyle name="KEYWORD"...> tag
+
# Change that <WordsStyle> tag to have opening and closing tags if it doesn't, and insert all the Unity keywords (found from the unitykeywords.properties you opened earlier) inside it. Here are examples: UnityScript: http://pastebin.com/M5ef2WtG, C#: http://pastebin.com/y3Zw8itM
Note: i did this on sep 2012 in win7, didnt work. i psted="" keywordClass="instre1" ADBannerView etc... zero /> hope this line saves you 20 minutes.
+
 
# Save it. Close and open Notepad++. It should highlight the Unity keywords now.
 
# Save it. Close and open Notepad++. It should highlight the Unity keywords now.
  
Line 56: Line 55:
 
# Turn on parameter hints by going to: Settings > Preferences > Backup/Auto-Completion. Check "Function parameters hint on input"
 
# Turn on parameter hints by going to: Settings > Preferences > Backup/Auto-Completion. Check "Function parameters hint on input"
 
# Open "C:\Program Files\Notepad++\plugins\APIs\javascript.xml" (As of version 3.4, the Javascript and C# API are the same, therefore editing "cs.xml" will also work.)
 
# Open "C:\Program Files\Notepad++\plugins\APIs\javascript.xml" (As of version 3.4, the Javascript and C# API are the same, therefore editing "cs.xml" will also work.)
# Depending on your version of Unity, copy and paste contents of the file specified below to anywhere inside the <AutoComplete> tags of the previous XML file. If you have trouble saving, try running Notepad++ as an administrator.
+
# Depending on your version of Unity, copy and paste contents of the file specified below to anywhere inside the <AutoComplete> tags of the previous XML file. If you have trouble saving, try running Notepad++ with admin privileges.
 
## For UnityScript in Unity 3.3:  http://unity.igorrafael.com/home/UnityAPI_JS.xml  
 
## For UnityScript in Unity 3.3:  http://unity.igorrafael.com/home/UnityAPI_JS.xml  
 
## For Unity 3.4:  http://dl.dropbox.com/u/25260770/Unity-Notepad%2B%2B/UnityApi_to_Npp-3.4.txt
 
## For Unity 3.4:  http://dl.dropbox.com/u/25260770/Unity-Notepad%2B%2B/UnityApi_to_Npp-3.4.txt
 
# Close and open Notepad++. A function tooltip should now appear whenever you type in an open parenthesis after a Unity function.
 
# Close and open Notepad++. A function tooltip should now appear whenever you type in an open parenthesis after a Unity function.
  
The files provided are created from the file found at "C:\Program Files\Unity\Editor\Data\Tools\UniSciTE\UnityJS.api" (or UnityCS.api), using a program made by [[User:AnomalousUnderdog|AnomalousUnderdog]] (http://dl.dropbox.com/u/25260770/Unity-Notepad%2B%2B/UnityJSapi_to_Npp.py). If ever the UnityJS.api or UnityCS.api changes again (in case of a Unity update), just run the python script and post the link here for others. Python 3.x Version doesn't work, so make sure you use the Python 2.7x Version.
+
The files provided are created from the file found at "C:\Program Files\Unity\Editor\Data\Tools\UniSciTE\UnityJS.api" (or UnityCS.api), using a program made by [[User:AnomalousUnderdog|AnomalousUnderdog]] (http://dl.dropbox.com/u/25260770/Unity-Notepad%2B%2B/UnityJSapi_to_Npp.py). If ever the UnityJS.api or UnityCS.api changes again (in case of a Unity update), just run the python script and post the link here for others. Python 3.x version doesn't work, so make sure you use the Python 2.7x version.
  
 
== How to make Notepad++ jump to the correct line number from the error console ==
 
== How to make Notepad++ jump to the correct line number from the error console ==

Revision as of 07:01, 7 October 2012

Notepad++ is a powerful text editor based on Scintilla (which is where UniSciTE is also based from). It is available only in Windows.

Advantages:

  • it can manage more than ten text files opened simultaneously
  • customizable color scheme
Notepad++ editing a Unityscript file
Notepad++ editing a Unityscript file.

Contents

Directions

  1. Notepad++ can be found in http://notepad-plus.sourceforge.net/uk/site.htm. Download and install.
  2. Change your External Script Editor to Notepad++ (In Unity, Edit> Preferences > General)
  3. Unity should now open Notepad++ whenever you double-click a script (or any text file actually).


How to add searching of Unity Documentation within Notepad++

  1. Download the Language Help Plugin via the Plugin Manager:
    1. Plugins > Plugin Manager > Show Plugin Manager. Then choose "Language Help" from the list, and click Install.
    2. If the Plugin Manager elicits an error, download the zip from https://sites.google.com/site/fstellari/nppplugins and place the appropriate DLL in your plugins folder. (A is ASCII and U is Unicode, referring to how your Notepad++ installation is configured.)
  2. Go to Plugins > Language Help > Options...
  3. Click Add and put these values
Name: Unity
Extension List: "js" (and/or "cs" if you're using C#)
Extended help file path: http://unity3d.com/support/documentation/ScriptReference/30_search.html?q=$word$

Now whenever you press ctrl+f1 while your cursor is on a word, it will search that word in the Unity documentation. (You can change the key binding via Settings > Shortcut Mapper)

How to enable highlighting of Unity "keywords" within Notepad++

  1. Open "C:\Program Files\Unity\Editor\Data\Tools\UniSciTE\unitykeywords.properties" This text file contains all the unity keywords.
  2. In Notepad++ go to Settings > Style Configurator...
  3. In the "Language:" list, select your appropriate language.
  4. In the "Style:" list, select Keyword (or Instruction Word).
  5. Add the keywords from the unitykeywords.properties file (the big block of text) into the "User-Defined Keywords" box.
  6. Note that the textbox may have a character limit so pasting here may not save all the Unity "keywords". Test by typing zero, that should highlight as a Unity keyword. If not, try the manual directions below.
  7. Save & Close. Close and open Notepad++. Voila.


How to enable highlighting of Unity "keywords" manually

  1. Open "C:\Program Files\Unity\Editor\Data\Tools\UniSciTE\unitykeywords.properties" This text file contains all the unity keywords. ("Program Files (x86)" on 64-bit systems.)
  2. Open "C:\Program Files\Notepad++\stylers.xml" If you're using a custom theme, open C:\Program Files\Notepad++\themes and open the theme XML file you are using instead. For Windows 7 the file is located in C:\Users\yourusername\AppData\Roaming\Notepad++\stylers.xml If you're using Windows 7 and editing a custom theme, since it's in Program Files, you'll want to edit that theme XML file with a text editor that is running on admin privileges, or else it won't work.
  3. In stylers.xml (or your theme's XML file), find: <LexerType name="javascript" desc="Javascript" ext=""> for UnityScript files, or <LexerType name="cs" desc="C#" ext=""> if you want highlighting to work for C# files.
  4. Find the coressponding: <WordsStyle name="KEYWORD" styleID="47" fgColor="000080" bgColor="F2F4FF" fontName="" fontStyle="3" fontSize="" keywordClass="instre1"> (If there is none, add it)
  5. Change that <WordsStyle> tag to have opening and closing tags if it doesn't, and insert all the Unity keywords (found from the unitykeywords.properties you opened earlier) inside it. Here are examples: UnityScript: http://pastebin.com/M5ef2WtG, C#: http://pastebin.com/y3Zw8itM
  6. Save it. Close and open Notepad++. It should highlight the Unity keywords now.

How to add hints for function parameters

This will cause Notepad++ to display a small scrollable tooltip, when you type an opening parenthesis after a function name, with the types and names of that function's parameters.

Note:

  • It doesn't work well for HTML/XML/SGML syntax.
  • It can stop working after some number of opening parentheses.
  • It requires the mouse for scrolling through the options.
  1. Turn on parameter hints by going to: Settings > Preferences > Backup/Auto-Completion. Check "Function parameters hint on input"
  2. Open "C:\Program Files\Notepad++\plugins\APIs\javascript.xml" (As of version 3.4, the Javascript and C# API are the same, therefore editing "cs.xml" will also work.)
  3. Depending on your version of Unity, copy and paste contents of the file specified below to anywhere inside the <AutoComplete> tags of the previous XML file. If you have trouble saving, try running Notepad++ with admin privileges.
    1. For UnityScript in Unity 3.3: http://unity.igorrafael.com/home/UnityAPI_JS.xml
    2. For Unity 3.4: http://dl.dropbox.com/u/25260770/Unity-Notepad%2B%2B/UnityApi_to_Npp-3.4.txt
  4. Close and open Notepad++. A function tooltip should now appear whenever you type in an open parenthesis after a Unity function.

The files provided are created from the file found at "C:\Program Files\Unity\Editor\Data\Tools\UniSciTE\UnityJS.api" (or UnityCS.api), using a program made by AnomalousUnderdog (http://dl.dropbox.com/u/25260770/Unity-Notepad%2B%2B/UnityJSapi_to_Npp.py). If ever the UnityJS.api or UnityCS.api changes again (in case of a Unity update), just run the python script and post the link here for others. Python 3.x version doesn't work, so make sure you use the Python 2.7x version.

How to make Notepad++ jump to the correct line number from the error console

  1. Download the Unity External Script Editor Helper (Located at http://dl.dropbox.com/u/25260770/Unity-Notepad%2B%2B/UnityExternalScriptEditorHelper-1.0.7z)
  2. Extract the files and follow the instructions in the README.txt
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox