Notepad++ Keystroke Macros

TAFE supplied a list of coordinates for a polygon in the Lockhart NSW area, but they have the X and Y coordinate values flipped around. So when I checked the supplied data in Leaflet, the polygon was not shown in the geographic extent.

Below is an example when a few of the coordinate values are flipped back correctly... it plots some of the points of the polygon in the correct geographic extent, and then the rest of the points lead off somewhere on the other side of the planet (somewhere in the Northern Hemisphere).


I initially started doing this job manually - copy and pasting coordinates in Notepad++. After the first dozen or so i got sick of it and there were hundreds of values!


I haven't used keystroke macros in a while - at least not since my gaming days writing bots for MMORPGs. After researching a few web pages I discovered that Notepad++ can record keystroke macros with relative ease and decided to create one for this job. Something that would have taken hours and part of my sanity was simplified into about 2 lines of code and then repeated about 100+ times! MINIMUM EFFORT, MAXIMUM EFFICIENCY!

Go to context menu > macro > start recording...


I only needed to record a macro for the first line: copying the first value and flipping positions with the second value, then adding/removing excess syntax.


...then repeat the macro until i reach the end of the script.


A summary of using macros in Notepad++ below (ripped from Lifehacker):


The final result is shown below. SUCCESS! The LGA polygon is now displayed in the geographic extent and everything appears to work in the interactive map.


In retrospect if i knew more about Javascript then i could have skipped the hassle of reversing the coordinates but since i had to rip the coordinates out and put it into ArcGIS, a macro is still quicker than learning Javascript from scratch.




notepad++, keystrokes, macros, scripting, javascript, gis, leaflet