The script editor has following features that make the code edition easier:
The API functions can easily be accessed by typing the first 3 letters (usually "sim"). When a script was modified, there is no need to explicitly save the changes: closing the script editor, saving the scene or starting a simulation will automatically apply the changes to the script. When a simulation is running, modifications to a given script will only have an effect once a new simulation run is started, except for customization scripts that will always apply changes once the editor was closed. The user can also explicitely restart/reset a given script, for changes to take immediately effect.
If you have recurring functions you wish to access from a given script, or if you simply wish to run code from an external file, you can do this with following:
In that case, make sure the file is named myExternalLuaFile.lua, and do not forget to distribute it together with your scene or model, since that code will not be part of a CoppeliaSim file anymore. Searched path are usually following:
Files included via the require directive can be opened in the same script editor by opening the popup menu over the file name.