[Tip] Using Notepad, sed to save you time with editing entities, brushes, materials.

teddyruxpin

Sr. Hygiene Technician
Mar 24, 2008
83
26
Some basic Notepad, sed, grep tips to save you time with mapping.

Problem 1: You need to rename a large number of entities in your map and do not want to go through each of them via hammer and do it manually.

Problem 2: You are converting a map from another game (CSS) and have some missing files you can not find but know some part of the name of them or type ( Materials, Textures, overlayers, models etc etc.)

Problem 3: You got allot of some form of text in hammer you need to change on any sort of brushes, entities, comments, materials, models etc etc.

Problem 4: You put a " or ' in the text field box in hammer and the map now crashes on load after being saved. Find them and delete them.



Problem 1 Solution: Basic Text editor application.

1: Locate your map VMF file with windows explorer and backup the file by making a copy of it and renaming it as a back up.

2: Open your text editor application. In this example we will use Notepad. Which is a default application that comes with all versions of Windows. Start > Programs > Accessories > Notepad.

3: From the text editor goto the File > Open. Select from the pop up window to open 'All Files' and change it from the 'Text' only. This should allow you to now see non text based files. Locate the map VMF file via this menu and select it. This will open your map file in the text editor and you will see your map is simply a bunch of text. This may take a few moments depending on the size of your map.

4: From the text editor select the 'Edit > Find' option or press 'Ctrl + F' this will then pop-up the 'Find and Replace' menu. From there simply enter the text string you want to find and its replacement. The application will then go through the entire map and change all instances of that string. Including the entities names and input and outputs, comments etc.

5: Save VMF file and exit the notepad application. Open the file now in Hammer and check it over for any sort of errors with 'Alt+P' and a cursory review. Run the map and give it a test and check the dev console for errors.

You can use any text editor for this. Make sure that you only use it in 'Plain Text' mode only and note RTF etc or you will destroy stuff.

Problem 2 Solution: With the text file open use the 'Find' tool to search for the folder string from the previous map gameplay type. IE '/css/materials' this will then allow you to go from instance to instance top to bottom of the map and find and replace each entry as needed or locate hard to find ones that cant be easily found in Hammer.

Problem 3 Solution: See #1 #2

Problem 4 Solution: See #2 and just look for the " or ' with the find tool.

*nix Geeks

If your a *nix geek or use OSX you can also use sed, vi etc.

Code:
cat mapfilename.vmf | sed 's/stringyouwanttoreplace/stringtoreplacewith/g' > mapfilename.new.vmf

or

Code:
cat mapfilename.vmf | sed 's/string1youwanttoreplace/string1toreplacewith/g;string2toreplace/string2toreplacewith;s/string3toreplace/string3toreplacewith/g' >
mapfilename.new.vmf

You can also use 'grep' to remove portions of the map.

Code:
cat mapfilename.vmf | grep -v "textstring" > mapfilename.new.vmf

-Teddy
 
Last edited:

Malcolm

L3: Member
Jul 10, 2008
123
25
but nice tips anyway!

Don't forget the tf_logic_arena, its Outputs must be written outside Hammer using Notepad to enable Arena-Mode fully.