Difference between revisions of "Sublime Text"

97 bytes added ,  10:12, 18 August 2019
m
changed user home directory in the previous edit to the proper variable used by the Python scripts
imported>Hannibalektr
imported>Nemesis
m (changed user home directory in the previous edit to the proper variable used by the Python scripts)
 
(18 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{RequiresPublicUpdate|Remove this line}}
'''Sublime Text''' is an extensible text-editor with a robust package system based on Python that makes it very flexible.
(INTERNAL: interested in how this all works? [[Sublime Text Development|See how the sausage is made]].)
Sublime Text is [https://www.sublimetext.com/buy not free software], but offers an unlimited and unrestricted evaluation version.
It can be purchased or evaluated on the [https://www.sublimetext.com official website].  
 
{{See Wikipedia}}


==Installation==
==Installation==
Line 8: Line 11:


===Install Plugin===
===Install Plugin===
{{RequiresPublicUpdate|Insert ZIP file for users to utilize instead of grabbing from the network}}
#Download [[File:PapyrusF4.zip]]
#Go to <code>\\bgs\F4\Tools\Sublime Text\Packages</code>, and copy the PapyrusF4 folder to <code>%APPDATA%\Sublime Text 2\Packages</code>. (If you installed Sublime Text 3, the name of the folder is "Sublime Text 3" instead)
#Extract the zip file to <code>%APPDATA%\Sublime Text 2\Packages</code> directly - or extract it somewhere else and drag in the PapyrusF4 folder to the packages folder.
#*If you installed Sublime Text 3, the location is <code>%APPDATA%\Sublime Text 3\Packages</code> instead


====If no previous Papyrus plugin====
====If no previous Papyrus plugin====
{{RequiresPublicUpdate|Update these settings for public release and remove update ini setting line}}
#In Sublime, press CTRL + SHIFT + P to type the command: "PapyrusF4" -> PapyrusF4 INI: Create default INI file. This will create the file <code>%USERPROFILE%\Documents\SublimePapyrusF4.ini</code> and open it in the editor.
#In Sublime, right-click and select PapyrusF4 -> Create default INI file
#Make the following changes:
#Make the following changes:
#*Point "scripts=" at your script ''source'' folder
#*Point "scripts=" at your script ''source'' folder
#*Point "compiler=" and "assembler=" at the compiler and assembler exe files in your PC folder
#*Point "compiler=" and "assembler=" at the compiler and assembler exe files in your PC folder
#*Point "output=" at your "Data\Scripts" folder
#*Point "output=" at your "Data\Scripts" folder
#*Change "wiki=" to "wiki=http://intranet.bethsoft.com/tesv_editor/"
#*Change "wiki=" to "wiki=http://www.creationkit.com/fallout4/"
#*Add the following to the top of the file:
[General]
update=\\bgs\F4\Tools\Sublime Text\Packages\PapyrusF4


====If you have the old Papyrus plugin====
====If you have the old Papyrus plugin====
{{RequiresPublicUpdate|Public users don't have the workspace switch tool - use above steps to generate and edit ini, and adjust instructions for setting it up as the default}}
Follow the above steps for if you have no Papyrus plugin, then do the following:
#Launch the workspace switch tool and it will auto-generate the new ini file for you based on your old ini file
#In Sublime, open an existing PSC file
#In Sublime, open an existing PSC file
#Select View -> Syntax -> Open all with current extension as... -> PapyrusF4 -> PapyrusF4
#Select View -> Syntax -> Open all with current extension as... -> PapyrusF4 -> PapyrusF4


===Additional Steps===
===Additional Steps===
Due to the addition of several new auto-complete options for functions, you may find Sublime accepting "Enter" to auto-complete to be annoying. (As an example, try typing "endif" and hitting "Enter" to add a new line) To disable this and only allow "Tab" to auto-complete, do the following:
Due to the addition of several new auto-complete options for functions, you may find Sublime accepting "Enter" to auto-complete to be annoying. (As an example, try typing {{kbd|endif}} and hitting {{key press|Enter}} to add a new line) To disable this and only allow {{key press|Tab}} to auto-complete, do the following:
#Select Preferences -> Settings - User
#Select Preferences -> Settings - User
#Add the following to the file, between the <nowiki>{ and }</nowiki> characters. If there is already other settings in there, make sure they are all separated by commas.
#Add the following to the file, between the <nowiki>{ and }</nowiki> characters. If there is already other settings in there, make sure they are all separated by commas.
Line 36: Line 35:


==Build Types==
==Build Types==
The Sublime Papyrus plugin supports three different build types - debug, release, and release final. These are identical to the build types exposed in the Creation Kit. The normal build option, invoked with Ctrl+B, is a "debug" build. It will produce non-optimized code, with all debug commands intact.
The Sublime Papyrus plugin supports three different build types - debug, release, and release final. These are identical to the build types exposed in the Creation Kit. The normal build option, invoked with {{key press|Ctrl|B}}, is a "debug" build. It will produce non-optimized code, with all debug commands intact.


To access the other build types, open the Sublime command palette (Ctrl+Shift+P) and type in "Build". Then select either release (optimized + debug stripping) or release final (optimized + debug and beta stripping).
To access the other build types, open the Sublime command palette ({{key press|Ctrl|Shift|P}}) and type in "Build". Then select either release (optimized + debug stripping) or release final (optimized + debug and beta stripping).


You will generally want to do debug builds for testing and development, with final builds for release.
You will generally want to do debug builds for testing and development, with final builds for release.
Line 61: Line 60:
==Adding Snippets==
==Adding Snippets==
The existing Papyrus package for Sublime Text includes a number of snippets that will auto-complete to frequently used things (like typing "onhit" and then tab will create a proper OnHit event so you don't have to constantly be looking up the syntax). If you want to make more of these, you can simply add another .sublime-snippet file to the Package directory. Documentation on snippets is available at [http://www.sublimetext.com/docs/2/ Sublime Text docs site].
The existing Papyrus package for Sublime Text includes a number of snippets that will auto-complete to frequently used things (like typing "onhit" and then tab will create a proper OnHit event so you don't have to constantly be looking up the syntax). If you want to make more of these, you can simply add another .sublime-snippet file to the Package directory. Documentation on snippets is available at [http://www.sublimetext.com/docs/2/ Sublime Text docs site].
{{RequiresPublicUpdate|Remove following line}}
If you make a new snippet that you think might be useful, e-mail it to Jeff Lundin for consideration in distribution.


==Tips 'n' Tricks==
==Tips 'n' Tricks==
* Drag your scripts directory to the Sublime Text window to have it opened as your current project. Now hit Ctrl-P. You have access to all your scripts here, with it narrowing down the list as you type. It's even smart enough to translate "comph" into "CompanionsHousekeepingScript," so whatever kinds of nutty shorthand you can think of for your scripts will probably work.  
* Drag your scripts directory to the Sublime Text window to have it opened as your current project. Now hit {{key press|Ctrl|P}}. You have access to all your scripts here, with it narrowing down the list as you type. It's even smart enough to translate "comph" into "CompanionsHousekeepingScript," so whatever kinds of nutty shorthand you can think of for your scripts will probably work.  
* In a long file with lots of functions, hit Ctrl-R. You're now looking at a list of functions that you can navigate the same way.  
* In a long file with lots of functions, hit {{key press|Ctrl|R}}. You're now looking at a list of functions that you can navigate the same way.  
* Combine the two of them. Ctrl-P, type to find your file. Add an "@" at the end of it when you have the one you want, and you can go directly to the function in question. So "comph@reoprq" takes me right to the "ReOpenAllRadiantQuests" in CompanionsHousekeepingScript.psc. And since it works as you type, you don't even have to remember ''that'' much.  
* Combine the two of them. {{key press|Ctrl|P}}, type to find your file. Add an "@" at the end of it when you have the one you want, and you can go directly to the function in question. So {{kbd|comph@reoprq}} takes me right to the "ReOpenAllRadiantQuests" in CompanionsHousekeepingScript.psc. And since it works as you type, you don't even have to remember ''that'' much.  
* After you hit Ctrl+B to compile, if there are any errors, you can hit F4 to cycle through them.
* After you hit {{key press|Ctrl|B}} to compile, if there are any errors, you can hit {{key press|F4}} to cycle through them.
* Holding Ctrl and Shift lets you move lines up and down with the arrow keys.  
* Holding {{key press|Ctrl|Shift}} lets you move lines up and down with the arrow keys.  
* Ctrl-Shift-D duplicates a line.  
* {{key press|Ctrl|Shift|D}} duplicates a line.  
* Highlight a word, then press Ctrl-D to highlight every other instance of that word in succession -- makes renaming variables simple!  
* Highlight a word, then press {{key press|Ctrl|D}} to highlight every other instance of that word in succession -- makes renaming variables simple!  
* Drag with the middle mouse button for a vertical select.  
* Drag with the middle mouse button for a vertical select.  
* If you've set up Perforce, you can use the Perforce commands in the FalloutF4 right-click menu (they are also in the command palette). This lets you view old versions of the file you're looking at, perform diffs from the current version against those old versions, and compare what is currently on your disk to what is in the repository.
* If you've set up Perforce, you can use the Perforce commands in the FalloutF4 right-click menu (they are also in the command palette). This lets you view old versions of the file you're looking at, perform diffs from the current version against those old versions, and compare what is currently on your disk to what is in the repository.
* All Events that the compiler supports have been added as snippets, so if you type the name of the event and hit Tab, it will autocomplete to the full event (with parameters) so you don't have to check the wiki for syntax. Snippets are case-sensitive, and all event names are set as lower-case, so you'll need to type the name in lower-case to see it.
* All Events that the compiler supports have been added as snippets, so if you type the name of the event and hit {{key press|Tab}}, it will autocomplete to the full event (with parameters) so you don't have to check the wiki for syntax. Snippets are case-sensitive, and all event names are set as lower-case, so you'll need to type the name in lower-case to see it.
** For remote-registered events, use the name of the event followed by "-REM" to have the correct syntax filled out
** For remote-registered events, use the name of the event followed by "-REM" to have the correct syntax filled out
** For reference collection aliases, use the name of the event followed by "-RC" to have the sender parameter auto-added
** For reference collection aliases, use the name of the event followed by "-RC" to have the sender parameter auto-added
** Both of the above are combined into "-REM-RC" if you happen to need a remote event from a ref collection alias.
** Both of the above are combined into "-REM-RC" if you happen to need a remote event from a ref collection alias.
* All the functions on the wiki have been added as snippets. You can type part of the function name (in lower-case) and hit Tab to fill out the function with all the parameters. Hit tab to switch between each parameter.
* All the functions on the wiki have been added as snippets. You can type part of the function name (in lower-case) and hit {{key press|Tab}} to fill out the function with all the parameters. Hit {{key press|Tab}} to switch between each parameter.
* Place your cursor inside a function name and hit F1 to open the wiki documentation on that function. If there's more than one function with the name, it'll give you a choice as to which one you want to see.  
* Place your cursor inside a function name and hit {{key press|F1}} to open the wiki documentation on that function. If there's more than one function with the name, it'll give you a choice as to which one you want to see.  
** You can also do this by right-clicking and selecting PapyrusF4 -> Wiki Documentation.
** You can also do this by right-clicking and selecting PapyrusF4 -> Wiki Documentation.
** Because Sublime lets you do multiple selections, if you have more than one cursor sitting in a function name, it will attempt to look up documentation for all of them and open them in tabs.
** Because Sublime lets you do multiple selections, if you have more than one cursor sitting in a function name, it will attempt to look up documentation for all of them and open them in tabs.
Line 104: Line 100:


===Assembling and Disassembling Papyrus PEX files===
===Assembling and Disassembling Papyrus PEX files===
If you open a PEX file in Sublime it will show up as a binary file. If you set the "syntax" (via the View menu) to "Compiled PapyrusF4" and hit "Build", Sublime with disassemble the PEX file for you into a PAS file which will then be auto-opened in Sublime with proper syntax coloring.
If you open a PEX file in Sublime it will show up as a binary file. If you set the "syntax" (via the View menu) to "Compiled PapyrusF4" and hit "Build", Sublime will disassemble the PEX file for you into a PAS file which will then be auto-opened in Sublime with proper syntax coloring.


Note that the PEX file needs to be in an "output" folder specified in the ini file for this to work.
Note that the PEX file needs to be in an "output" folder specified in the ini file for this to work.
Line 111: Line 107:


Note that the normal script compiler will delete the PAS file if it is found, so if you want to keep it, make a copy.
Note that the normal script compiler will delete the PAS file if it is found, so if you want to keep it, make a copy.
==See Also==
*[[:Category:Text Editors|Other Text Editors]]
[[Category:Text Editors]]
[[Category:Scripting]]
[[Category:Scripting]]
[[Category:Tooling]]
Anonymous user