Skip to content

Instantly share code, notes, and snippets.

@munen
Last active December 22, 2015 01:59
Show Gist options
  • Select an option

  • Save munen/6399903 to your computer and use it in GitHub Desktop.

Select an option

Save munen/6399903 to your computer and use it in GitHub Desktop.
Vimscript / Ruby function to find a key in a nested yaml key/value pair (i.e. a Rails translation)
function! FindTranslation(pat)
let s = ""
ruby << EOF
pat = VIM::evaluate 'a:pat'
pat = pat.gsub("\.", ":\\\\\\n\ *")
s = "normal! gg/#{pat}/e+1\\<cr>"
VIM::command "let s = \"#{s}\""
VIM::command "execute s"
EOF
endfunction
command! -nargs=1 FindTranslation call FindTranslation(<f-args>)
maunz:
braunz: "fooBar"
foo:
bar:
baz: "hallo welt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment