Last active
December 22, 2015 01:59
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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>) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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