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"). Copy/paste and undo/redo functionality of the script editor is supported through a popup menu (right-click). 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.
If you have recurring functions you wish to access from a given script, you can add following line at the top of your script:
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 V-REP file anymore.
It can also be convenient to include the code from an external lua script, for ease of maintenance, or simply if you wish to use the same script content for several scripts:
Above way of including scripts will also allow you to edit your script content with an external editor. Remember however that you will also have to distribute the external files, when distributing your scene or model.