Skip to content

Instantly share code, notes, and snippets.

@steadystatic
Last active December 25, 2015 00:29
Show Gist options
  • Select an option

  • Save steadystatic/6888634 to your computer and use it in GitHub Desktop.

Select an option

Save steadystatic/6888634 to your computer and use it in GitHub Desktop.
Grabs titles from a csv file for an xml file
function! TitleGrab()
let currentLine = line('.')
let bottomLine = line("$")
while currentLine <= bottomLine
try
let @x = '/media-external
6wvt""ayl:0
/a
'
let @y = 'bhvT,"byh/overlay
/CDATA
wwvt]"cy:0
/c
/textDefault
:s/CDATA\[\]/CDATA\[b\]/g
/labelDefault
:s/CDATA\[\]/CDATA\[b\]/g
/altTExt€kb€kb€kbextDefault
:s/CDATA\[\]/CDATA\[b\]/g
j$'
let @z = '/media-external
j'
let @s = '
hj'
let l:MissionSuccess = 1
:normal @x
catch
let l:MissionSuccess = 0
sleep 1
:normal @s
finally
if (l:MissionSuccess == 1)
:normal @y
sleep 1
:normal @z
endif
endtry
endwhile
endfunction
@steadystatic
Copy link
Author

With this I made good use of registers and printed what was in the register after doing one or two XML blocks into my script...setup a key to call the function, and off vim went! The try catch is super nice for when you don't find a result searching for something, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment