diff options
author | Teddy Wing | 2018-03-05 20:22:33 +0100 |
---|---|---|
committer | Teddy Wing | 2018-03-05 20:22:33 +0100 |
commit | 0baa8a98fbca4972cfc13475f3461ffd164b94ac (patch) | |
tree | ce3e11dbe50e8cc0b34bdafbde1fb04bec99a77d | |
download | vim-rails-locale-alternate-0baa8a98fbca4972cfc13475f3461ffd164b94ac.tar.bz2 |
Add commands to open an alternate Rails locale file
Two new commands that will open an alternate Rails locale file in either
a horizontal or vertical split. Takes the current filename and replaces
the two-letter language code with the argument given to the command.
-rw-r--r-- | ftplugin/ruby_rails_locale_alternate.vim | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/ftplugin/ruby_rails_locale_alternate.vim b/ftplugin/ruby_rails_locale_alternate.vim new file mode 100644 index 0000000..ef4934b --- /dev/null +++ b/ftplugin/ruby_rails_locale_alternate.vim @@ -0,0 +1,14 @@ +function! s:AlternateLocale(key) + let filename = expand('%') + let alternate = substitute(filename, '..\.yml', a:key . '.yml', '') + return alternate +endfunction + + +function! s:SplitAlternate(key) + execute 'split ' . s:AlternateLocale(a:key) +endfunction + + +command! -buffer -nargs=1 SRailsLocaleAlternate :call s:SplitAlternate(<args>) +command! -buffer -nargs=1 VRailsLocaleAlternate :call s:SplitAlternate(<args>) |