[Tutorial] Edit big pieces of code in a much easier way (sublime)

In this tutorial I'll be showing an example of how to edit a big piece of code very easily.
I will be using a text editor called: Sublime Text 2 (Free)
You don't have to code your scripts in this text editor, I just copy the pieces I need to edit into Sublime and copy them back to pawno once they're done.

The code that we want to edit: (of course your code can be much bigger)
PHP Code:
CreateObject(193772817.831302668.524669.89860,   0.0000090.0000090.00000);
CreateObject(193552814.202152670.698739.77740,   0.000000.0000090.00000);
CreateObject(193552821.475832670.698739.77740,   0.000000.0000090.00000);
CreateObject(194472814.392822665.9592311.71586,   0.000000.000000.00000);
CreateObject(194472821.300292665.9592311.71590,   0.000000.000000.00000);
CreateObject(194472824.654052665.2380411.71590,   0.000000.0000090.00000);
CreateObject(144092817.808112668.451428.34180,   0.000000.00000180.00000);
CreateObject(193552815.738532669.942879.78740,   0.000000.000000.00000);
CreateObject(193552819.805662669.942879.78740,   0.000000.000000.00000);
CreateObject(193622822.408452672.2238811.46280,   0.0000090.000000.00000);
CreateObject(193622818.909912672.2238811.46280,   0.0000090.000000.00000);
CreateObject(193622815.410402672.2238811.46280,   0.0000090.000000.00000);
CreateObject(193622811.917482672.2238811.46280,   0.0000090.000000.00000);
CreateObject(193772817.831302679.0625010.35130,   0.0000090.0000090.00000);
CreateObject(194472817.831302673.745619.79898,   0.000000.0000090.00000);
CreateObject(194542822.160642678.6433111.46280,   0.0000090.000000.00000);
CreateObject(194542813.738282678.6433111.46280,   0.0000090.000000.00000);
CreateObject(194472820.489502678.628429.79900,   0.000000.000000.00000);
CreateObject(194472815.408692678.628429.79900,   0.000000.000000.00000);
CreateObject(14372817.840092664.652599.98590,   10.000000.000000.00000);
CreateObject(194472811.024662665.2380411.71590,   0.000000.0000090.00000);
CreateObject(194472816.501712661.8676811.71590,   0.000000.00000, -45.00000);
CreateObject(194472819.203612661.8715811.71590,   0.000000.0000045.00000); 
In this tutorial I will be changing the code shown above so that it is using the function CreateDynamicObject from incognito's streamer.

So go ahead and copy the code into sublime

Now press CTRL + H, this will show you the replace window at the bottom of your screen

Now in the 'Find what:' area we will type 'CreateObject' and in the 'Replace With:' area we put 'CreateDynamicObject'
This replaces all instances of 'CreateObject' with 'CreateDynamicObject'

Press the replace all button and you should see that all instances of 'CreateObject' were replaced with 'CreateDynamicObject'

But wait! The parameters of the function are still not right with CreateDynamicObject.
CreateDynamicObject function:
CreateDynamicObject(modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, worldid = -1, interiorid = -1, playerid = -1, Float:streamdistance = 200.0, Float:drawdistance = 0.0);
CreateObject function:
CreateObject(modelid, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ, Float:DrawDistance [not used in our script])
As you can see, the function used in our script is missing 5 parameters.
These are:
worldid = -1, interiorid = -1, playerid = -1, Float:streamdistance = 200.0, Float:drawdistance = 0.0
Now that we know this, we can start editing the functions.
First let's remove all the ');' from the end of the functions just by using the replace feature.

Replace with: (nothing)

Now that all the ');' are gone, we can go ahead and select all lines. (CTRL + A)
and now do CTRL + SHIFT + L and RIGHT ARROW
It may sound complicated but once you've done it right, it should look like this:

You can now type something and it will appear on the end of each line! How easy was that?
Let's simply type in our parameters now and close them with a ');'

That's it, you're done! How easy was that?

(Yes, you could have done the last part with the replace feature aswell but I wanted to show the CTRL + SHIFT + L feature )

Even easier is to select "CreateObject", press ctrl + D, then f3. All instances are selected

Originally Posted by Misiur
View Post
Even easier is to select "CreateObject", press ctrl + D, then f3. All instances are selected
I don't think that selects every instance. Pressing F3 only continues onto the next instance of whatever you've highlighted.

This is pretty nice, thanks for showing us this.

Forum Jump:

Users browsing this thread: