aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--autoload/rails_locale_alternate.vim18
-rw-r--r--plugin/rails_locale_alternate.vim21
2 files changed, 19 insertions, 20 deletions
diff --git a/autoload/rails_locale_alternate.vim b/autoload/rails_locale_alternate.vim
new file mode 100644
index 0000000..bf33b89
--- /dev/null
+++ b/autoload/rails_locale_alternate.vim
@@ -0,0 +1,18 @@
+function! s:AlternateLocale(key)
+ let filename = expand('%')
+ let alternate = substitute(filename, '\a\{2}\.yml', a:key . '.yml', '')
+ return alternate
+endfunction
+
+
+function! s:SplitAlternate(key, modifiers)
+ execute a:modifiers . ' split ' . s:AlternateLocale(a:key)
+endfunction
+
+
+function! rails_locale_alternate#CreateCommands()
+ command! -buffer -nargs=1 RailsLocaleAlternate :call s:SplitAlternate(<q-args>, <q-mods>)
+ command! -buffer -nargs=1 ERailsLocaleAlternate :execute 'edit ' . s:AlternateLocale(<q-args>)
+ command! -buffer -nargs=1 SRailsLocaleAlternate :call s:SplitAlternate(<q-args>, '')
+ command! -buffer -nargs=1 VRailsLocaleAlternate :call s:SplitAlternate(<q-args>, 'vertical')
+endfunction
diff --git a/plugin/rails_locale_alternate.vim b/plugin/rails_locale_alternate.vim
index b0a82f0..4d161e3 100644
--- a/plugin/rails_locale_alternate.vim
+++ b/plugin/rails_locale_alternate.vim
@@ -1,24 +1,5 @@
-function! s:AlternateLocale(key)
- let filename = expand('%')
- let alternate = substitute(filename, '\a\{2}\.yml', a:key . '.yml', '')
- return alternate
-endfunction
-
-
-function! s:SplitAlternate(key, modifiers)
- execute a:modifiers . ' split ' . s:AlternateLocale(a:key)
-endfunction
-
-
-function! s:CreateCommands()
- command! -buffer -nargs=1 RailsLocaleAlternate :call s:SplitAlternate(<q-args>, <q-mods>)
- command! -buffer -nargs=1 ERailsLocaleAlternate :execute 'edit ' . s:AlternateLocale(<q-args>)
- command! -buffer -nargs=1 SRailsLocaleAlternate :call s:SplitAlternate(<q-args>, '')
- command! -buffer -nargs=1 VRailsLocaleAlternate :call s:SplitAlternate(<q-args>, 'vertical')
-endfunction
-
augroup rails_locale_alternate
autocmd!
- autocmd BufNewFile,BufRead config/locales/*.\a\a.yml call s:CreateCommands()
+ autocmd BufNewFile,BufRead config/locales/*.\a\a.yml call rails_locale_alternate#CreateCommands()
augroup END