thamis
King of Kish
- Joined
- Jan 21, 2002
- Messages
- 1,583
Outline
This article covers how to do the following things to a WBS file:
- remove all TeamReveals with a few keystrokes
- remove all Units with a few keystrokes
- remove all Cities with a few keystrokes
There are many more things that you can do. Please comment here if you want to do something and you aren't sure how, or if you've found an even quicker way!
Here are all the keystrokes you have to press without explanations. You can be stupid as a monkey, simply load the file and press the keys.
VIM
Ok, after I have written my tutorial on how to make clean maps without causing WorldBuilder to mess stuff up, here's a tip on how to vastly improve your editing speed with one of the most powerful text editors, VIM. You can download VIM here. It's free!
The great thing about VIM: It's very powerful. You can make yourself macros which are very very very helpful if you want to edit a certain thing in your map, maybe over and over again.
The bad thing about VIM: It's pretty damn complex. I haven't mastered it yet, far from it. But I've found some pretty nifty ways to help editing WBS files, and I'll explain them for you all here!
First of all, VIM has three editing modes: NORMAL (what you get when you start VIM, you can't actually write anything into the text file), INSERT (works like the normal text editor), REPLACE (everything you type replaces existing text).
The Modes
NORMAL: You get this mode when VIM comes up. In this mode, you can use all the keyboard shortcuts of VIM. We'll use this mode a lot. If you're in any other mode, pressing ESC gets you back to normal mode.
INSERT & REPLACE: Well, pretty much like any text editor. Enter these modes by pressing the INSERT key on your keyboard (once for insert, twice for replace). Press ESC to get back to normal.
VISUAL: You get there by pressing either "v" or "V". This mode is good for selecting lines of text. If you press "V" (SHIFT+V) you can only select full lines. We'll need that later.
Commands
First off, let me tell you a few useful commands. They work in NORMAL mode, and when you type them you'll see them in the bottom line. Some of them require enter to be executed, others don't.
Now, the cool thing about VIM is that you can tell the program to repeat a certain command an unlimited number of times! So if you type 6dd, it will delete 6 lines - the line your cursor is on and the 5 lines after it. You can also execute a macro several times. 1000@1 will execute macro 1 a thousand times. Remember, this only works in NORMAL mode (press ESC to get there).
Ok, so let's say you have a map that you saved in WorldBuilder, and there are cities, units, and revealed plots saved in there, none of which you want to have. How can we remove them? Let's start with revealed plots, that's easiest.
Remove All Revealed Plots
First, go to the top of the document (CRTL+HOME will get you there). We will now create a macro, let's call it "t" for TeamReveal. Enter NORMAL mode. Type:
No pressing ENTER needed. You'll see in the bottom left that it now says "recording". Now let's search for the first instance of TeamReveal.
Press Enter. Remember that the search function is case sensitive. If you type all lowercase, it won't find anything. You'll get a yellow marked TeamReveal. Now type
This will remove the whole line that says TeamReveal. This way, we can remove ALL TeamReveals, no matter what team number they refer to.
Now stop recording. Press
Ok, we've got Macro 1. What it does: Find a line that says TeamReveal. Delete that line. Since we don't know how many plots are revealed, let's do that 1000 times. This may or may not remove all team reveals. If there are any left, we can simply do it another 1000 times. Go back to the top of the document. Type:
No pressing ENTER required. You will now see the editor quickly go through the text, removing all TeamReveals. If it finished through the document and there were less than 1000 instances, you'll get a red error message at the bottom of the document, stating that there are no TeamReveals left. Done! If you don't get the error message and there are instances left, simply execute the macro another 1000 times: 1000@t
Remove All Units
This is very similar. Every unit is marked with BeginUnit and EndUnit (which comes 5 lines later).
Start recording a macro, we'll call it "u" for units:
Don't press enter. Type
Press ENTER. The first instance of BeginUnit is now marked yellow. Type
Yes, that's SHIFT+V! Don't press enter.
ENTER. Now everything from BeginUnit to EndUnit should be selected. To delete it, press
End recording the macro:
Then go back to the top of the document and execute the macro 1000 times:
Again, if all units are removed you'll get an error message.
Remove All Cities
Works very similarly. The only problem is that cities can have a different number of lines (unlike units, which always are 6 lines). I'll quickly take you through it:
Starts recording the macro.
ENTER.
Yes, that's SHIFT-V, which gets you into VISUAL mode, line select.
ENTER. Selects all text from BeginCity to EndCity.
No enter. Deletes the selected text.
No enter. Stops recording the macro. Go to the top of the document (CRTL+HOME).
No enter. Executes the macro 1000 times.
From Now On...
You should be able simply to type 1000@t to delete all TeamReveals, 1000@u to delete all units, and 1000@c to delete all cities. VIM should save these macros until you re-define them with something different.
This article covers how to do the following things to a WBS file:
- remove all TeamReveals with a few keystrokes
- remove all Units with a few keystrokes
- remove all Cities with a few keystrokes
There are many more things that you can do. Please comment here if you want to do something and you aren't sure how, or if you've found an even quicker way!
Here are all the keystrokes you have to press without explanations. You can be stupid as a monkey, simply load the file and press the keys.
VIM
Ok, after I have written my tutorial on how to make clean maps without causing WorldBuilder to mess stuff up, here's a tip on how to vastly improve your editing speed with one of the most powerful text editors, VIM. You can download VIM here. It's free!
The great thing about VIM: It's very powerful. You can make yourself macros which are very very very helpful if you want to edit a certain thing in your map, maybe over and over again.
The bad thing about VIM: It's pretty damn complex. I haven't mastered it yet, far from it. But I've found some pretty nifty ways to help editing WBS files, and I'll explain them for you all here!
First of all, VIM has three editing modes: NORMAL (what you get when you start VIM, you can't actually write anything into the text file), INSERT (works like the normal text editor), REPLACE (everything you type replaces existing text).
The Modes
NORMAL: You get this mode when VIM comes up. In this mode, you can use all the keyboard shortcuts of VIM. We'll use this mode a lot. If you're in any other mode, pressing ESC gets you back to normal mode.
INSERT & REPLACE: Well, pretty much like any text editor. Enter these modes by pressing the INSERT key on your keyboard (once for insert, twice for replace). Press ESC to get back to normal.
VISUAL: You get there by pressing either "v" or "V". This mode is good for selecting lines of text. If you press "V" (SHIFT+V) you can only select full lines. We'll need that later.
Commands
First off, let me tell you a few useful commands. They work in NORMAL mode, and when you type them you'll see them in the bottom line. Some of them require enter to be executed, others don't.
Code:
/thetext [ENTER] = Searches for all occurrences of "thetext" in your text. This is case sensitive!
/ [ENTER] = Repeats the last search, or goes to the next occurrence in the text.
dd = Deletes the line you're on
q# = Starts recording a macro, where # is a character (0-9, a-z).
q = Finishes recording a macro
@# = Execute macro named #
Now, the cool thing about VIM is that you can tell the program to repeat a certain command an unlimited number of times! So if you type 6dd, it will delete 6 lines - the line your cursor is on and the 5 lines after it. You can also execute a macro several times. 1000@1 will execute macro 1 a thousand times. Remember, this only works in NORMAL mode (press ESC to get there).
Ok, so let's say you have a map that you saved in WorldBuilder, and there are cities, units, and revealed plots saved in there, none of which you want to have. How can we remove them? Let's start with revealed plots, that's easiest.
Remove All Revealed Plots
First, go to the top of the document (CRTL+HOME will get you there). We will now create a macro, let's call it "t" for TeamReveal. Enter NORMAL mode. Type:
Code:
qt
No pressing ENTER needed. You'll see in the bottom left that it now says "recording". Now let's search for the first instance of TeamReveal.
Code:
/TeamReveal
Press Enter. Remember that the search function is case sensitive. If you type all lowercase, it won't find anything. You'll get a yellow marked TeamReveal. Now type
Code:
dd
This will remove the whole line that says TeamReveal. This way, we can remove ALL TeamReveals, no matter what team number they refer to.
Now stop recording. Press
Code:
q
Ok, we've got Macro 1. What it does: Find a line that says TeamReveal. Delete that line. Since we don't know how many plots are revealed, let's do that 1000 times. This may or may not remove all team reveals. If there are any left, we can simply do it another 1000 times. Go back to the top of the document. Type:
Code:
1000@t
No pressing ENTER required. You will now see the editor quickly go through the text, removing all TeamReveals. If it finished through the document and there were less than 1000 instances, you'll get a red error message at the bottom of the document, stating that there are no TeamReveals left. Done! If you don't get the error message and there are instances left, simply execute the macro another 1000 times: 1000@t
Remove All Units
This is very similar. Every unit is marked with BeginUnit and EndUnit (which comes 5 lines later).
Start recording a macro, we'll call it "u" for units:
Code:
qu
Don't press enter. Type
Code:
/BeginUnit
Press ENTER. The first instance of BeginUnit is now marked yellow. Type
Code:
V
Yes, that's SHIFT+V! Don't press enter.
Code:
/EndUnit
ENTER. Now everything from BeginUnit to EndUnit should be selected. To delete it, press
Code:
d
End recording the macro:
Code:
q
Then go back to the top of the document and execute the macro 1000 times:
Code:
1000@u
Again, if all units are removed you'll get an error message.
Remove All Cities
Works very similarly. The only problem is that cities can have a different number of lines (unlike units, which always are 6 lines). I'll quickly take you through it:
Code:
qc
Starts recording the macro.
Code:
/BeginCity
ENTER.
Code:
V
Yes, that's SHIFT-V, which gets you into VISUAL mode, line select.
Code:
/EndCity
ENTER. Selects all text from BeginCity to EndCity.
Code:
d
No enter. Deletes the selected text.
Code:
q
No enter. Stops recording the macro. Go to the top of the document (CRTL+HOME).
Code:
1000@c
No enter. Executes the macro 1000 times.
From Now On...
You should be able simply to type 1000@t to delete all TeamReveals, 1000@u to delete all units, and 1000@c to delete all cities. VIM should save these macros until you re-define them with something different.