<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>dot.vim/.netrwhist</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,10 +1,10 @@
 ScriptId SourceID Filename
 --------------------------
-1567 10297 :AutoInstall: rails.vim
+1567 11481 :AutoInstall: rails.vim
 1234 11289 :AutoInstall: yankring.vim
 1697 8283 :AutoInstall: surround.vim
 2386 9299 :AutoInstall: endwise.vim
 23 8319 :AutoInstall: enhcommentify.tar.gz
-2423 10964 :AutoInstall: gist.vim
+2423 11634 :AutoInstall: gist.vim
 2478 9644 :: as3_omnicomplete.vim.zip
 1934 7990 :: git-commit.tar</diff>
      <filename>dot.vim/GetLatest/GetLatestVimScripts.dat</filename>
    </modified>
    <modified>
      <diff>@@ -13,7 +13,7 @@
 if &amp;cp || exists(&quot;g:autoloaded_rails&quot;)
   finish
 endif
-let g:autoloaded_rails = '3.4'
+let g:autoloaded_rails = '4.0'
 
 let s:cpo_save = &amp;cpo
 set cpo&amp;vim
@@ -21,6 +21,9 @@ set cpo&amp;vim
 &quot; Utility Functions {{{1
 
 let s:app_prototype = {}
+let s:file_prototype = {}
+let s:buffer_prototype = {}
+let s:readable_prototype = {}
 
 function! s:add_methods(namespace, method_names)
   for name in a:method_names
@@ -139,7 +142,7 @@ function! s:app_find_file(name, ...) dict abort
         let found = findfile(a:name,path,i)
       endwhile
     endif
-    return found == &quot;&quot; ? found : s:gsub(strpart(fnamemodify(found,':p'),trim),'\\','/')
+    return found == &quot;&quot; ? default : s:gsub(strpart(fnamemodify(found,':p'),trim),'\\','/')
   finally
     let &amp;l:suffixesadd = oldsuffixesadd
   endtry
@@ -178,73 +181,99 @@ function! s:pathjoin(...) abort
   return substitute(path,'^,','','')
 endfunction
 
-function! s:endof(lnum)
+function! s:readable_end_of(lnum) dict abort
   if a:lnum == 0
     return 0
   endif
-  if &amp;ft == &quot;yaml&quot; || expand(&quot;%:e&quot;) == &quot;yml&quot;
+  if self.name() =~# '\.yml$'
     return -1
   endif
-  let cline = getline(a:lnum)
+  let cline = self.getline(a:lnum)
   let spc = matchstr(cline,'^\s*')
   let endpat = '\&lt;end\&gt;'
-  if matchstr(getline(a:lnum+1),'^'.spc) &amp;&amp; !matchstr(getline(a:lnum+1),'^'.spc.endpat) &amp;&amp; matchstr(cline,endpat)
+  if matchstr(self.getline(a:lnum+1),'^'.spc) &amp;&amp; !matchstr(self.getline(a:lnum+1),'^'.spc.endpat) &amp;&amp; matchstr(cline,endpat)
     return a:lnum
   endif
   let endl = a:lnum
-  while endl &lt;= line('$')
+  while endl &lt;= self.line_count()
     let endl += 1
-    if getline(endl) =~ '^'.spc.endpat
+    if self.getline(endl) =~ '^'.spc.endpat
       return endl
-    elseif getline(endl) =~ '^=begin\&gt;'
-      while getline(endl) !~ '^=end\&gt;' &amp;&amp; endl &lt;= line('$')
+    elseif self.getline(endl) =~ '^=begin\&gt;'
+      while self.getline(endl) !~ '^=end\&gt;' &amp;&amp; endl &lt;= self.line_count()
         let endl += 1
       endwhile
       let endl += 1
-    elseif getline(endl) !~ '^'.spc &amp;&amp; getline(endl) !~ '^\s*\%(#.*\)\=$'
+    elseif self.getline(endl) !~ '^'.spc &amp;&amp; self.getline(endl) !~ '^\s*\%(#.*\)\=$'
       return 0
     endif
   endwhile
   return 0
 endfunction
 
-function! s:lastopeningline(pattern,limit,...)
-  let line = a:0 ? a:1 : line(&quot;.&quot;)
-  while line &gt; a:limit &amp;&amp; getline(line) !~ a:pattern
+function! s:endof(lnum)
+  return rails#buffer().end_of(a:lnum)
+endfunction
+
+function! s:readable_last_opening_line(start,pattern,limit) dict abort
+  let line = a:start
+  while line &gt; a:limit &amp;&amp; self.getline(line) !~ a:pattern
     let line -= 1
   endwhile
-  let lend = s:endof(line)
-  if line &gt; a:limit &amp;&amp; (lend &lt; 0 || lend &gt;= (a:0 ? a:1 : line(&quot;.&quot;)))
+  let lend = self.end_of(line)
+  if line &gt; a:limit &amp;&amp; (lend &lt; 0 || lend &gt;= a:start)
     return line
   else
     return -1
   endif
 endfunction
 
-function! s:lastmethodline(...)
-  return s:lastopeningline(&amp;l:define,0,a:0 ? a:1 : line(&quot;.&quot;))
+function! s:lastopeningline(pattern,limit,start)
+  return rails#buffer().last_opening_line(a:start,a:pattern,a:limit)
 endfunction
 
-function! s:lastmethod(...)
-  let line = s:lastmethodline(a:0 ? a:1 : line(&quot;.&quot;))
+function! s:readable_define_pattern() dict abort
+  if self.name() =~ '\.yml$'
+    return '^\%(\h\k*:\)\@='
+  endif
+  let define = '^\s*def\s\+\(self\.\)\='
+  if self.name() =~# '\.rake$'
+    let define .= &quot;\\\|^\\s*\\%(task\\\|file\\)\\s\\+[:'\&quot;]&quot;
+  endif
+  if self.name() =~# '/schema\.rb$'
+    let define .= &quot;\\\|^\\s*create_table\\s\\+[:'\&quot;]&quot;
+  endif
+  return define
+endfunction
+
+function! s:readable_last_method_line(start) dict abort
+  return self.last_opening_line(a:start,self.define_pattern(),0)
+endfunction
+
+function! s:lastmethodline(start)
+  return rails#buffer().last_method_line(a:start)
+endfunction
+
+function! s:readable_last_method(start) dict abort
+  let line = self.last_method_line(a:start)
   if line
-    return s:sub(matchstr(getline(line),'\%('.&amp;define.'\)\zs\h\%(\k\|[:.]\)*[?!=]\='),':$','')
+    return s:sub(matchstr(self.getline(line),'\%('.self.define_pattern().'\)\zs\h\%(\k\|[:.]\)*[?!=]\='),':$','')
   else
     return &quot;&quot;
   endif
 endfunction
 
-function! s:lastrespondtoline(...)
-  return s:lastopeningline('\C^\s*respond_to\s*\%(\&lt;do\)\s*|\zs\h\k*\ze|',s:lastmethodline(), a:0 ? a:1 : line(&quot;.&quot;))
+function! s:lastmethod(...)
+  return rails#buffer().last_method(a:0 ? a:1 : line(&quot;.&quot;))
 endfunction
 
-function! s:lastformat()
-  let rline = s:lastrespondtoline()
+function! s:readable_last_format(start) dict abort
+  let rline = self.last_opening_line('\C^\s*respond_to\s*\%(\&lt;do\)\s*|\zs\h\k*\ze|',self.last_method_line(a:start),a:start)
   if rline
-    let variable = matchstr(getline(rline),'\C^\s*respond_to\s*\%(\&lt;do\|{\)\s*|\zs\h\k*\ze|')
-    let line = line('.')
+    let variable = matchstr(self.getline(rline),'\C^\s*respond_to\s*\%(\&lt;do\|{\)\s*|\zs\h\k*\ze|')
+    let line = a:start
     while line &gt; rline
-      let match = matchstr(getline(line),'\C^\s*'.variable.'\s*\.\s*\zs\h\k*')
+      let match = matchstr(self.getline(line),'\C^\s*'.variable.'\s*\.\s*\zs\h\k*')
       if match != ''
         return match
       endif
@@ -254,11 +283,15 @@ function! s:lastformat()
   return &quot;&quot;
 endfunction
 
+function! s:lastformat(start)
+  return rails#buffer().last_format(a:start)
+endfunction
+
 function! s:format(...)
   if RailsFileType() =~ '^view\&gt;'
     let format = fnamemodify(RailsFilePath(),':r:e')
   else
-    let format = s:lastformat()
+    let format = rails#buffer().last_format(a:0 &gt; 1 ? a:2 : line(&quot;.&quot;))
   endif
   if format == ''
     return get({'rhtml': 'html', 'rxml': 'xml', 'rjs': 'js'},fnamemodify(RailsFilePath(),':e'),a:0 ? a:1 : '')
@@ -266,6 +299,8 @@ function! s:format(...)
   return format
 endfunction
 
+call s:add_methods('readable',['end_of','last_opening_line','last_method_line','last_method','last_format','define_pattern'])
+
 let s:view_types = 'rhtml,erb,rxml,builder,rjs,mab,liquid,haml,dryml,mn'
 
 function! s:viewspattern()
@@ -273,11 +308,13 @@ function! s:viewspattern()
 endfunction
 
 function! s:controller(...)
-  let t = RailsFileType()
-  let f = RailsFilePath()
-  let o = s:getopt(&quot;controller&quot;,&quot;lb&quot;)
-  if o != &quot;&quot;
-    return o
+  return rails#buffer().controller_name(a:0 ? a:1 : 0)
+endfunction
+
+function! s:readable_controller_name(...) dict abort
+  let f = self.name()
+  if has_key(self,'getvar') &amp;&amp; self.getvar('rails_controller') != ''
+    return self.getvar('rails_controller')
   elseif f =~ '\&lt;app/views/layouts/'
     return s:sub(f,'.*&lt;app/views/layouts/(.{-})\..*','\1')
   elseif f =~ '\&lt;app/views/'
@@ -300,21 +337,24 @@ function! s:controller(...)
     return s:sub(f,'.*&lt;components/(.{-})_controller\.rb$','\1')
   elseif f =~ '\&lt;components/.*\.'.s:viewspattern().'$'
     return s:sub(f,'.*&lt;components/(.{-})/\k+\.\k+$','\1')
-  elseif f =~ '\&lt;app/models/.*\.rb$' &amp;&amp; t =~ '^model-mailer\&gt;'
+  elseif f =~ '\&lt;app/models/.*\.rb$' &amp;&amp; self.type_name('model-mailer')
     return s:sub(f,'.*&lt;app/models/(.{-})\.rb$','\1')
   elseif f =~ '\&lt;public/stylesheets/.*\.css$'
     return s:sub(f,'.*&lt;public/stylesheets/(.{-})\.css$','\1')
   elseif a:0 &amp;&amp; a:1
-    return rails#pluralize(s:model())
+    return rails#pluralize(self.model_name())
   endif
   return &quot;&quot;
 endfunction
 
 function! s:model(...)
-  let f = RailsFilePath()
-  let o = s:getopt(&quot;model&quot;,&quot;lb&quot;)
-  if o != &quot;&quot;
-    return o
+  return rails#buffer().model_name(a:0 ? a:1 : 0)
+endfunction
+
+function! s:readable_model_name(...) dict abort
+  let f = self.name()
+  if has_key(self,'getvar') &amp;&amp; self.getvar('rails_model') != ''
+    return self.getvar('rails_model')
   elseif f =~ '\&lt;app/models/.*_observer.rb$'
     return s:sub(f,'.*&lt;app/models/(.*)_observer\.rb$','\1')
   elseif f =~ '\&lt;app/models/.*\.rb$'
@@ -327,16 +367,20 @@ function! s:model(...)
     return s:sub(f,'.*&lt;spec/models/(.*)_spec\.rb$','\1')
   elseif f =~ '\&lt;\%(test\|spec\)/fixtures/.*\.\w*\~\=$'
     return rails#singularize(s:sub(f,'.*&lt;%(test|spec)/fixtures/(.*)\.\w*\~=$','\1'))
+  elseif f =~ '\&lt;\%(test\|spec\)/blueprints/.*\.rb$'
+    return s:sub(f,'.*&lt;%(test|spec)/blueprints/(.{-})%(_blueprint)=\.rb$','\1')
   elseif f =~ '\&lt;\%(test\|spec\)/exemplars/.*_exemplar\.rb$'
     return s:sub(f,'.*&lt;%(test|spec)/exemplars/(.*)_exemplar\.rb$','\1')
-  elseif f =~ '\&lt;\%(test\|spec\)/factories/.*\.rb$'
-    return s:sub(f,'.*&lt;%(test|spec)/factories/(.{-})%(_factory)=\.rb$','\1')
+  elseif f =~ '\&lt;\%(test/\|spec/\)\=factories/.*\.rb$'
+    return s:sub(f,'.*&lt;%(test/|spec/)=factories/(.{-})%(_factory)=\.rb$','\1')
   elseif a:0 &amp;&amp; a:1
-    return rails#singularize(s:controller())
+    return rails#singularize(self.controller_name())
   endif
   return &quot;&quot;
 endfunction
 
+call s:add_methods('readable',['controller_name','model_name'])
+
 function! s:readfile(path,...)
   let nr = bufnr('^'.a:path.'$')
   if nr &lt; 0 &amp;&amp; exists('+shellslash') &amp;&amp; ! &amp;shellslash
@@ -353,6 +397,39 @@ function! s:readfile(path,...)
   endif
 endfunction
 
+function! s:file_lines() dict abort
+  let ftime = getftime(self.path)
+  if ftime &gt; get(self,last_lines_ftime,0)
+    let self.last_lines = readfile(self.path())
+    let self.last_lines_ftime = ftime
+  endif
+  return get(self,'last_lines',[])
+endfunction
+
+function! s:file_getline(lnum,...) dict abort
+  if a:0
+    return self.lines[lnum-1 : a:1-1]
+  else
+    return self.lines[lnum-1]
+  endif
+endfunction
+
+function! s:buffer_lines() dict abort
+  return self.getline(1,'$')
+endfunction
+
+function! s:buffer_getline(...) dict abort
+  if a:0 == 1
+    return get(call('getbufline',[self.number()]+a:000),0,'')
+  else
+    return call('getbufline',[self.number()]+a:000)
+  endif
+endfunction
+
+function! s:readable_line_count() dict abort
+  return len(self.lines())
+endfunction
+
 function! s:environment()
   if exists('$RAILS_ENV')
     return $RAILS_ENV
@@ -389,6 +466,16 @@ function! s:debug(str)
   endif
 endfunction
 
+function! s:buffer_getvar(varname) dict abort
+  return getbufvar(self.number(),a:varname)
+endfunction
+
+function! s:buffer_setvar(varname, val) dict abort
+  return setbufvar(self.number(),a:varname,a:val)
+endfunction
+
+call s:add_methods('buffer',['getvar','setvar'])
+
 &quot; }}}1
 &quot; &quot;Public&quot; Interface {{{1
 
@@ -421,7 +508,7 @@ function! rails#singularize(word)
   let word = s:sub(word,'ves$','fs')
   let word = s:sub(word,'ss%(es)=$','sss')
   let word = s:sub(word,'s$','')
-  let word = s:sub(word,'%(tatus|lias)\zse$','')
+  let word = s:sub(word,'%([nrt]ch|tatus|lias)\zse$','')
   let word = s:sub(word,'%(nd|rt)\zsice$','ex')
   return word
 endfunction
@@ -447,6 +534,23 @@ function! rails#app(...)
   return get(s:apps,root,0)
 endfunction
 
+function! rails#buffer(...)
+  return extend(extend({'#': bufnr(a:0 ? a:1 : '%')},s:buffer_prototype,'keep'),s:readable_prototype,'keep')
+  endif
+endfunction
+
+function! s:buffer_app() dict abort
+  if self.getvar('rails_root') != ''
+    return rails#app(self.getvar('rails_root'))
+  else
+    return 0
+  endif
+endfunction
+
+function! s:readable_app() dict abort
+  return self._app
+endfunction
+
 function! RailsRevision()
   return 1000*matchstr(g:autoloaded_rails,'^\d\+')+matchstr(g:autoloaded_rails,'[1-9]\d*$')
 endfunction
@@ -459,29 +563,53 @@ function! RailsRoot()
   endif
 endfunction
 
-function! RailsFilePath()
-  if !exists(&quot;b:rails_root&quot;)
-    return &quot;&quot;
-  elseif exists(&quot;b:rails_file_path&quot;)
-    return b:rails_file_path
-  endif
-  let f = s:gsub(expand('%:p'),'\\ @!','/')
+function! s:app_file(name)
+  return extend(extend({'_app': self, '_name': a:name}, s:file_prototype,'keep'),s:readable_prototype,'keep')
+endfunction
+
+function! s:file_path() dict abort
+  return self.app().path(self._name)
+endfunction
+
+function! s:file_name() dict abort
+  return self._name
+endfunction
+
+function! s:buffer_number() dict abort
+  return self['#']
+endfunction
+
+function! s:buffer_path() dict abort
+  return s:gsub(fnamemodify(bufname(self.number()),':p'),'\\ @!','/')
+endfunction
+
+function! s:buffer_name() dict abort
+  let app = self.app()
+  let f = s:gsub(fnamemodify(bufname(self.number()),':p'),'\\ @!','/')
   let f = s:sub(f,'/$','')
   let sep = matchstr(f,'^[^\\/]\{3,\}\zs[\\/]')
   if sep != &quot;&quot;
     let f = getcwd().sep.f
   endif
-  if s:startswith(f,s:gsub(b:rails_root,'\\ @!','/')) || f == &quot;&quot;
-    return strpart(f,strlen(b:rails_root)+1)
+  if s:startswith(f,s:gsub(app.path(),'\\ @!','/')) || f == &quot;&quot;
+    return strpart(f,strlen(app.path())+1)
   else
     if !exists(&quot;s:path_warn&quot;)
       let s:path_warn = 1
-      call s:warn(&quot;File &quot;.f.&quot; does not appear to be under the Rails root &quot;.b:rails_root.&quot;. Please report to the rails.vim author!&quot;)
+      call s:warn(&quot;File &quot;.f.&quot; does not appear to be under the Rails root &quot;.self.app().path().&quot;. Please report to the rails.vim author!&quot;)
     endif
     return f
   endif
 endfunction
 
+function! RailsFilePath()
+  if !exists(&quot;b:rails_root&quot;)
+    return &quot;&quot;
+  else
+    return rails#buffer().name()
+  endif
+endfunction
+
 function! RailsFile()
   return RailsFilePath()
 endfunction
@@ -489,18 +617,16 @@ endfunction
 function! RailsFileType()
   if !exists(&quot;b:rails_root&quot;)
     return &quot;&quot;
-  elseif exists(&quot;b:rails_cached_file_type&quot;)
-    return b:rails_cached_file_type
   else
-    return rails#app().calculate_file_type(RailsFilePath())
-  endif
+    return rails#buffer().type_name()
+  end
 endfunction
 
-function! s:app_calculate_file_type(path) dict
-  let f = a:path
+function! s:readable_calculate_file_type() dict abort
+  let f = self.name()
   let e = fnamemodify(f,':e')
-  let r = &quot;&quot;
-  let full_path = self.path(f)
+  let r = &quot;-&quot;
+  let full_path = self.path()
   let nr = bufnr('^'.full_path.'$')
   if nr &lt; 0 &amp;&amp; exists('+shellslash') &amp;&amp; ! &amp;shellslash
     let nr = bufnr('^'.s:gsub(full_path,'/','\\').'$')
@@ -581,7 +707,11 @@ function! s:app_calculate_file_type(path) dict
     let r = &quot;task&quot;
   elseif f =~ '\&lt;log/.*\.log$'
     let r = &quot;log&quot;
-  elseif e == &quot;css&quot; || e == &quot;js&quot; || e == &quot;html&quot;
+  elseif e == &quot;css&quot; || e == &quot;sass&quot;
+    let r = &quot;stylesheet-&quot;.e
+  elseif e == &quot;js&quot;
+    let r = &quot;javascript&quot;
+  elseif e == &quot;html&quot;
     let r = e
   elseif f =~ '\&lt;config/routes\&gt;.*\.rb$'
     let r = &quot;config-routes&quot;
@@ -591,6 +721,27 @@ function! s:app_calculate_file_type(path) dict
   return r
 endfunction
 
+function! s:buffer_type_name(...) dict abort
+  let type = getbufvar(self.number(),'rails_cached_file_type')
+  if type == ''
+    let type = self.calculate_file_type()
+  endif
+  return call('s:match_type',[type == '-' ? '' : type] + a:000)
+endfunction
+
+function! s:readable_type_name() dict abort
+  let type = self.calculate_file_type()
+  return call('s:match_type',[type == '-' ? '' : type] + a:000)
+endfunction
+
+function! s:match_type(type,...)
+  if a:0
+    return !empty(filter(copy(a:000),'a:type =~# &quot;^&quot;.v:val.&quot;\\&gt;&quot;'))
+  else
+    return a:type
+  endif
+endfunction
+
 function! s:app_environments() dict
   if self.cache.needs('environments')
     call self.cache.set('environments',self.relglob('config/environments/','**/*','.rb'))
@@ -598,6 +749,14 @@ function! s:app_environments() dict
   return copy(self.cache.get('environments'))
 endfunction
 
+function! s:app_default_locale() dict abort
+  if self.cache.needs('default_locale')
+    let candidates = map(filter(s:readfile(self.path('config/environment.rb')),'v:val =~ &quot;^ *config.i18n.default_locale = :[\&quot;'']\\=[A-Za-z-]\\+[\&quot;'']\\= *$&quot;'),'matchstr(v:val,&quot;[A-Za-z-]\\+[\&quot;'']\\= *$&quot;)')
+    call self.cache.set('default_locale',get(candidates,0,'en'))
+  endif
+  return self.cache.get('default_locale')
+endfunction
+
 function! s:app_has(feature) dict
   let map = {
         \'test': 'test/',
@@ -620,7 +779,10 @@ function! s:app_test_suites() dict
   return filter(['test','spec','cucumber'],'self.has(v:val)')
 endfunction
 
-call s:add_methods('app',['calculate_file_type','environments','has','test_suites'])
+call s:add_methods('app',['default_locale','environments','file','has','test_suites'])
+call s:add_methods('file',['path','name','lines','getline'])
+call s:add_methods('buffer',['app','number','path','name','lines','getline','type_name'])
+call s:add_methods('readable',['app','calculate_file_type','type_name','line_count'])
 
 &quot; }}}1
 &quot; Ruby Execution {{{1
@@ -685,16 +847,6 @@ endfunction
 
 call s:add_methods('app', ['ruby_shell_command','execute_ruby_command','background_ruby_command','lightweight_ruby_eval','eval'])
 
-function! RailsEval(ruby,...) abort
-  if !exists(&quot;b:rails_root&quot;)
-    return a:0 ? a:1 : &quot;&quot;
-  elseif a:0
-    return rails#app().eval(a:ruby,a:1)
-  else
-    return rails#app().eval(a:ruby)
-  endif
-endfunction
-
 &quot; }}}1
 &quot; Commands {{{1
 
@@ -737,19 +889,19 @@ function! s:BufCommands()
         \   exe RailsHelpCommand(&lt;q-args&gt;) |
         \ else | call s:Doc(&lt;bang&gt;0,&lt;q-args&gt;) | endif
   command! -buffer -bar -nargs=0 -bang Rrefresh :if &lt;bang&gt;0|unlet! g:autoloaded_rails|source `=s:file`|endif|call s:Refresh(&lt;bang&gt;0)
-  if exists(&quot;:Project&quot;)
-    command! -buffer -bar -nargs=? Rproject :call s:Project(&lt;bang&gt;0,&lt;q-args&gt;)
-  elseif exists(&quot;:NERDTree&quot;)
-    command! -buffer -bar -nargs=? Rproject :NERDTree `=rails#app().path()`
+  if exists(&quot;:NERDTree&quot;)
+    command! -buffer -bar -nargs=? -complete=customlist,s:Complete_cd Rtree :NERDTree `=rails#app().path(&lt;f-args&gt;)`
+  elseif exists(&quot;:Project&quot;)
+    command! -buffer -bar -nargs=? Rtree :call s:Project(&lt;bang&gt;0,&lt;q-args&gt;)
   endif
+  command! -buffer -bar -nargs=? Rproject :call s:warn(&quot;Warning: :Rproject has been deprecated in favor of :Rtree&quot;) | Rtree&lt;bang&gt; &lt;args&gt;
   if exists(&quot;g:loaded_dbext&quot;)
-    command! -buffer -bar -nargs=? -bang  -complete=customlist,s:Complete_environments Rdbext  :call s:BufDatabase(2,&lt;q-args&gt;,&lt;bang&gt;0)|let b:dbext_buffer_defaulted = 1
+    command! -buffer -bar -nargs=? -complete=customlist,s:Complete_environments Rdbext  :call s:BufDatabase(2,&lt;q-args&gt;)|let b:dbext_buffer_defaulted = 1
   endif
   let ext = expand(&quot;%:e&quot;)
   if ext =~ s:viewspattern()
     &quot; TODO: complete controller names with trailing slashes here
     command! -buffer -bar -nargs=? -range -complete=customlist,s:controllerList Rextract :&lt;line1&gt;,&lt;line2&gt;call s:Extract(&lt;bang&gt;0,&lt;f-args&gt;)
-    command! -buffer -bar -nargs=? -range Rpartial :call s:warn(&quot;Warning: :Rpartial has been deprecated in favor of :Rextract&quot;) | &lt;line1&gt;,&lt;line2&gt;Rextract&lt;bang&gt; &lt;args&gt;
   endif
   if RailsFilePath() =~ '\&lt;db/migrate/.*\.rb$'
     command! -buffer -bar                 Rinvert  :call s:Invert(&lt;bang&gt;0)
@@ -803,8 +955,13 @@ endfunction
 
 function! rails#new_app_command(bang,...)
   if a:0 == 0
-    if a:bang
-      echo &quot;rails.vim version &quot;.g:autoloaded_rails
+    let msg = &quot;rails.vim &quot;.g:autoloaded_rails
+    if a:bang &amp;&amp; exists('b:rails_root') &amp;&amp; RailsFileType() == ''
+      echo msg.&quot; (Rails)&quot;
+    elseif a:bang &amp;&amp; exists('b:rails_root')
+      echo msg.&quot; (Rails-&quot;.RailsFileType().&quot;)&quot;
+    elseif a:bang
+      echo msg
     else
       !rails
     endif
@@ -858,7 +1015,7 @@ endfunction
 call s:add_methods('app',['tags_command'])
 
 function! s:Refresh(bang)
-  if exists(&quot;g:rubycomplete_rails&quot;) &amp;&amp; g:rubycomplete_rails &amp;&amp; has(&quot;ruby&quot;)
+  if exists(&quot;g:rubycomplete_rails&quot;) &amp;&amp; g:rubycomplete_rails &amp;&amp; has(&quot;ruby&quot;) &amp;&amp; exists('g:rubycomplete_completions')
     silent! ruby ActiveRecord::Base.reset_subclasses if defined?(ActiveRecord)
     silent! ruby if defined?(ActiveSupport::Dependencies); ActiveSupport::Dependencies.clear; elsif defined?(Dependencies); Dependencies.clear; end
     if a:bang
@@ -920,75 +1077,25 @@ endfunction
 
 call s:add_methods('app', ['rake_tasks'])
 
-&quot; Current directory
-let s:efm='%D(in\ %f),'
-&quot; Failure and Error headers, start a multiline message
-let s:efm=s:efm
-      \.'%A\ %\\+%\\d%\\+)\ Failure:,'
-      \.'%A\ %\\+%\\d%\\+)\ Error:,'
-      \.'%+A'.&quot;'&quot;.'%.%#'.&quot;'&quot;.'\ FAILED,'
-&quot; Exclusions
-let s:efm=s:efm
-      \.'%C%.%#(eval)%.%#,'
-      \.'%C-e:%.%#,'
-      \.'%C%.%#/lib/gems/%\\d.%\\d/gems/%.%#,'
-      \.'%C%.%#/lib/ruby/%\\d.%\\d/%.%#,'
-      \.'%C%.%#/vendor/rails/%.%#,'
-&quot; Specific to template errors
-let s:efm=s:efm
-      \.'%C\ %\\+On\ line\ #%l\ of\ %f,'
-      \.'%CActionView::TemplateError:\ compile\ error,'
-&quot; stack backtrace is in brackets. if multiple lines, it starts on a new line.
-let s:efm=s:efm
-      \.'%Ctest_%.%#(%.%#):%#,'
-      \.'%C%.%#\ [%f:%l]:,'
-      \.'%C\ \ \ \ [%f:%l:%.%#,'
-      \.'%C\ \ \ \ %f:%l:%.%#,'
-      \.'%C\ \ \ \ \ %f:%l:%.%#]:,'
-      \.'%C\ \ \ \ \ %f:%l:%.%#,'
-&quot; Catch all
-let s:efm=s:efm
-      \.'%Z%f:%l:\ %#%m,'
-      \.'%Z%f:%l:,'
-      \.'%C%m,'
-&quot; Syntax errors in the test itself
-let s:efm=s:efm
-      \.'%.%#.rb:%\\d%\\+:in\ `load'.&quot;'&quot;.':\ %f:%l:\ syntax\ error\\\, %m,'
-      \.'%.%#.rb:%\\d%\\+:in\ `load'.&quot;'&quot;.':\ %f:%l:\ %m,'
-&quot; And required files
-let s:efm=s:efm
-      \.'%.%#:in\ `require'.&quot;'&quot;.':in\ `require'.&quot;'&quot;.':\ %f:%l:\ syntax\ error\\\, %m,'
-      \.'%.%#:in\ `require'.&quot;'&quot;.':in\ `require'.&quot;'&quot;.':\ %f:%l:\ %m,'
-&quot; Exclusions
-let s:efm=s:efm
-      \.'%-G%.%#/lib/gems/%\\d.%\\d/gems/%.%#,'
-      \.'%-G%.%#/lib/ruby/%\\d.%\\d/%.%#,'
-      \.'%-G%.%#/vendor/rails/%.%#,'
-      \.'%-G%.%#%\\d%\\d:%\\d%\\d:%\\d%\\d%.%#,'
-&quot; Final catch all for one line errors
-let s:efm=s:efm
-      \.'%-G%\\s%#from\ %.%#,'
-      \.'%f:%l:\ %#%m,'
-&quot; Drop everything else
-let s:efm=s:efm
-      \.'%-G%.%#'
-
 let s:efm_backtrace='%D(in\ %f),'
       \.'%\\s%#from\ %f:%l:%m,'
+      \.'%\\s%#from\ %f:%l:,'
       \.'%\\s#{RAILS_ROOT}/%f:%l:\ %#%m,'
       \.'%\\s%#[%f:%l:\ %#%m,'
-      \.'%\\s%#%f:%l:\ %#%m'
+      \.'%\\s%#%f:%l:\ %#%m,'
+      \.'%\\s%#%f:%l:'
 
 function! s:makewithruby(arg,bang,...)
-  if &amp;efm == s:efm
-    if (a:0 ? a:1 : 1) &amp;&amp; !a:bang
-      setlocal efm=\%-E-e:%.%#,\%+E%f:%l:\ parse\ error,%W%f:%l:\ warning:\ %m,%E%f:%l:in\ %*[^:]:\ %m,%E%f:%l:\ %m,%-C%\tfrom\ %f:%l:in\ %.%#,%-Z%\tfrom\ %f:%l,%-Z%p^,%-G%.%#
-    endif
-  endif
   let old_make = &amp;makeprg
-  let &amp;l:makeprg = rails#app().ruby_shell_command(a:arg)
-  exe 'make'.(a:bang ? '!' : '')
-  let &amp;l:makeprg = old_make
+  try
+    let &amp;l:makeprg = rails#app().ruby_shell_command(a:arg)
+    exe 'make'.(a:bang ? '!' : '')
+    if !a:bang
+      cwindow
+    endif
+  finally
+    let &amp;l:makeprg = old_make
+  endtry
 endfunction
 
 function! s:Rake(bang,lnum,arg)
@@ -1000,7 +1107,7 @@ function! s:Rake(bang,lnum,arg)
     if &amp;l:makeprg !~# 'rake'
       let &amp;l:makeprg = 'rake'
     endif
-    let &amp;l:errorformat = a:bang ? s:efm_backtrace : s:efm
+    let &amp;l:errorformat = s:efm_backtrace
     let t = RailsFileType()
     let arg = a:arg
     if &amp;filetype == &quot;ruby&quot; &amp;&amp; arg == '' &amp;&amp; g:rails_modelines
@@ -1018,7 +1125,7 @@ function! s:Rake(bang,lnum,arg)
       if opt != ''
         let arg = opt
       else
-        let arg = s:default_rake_task(lnum)
+        let arg = rails#buffer().default_rake_task(lnum)
       endif
     endif
     let withrubyargs = '-r ./config/boot -r '.s:rquote(self.path('config/environment')).' -e &quot;puts \%((in \#{Dir.getwd}))&quot; '
@@ -1026,15 +1133,15 @@ function! s:Rake(bang,lnum,arg)
       let &amp;l:errorformat = '%-P%f:,\ \ *\ [%*[\ ]%l]\ [%t%*[^]]] %m,\ \ *\ [%*[\ ]%l] %m,%-Q'
       &quot; %D to chdir is apparently incompatible with %P multiline messages
       call s:push_chdir(1)
-      exe 'make '.arg
+      exe 'make! '.arg
       call s:pop_command()
-      if a:bang
-        copen
+      if !a:bang
+        cwindow
       endif
-    elseif arg =~# '^\%(stats\|routes\|secret\|time:zones\|db:\%(charset\|collation\|fixtures:identify\&gt;.*\|version\)\)\%(:\|$\)'
+    elseif arg =~# '^\%(stats\|routes\|secret\|time:zones\|db:\%(charset\|collation\|fixtures:identify\&gt;.*\|version\)\)\%([: ]\|$\)'
       let &amp;l:errorformat = '%D(in\ %f),%+G%.%#'
-      exe 'make '.arg
-      if a:bang
+      exe 'make! '.arg
+      if !a:bang
         copen
       endif
     elseif arg =~ '^preview\&gt;'
@@ -1063,7 +1170,10 @@ function! s:Rake(bang,lnum,arg)
       let arg = s:sub(arg,'#(\w+[?!=]=)$',' -- -n\1')
       call s:makewithruby(withrubyargs.'-r'.arg,a:bang,arg !~# '_\%(spec\|test\)\.rb$')
     else
-      exe 'make'.(a:bang ? '!' : '').' '.arg
+      exe 'make! '.arg
+      if !a:bang
+        cwindow
+      endif
     endif
   finally
     let &amp;l:errorformat = old_errorformat
@@ -1071,27 +1181,35 @@ function! s:Rake(bang,lnum,arg)
   endtry
 endfunction
 
-function! s:default_rake_task(lnum)
-  let self = rails#app()
-  let t = RailsFileType()
+function! s:readable_default_rake_task(lnum) dict abort
+  let app = self.app()
+  let t = self.type_name()
   let lnum = a:lnum &lt; 0 ? 0 : a:lnum
-  if t =~ '^config-routes\&gt;'
+  if self.getline(lnum) =~# '# rake '
+    return matchstr(self.getline(lnum),'\C# rake \zs.*')
+  elseif self.getline(self.last_method_line(lnum)-1) =~# '# rake '
+    return matchstr(self.getline(self.last_method_line(lnum)-1),'\C# rake \zs.*')
+  elseif self.getline(self.last_method_line(lnum)) =~# '# rake '
+    return matchstr(self.getline(self.last_method_line(lnum)),'\C# rake \zs.*')
+  elseif self.getline(1) =~# '# rake ' &amp;&amp; !lnum
+    return matchstr(self.getline(1),'\C# rake \zs.*')
+  elseif t =~ '^config-routes\&gt;'
     return 'routes'
   elseif t =~ '^fixtures-yaml\&gt;' &amp;&amp; lnum
-    return &quot;db:fixtures:identify LABEL=&quot;.s:lastmethod(lnum)
+    return &quot;db:fixtures:identify LABEL=&quot;.self.last_method(lnum)
   elseif t =~ '^fixtures\&gt;' &amp;&amp; lnum == 0
-    return &quot;db:fixtures:load FIXTURES=&quot;.s:sub(fnamemodify(RailsFilePath(),':r'),'^.{-}/fixtures/','')
+    return &quot;db:fixtures:load FIXTURES=&quot;.s:sub(fnamemodify(self.name(),':r'),'^.{-}/fixtures/','')
   elseif t =~ '^task\&gt;'
-    let mnum = s:lastmethodline(lnum)
+    let mnum = self.last_method_line(lnum)
     let line = getline(mnum)
     &quot; We can't grab the namespace so only run tasks at the start of the line
     if line =~# '^\%(task\|file\)\&gt;'
-      return s:lastmethod(a:lnum)
+      return self.last_method(a:lnum)
     else
-      return ''
+      return matchstr(self.getline(1),'\C# rake \zs.*')
     endif
   elseif t =~ '^spec\&gt;'
-    if RailsFilePath() =~# '\&lt;spec/spec_helper\.rb$'
+    if self.name() =~# '\&lt;spec/spec_helper\.rb$'
       return 'spec SPEC_OPTS='
     elseif lnum &gt; 0
       return 'spec SPEC=&quot;%:p&quot; SPEC_OPTS=--line='.lnum
@@ -1099,7 +1217,7 @@ function! s:default_rake_task(lnum)
       return 'spec SPEC=&quot;%:p&quot; SPEC_OPTS='
     endif
   elseif t =~ '^test\&gt;'
-    let meth = s:lastmethod(lnum)
+    let meth = self.last_method(lnum)
     if meth =~ '^test_'
       let call = &quot; -n&quot;.meth.&quot;&quot;
     else
@@ -1107,15 +1225,15 @@ function! s:default_rake_task(lnum)
     endif
     if t =~ '^test-\%(unit\|functional\|integration\)$'
       return s:sub(s:gsub(t,'-',':'),'unit$|functional$','&amp;s').&quot; TEST=\&quot;%:p\&quot;&quot;.s:sub(call,'^ ',' TESTOPTS=')
-    elseif RailsFilePath() =~# '\&lt;test/test_helper\.rb$'
+    elseif self.name() =~# '\&lt;test/test_helper\.rb$'
       return 'test'
     else
       return &quot;test:recent TEST=\&quot;%:p\&quot;&quot;.s:sub(call,'^ ',' TESTOPTS=')
     endif
-  elseif t=~ '^\%(db-\)\=migration\&gt;' &amp;&amp; RailsFilePath() !~# '\&lt;db/schema\.rb$'
-    let ver = matchstr(RailsFilePath(),'\&lt;db/migrate/0*\zs\d*\ze_')
+  elseif t=~ '^\%(db-\)\=migration\&gt;' &amp;&amp; self.name() !~# '\&lt;db/schema\.rb$'
+    let ver = matchstr(self.name(),'\&lt;db/migrate/0*\zs\d*\ze_')
     if ver != &quot;&quot;
-      let method = s:lastmethod(lnum)
+      let method = self.last_method(lnum)
       if method == &quot;down&quot;
         return &quot;db:migrate:down VERSION=&quot;.ver
       elseif method == &quot;up&quot;
@@ -1128,26 +1246,36 @@ function! s:default_rake_task(lnum)
     else
       return 'db:migrate'
     endif
-  elseif self.has('spec') &amp;&amp; RailsFilePath() =~# '^app/.*\.rb' &amp;&amp; self.has_file(s:sub(RailsFilePath(),'^app/(.*)\.rb$','spec/\1_spec.rb'))
+  elseif self.name() =~# '\&lt;db/seeds\.rb$'
+    return 'db:seed'
+  elseif self.type_name('controller') &amp;&amp; lnum
+    let lm = self.last_method(lnum)
+    if lm != ''
+      &quot; rake routes doesn't support ACTION... yet...
+      return 'routes CONTROLLER='.self.controller_name().' ACTION='.lm
+    else
+      return 'routes CONTROLLER='.self.controller_name()
+    endif
+  elseif app.has('spec') &amp;&amp; self.name() =~# '^app/.*\.rb' &amp;&amp; app.has_file(s:sub(self.name(),'^app/(.*)\.rb$','spec/\1_spec.rb'))
     return 'spec SPEC=&quot;%:p:r:s?[\/]app[\/]?/spec/?_spec.rb&quot; SPEC_OPTS='
   elseif t=~ '^model\&gt;'
     return 'test:units TEST=&quot;%:p:r:s?[\/]app[\/]models[\/]?/test/unit/?_test.rb&quot;'
   elseif t=~ '^api\&gt;'
     return 'test:units TEST=&quot;%:p:r:s?[\/]app[\/]apis[\/]?/test/functional/?_test.rb&quot;'
   elseif t=~ '^\&lt;\%(controller\|helper\|view\)\&gt;'
-    if RailsFilePath() =~ '\&lt;app/' &amp;&amp; s:controller() !~# '^\%(application\)\=$'
-      return 'test:functionals TEST=&quot;'.s:escarg(self.path('test/functional/'.s:controller().'_controller_test.rb')).'&quot;'
+    if self.name() =~ '\&lt;app/' &amp;&amp; s:controller() !~# '^\%(application\)\=$'
+      return 'test:functionals TEST=&quot;'.s:escarg(app.path('test/functional/'.s:controller().'_controller_test.rb')).'&quot;'
     else
       return 'test:functionals'
     endif
   elseif t =~ '^cucumber-feature\&gt;'
     if lnum &gt; 0
-      return 'features FEATURE=&quot;%:p&quot;:'.lnum
+      return 'cucumber FEATURE=&quot;%:p&quot;:'.lnum
     else
-      return 'features FEATURE=&quot;%:p&quot;'
+      return 'cucumber FEATURE=&quot;%:p&quot;'
     endif
   elseif t =~ '^cucumber\&gt;'
-    return 'features'
+    return 'cucumber'
   else
     return ''
   endif
@@ -1157,6 +1285,8 @@ function! s:Complete_rake(A,L,P)
   return s:completion_filter(rails#app().rake_tasks(),a:A)
 endfunction
 
+call s:add_methods('readable',['default_rake_task'])
+
 &quot; }}}1
 &quot; Preview {{{1
 
@@ -1172,10 +1302,8 @@ function! s:initOpenURL()
   endif
 endfunction
 
-&quot; This returns the URI with a trailing newline if it is found
-function! s:scanlineforuri(lnum)
-  let line = getline(a:lnum)
-  let url = matchstr(line,&quot;\\v\\C%(%(GET|PUT|POST|DELETE)\\s+|\w+:/)/[^ \n\r\t&lt;&gt;\&quot;]*[^] .,;\n\r\t&lt;&gt;\&quot;:]&quot;)
+function! s:scanlineforuris(line)
+  let url = matchstr(a:line,&quot;\\v\\C%(%(GET|PUT|POST|DELETE)\\s+|\w+:/)/[^ \n\r\t&lt;&gt;\&quot;]*[^] .,;\n\r\t&lt;&gt;\&quot;:]&quot;)
   if url =~ '\C^\u\+\s\+'
     let method = matchstr(url,'^\u\+')
     let url = matchstr(url,'\s\+\zs.*')
@@ -1184,43 +1312,45 @@ function! s:scanlineforuri(lnum)
     endif
   endif
   if url != &quot;&quot;
-    return s:sub(url,'^/','') . &quot;\n&quot;
+    return [url]
   else
-    return &quot;&quot;
+    return []
   endif
 endfunction
 
-function! s:defaultpreview(lnum)
-  let ret = ''
-  if s:getopt('preview','l',a:lnum) != ''
-    let uri = s:getopt('preview','l',a:lnum)
-  elseif s:controller() != '' &amp;&amp; s:controller() != 'application' &amp;&amp; RailsFilePath() !~ '^public/'
-    if RailsFileType() =~ '^controller\&gt;'
-      let start = s:lastmethodline(a:lnum) - 1
-      if start + 1
-        while getline(start) =~ '^\s*\%(#.*\)\=$'
-          let ret = s:scanlineforuri(start).ret
-          let start -= 1
-        endwhile
-        let ret .= s:controller().'/'.s:lastmethod(a:lnum).'/'
-      else
-        let ret .= s:controller().'/'
-      endif
-    elseif s:getopt('preview','b') != ''
-      let ret = s:getopt('preview','b')
-    elseif RailsFileType() =~ '^view\%(-partial\|-layout\)\@!'
-      let ret .= s:controller().'/'.expand('%:t:r:r').'/'
+function! s:readable_preview_urls(lnum) dict abort
+  let urls = []
+  let start = self.last_method_line(a:lnum) - 1
+  while start &gt; 0 &amp;&amp; self.getline(start) =~ '^\s*\%(\%(-\=\|&lt;%\)#.*\)\=$'
+    let urls = s:scanlineforuris(self.getline(start)) + urls
+    let start -= 1
+  endwhile
+  let start = 1
+  while start &lt; self.line_count() &amp;&amp; self.getline(start) =~ '^\s*\%(\%(-\=\|&lt;%\)#.*\)\=$'
+    let urls += s:scanlineforuris(self.getline(start))
+    let start += 1
+  endwhile
+  if has_key(self,'getvar') &amp;&amp; self.getvar('rails_preview') != ''
+    let url += [self.getvar('rails_preview')]
+  end
+  if self.name() =~ '^public/stylesheets/sass/'
+    let urls = urls + [s:sub(s:sub(self.name(),'^public/stylesheets/sass/','/stylesheets/'),'\.sass$','.css')]
+  elseif self.name() =~ '^public/'
+    let urls = urls + [s:sub(self.name(),'^public','')]
+  elseif self.controller_name() != '' &amp;&amp; self.controller_name() != 'application'
+    if self.type_name('controller') &amp;&amp; self.last_method(a:lnum) != ''
+      let urls += ['/'.self.controller_name().'/'.self.last_method(a:lnum).'/']
+    elseif self.type_name('controller','view-layout','view-partial')
+      let urls += ['/'.self.controller_name().'/']
+    elseif self.type_name('view')
+      let urls += ['/'.s:controller().'/'.fnamemodify(self.name(),':t:r:r').'/']
     endif
-  elseif s:getopt('preview','b') != ''
-    let uri = s:getopt('preview','b')
-  elseif RailsFilePath() =~ '^public/'
-    let ret = s:sub(RailsFilePath(),'^public/','')
-  elseif s:getopt('preview','ag') != ''
-    let ret = s:getopt('preview','ag')
   endif
-  return ret
+  return urls
 endfunction
 
+call s:add_methods('readable',['preview_urls'])
+
 function! s:Preview(bang,lnum,arg)
   let root = s:getopt(&quot;root_url&quot;)
   if root == ''
@@ -1232,7 +1362,7 @@ function! s:Preview(bang,lnum,arg)
   elseif a:arg != ''
     let uri = root.'/'.s:sub(a:arg,'^/','')
   else
-    let uri = matchstr(s:defaultpreview(a:lnum),'.\{-\}\%(\n\@=\|$\)')
+    let uri = get(rails#buffer().preview_urls(a:lnum),0,'')
     let uri = root.'/'.s:sub(s:sub(uri,'^/',''),'/$','')
   endif
   call s:initOpenURL()
@@ -1262,7 +1392,7 @@ function! s:Preview(bang,lnum,arg)
 endfunction
 
 function! s:Complete_preview(A,L,P)
-  return split(s:defaultpreview(a:L =~ '^\d' ? matchstr(a:L,'^\d\+') : line('.')),&quot;\n&quot;)
+  return rails#buffer().preview_urls(a:L =~ '^\d' ? matchstr(a:L,'^\d\+') : line('.'))
 endfunction
 
 &quot; }}}1
@@ -1270,7 +1400,6 @@ endfunction
 
 function! s:BufScriptWrappers()
   command! -buffer -bar -nargs=*       -complete=customlist,s:Complete_script   Rscript       :call rails#app().script_command(&lt;bang&gt;0,&lt;f-args&gt;)
-  command! -buffer -bar -nargs=*       -complete=customlist,s:Complete_console  Rconsole      :call s:warn(&quot;Warning: :Rconsole has been deprecated in favor of :Rscript&quot;)|call rails#app().script_command(&lt;bang&gt;0,'console',&lt;f-args&gt;)
   command! -buffer -bar -nargs=*       -complete=customlist,s:Complete_generate Rgenerate     :call rails#app().generate_command(&lt;bang&gt;0,&lt;f-args&gt;)
   command! -buffer -bar -nargs=*       -complete=customlist,s:Complete_destroy  Rdestroy      :call rails#app().destroy_command(&lt;bang&gt;0,&lt;f-args&gt;)
   command! -buffer -bar -nargs=? -bang -complete=customlist,s:Complete_server   Rserver       :call rails#app().server_command(&lt;bang&gt;0,&lt;q-args&gt;)
@@ -1446,7 +1575,7 @@ function! s:Complete_script(ArgLead,CmdLine,P)
       return s:modelList(a:ArgLead,&quot;&quot;,&quot;&quot;)
     elseif target ==# 'migration' || target ==# 'session_migration'
       return s:migrationList(a:ArgLead,&quot;&quot;,&quot;&quot;)
-    elseif target ==# 'integration_test' || target ==# 'feature'
+    elseif target ==# 'integration_test' || target ==# 'integration_spec' || target ==# 'feature'
       return s:integrationtestList(a:ArgLead,&quot;&quot;,&quot;&quot;)
     elseif target ==# 'observer'
       let observers = s:observerList(&quot;&quot;,&quot;&quot;,&quot;&quot;)
@@ -1508,31 +1637,34 @@ endfunction
 &quot; Navigation {{{1
 
 function! s:BufNavCommands()
-  command!   -buffer -bar -nargs=? -complete=customlist,s:Complete_cd Rcd   :cd `=rails#app().path(&lt;q-args&gt;)`
-  command!   -buffer -bar -nargs=? -complete=customlist,s:Complete_cd Rlcd :lcd `=rails#app().path(&lt;q-args&gt;)`
-  command!   -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find Rfind       :call s:Find(&lt;bang&gt;0,&lt;count&gt;,'' ,&lt;f-args&gt;)
-  command!   -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find REfind      :call s:Find(&lt;bang&gt;0,&lt;count&gt;,'E',&lt;f-args&gt;)
-  command!   -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find RSfind      :call s:Find(&lt;bang&gt;0,&lt;count&gt;,'S',&lt;f-args&gt;)
-  command!   -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find RVfind      :call s:Find(&lt;bang&gt;0,&lt;count&gt;,'V',&lt;f-args&gt;)
-  command!   -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find RTfind      :call s:Find(&lt;bang&gt;0,&lt;count&gt;,'T',&lt;f-args&gt;)
-  command!   -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find Rsfind      :&lt;count&gt;RSfind&lt;bang&gt; &lt;args&gt;
-  command!   -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find Rtabfind    :&lt;count&gt;RTfind&lt;bang&gt; &lt;args&gt;
-  command!   -buffer -bar -nargs=* -bang    -complete=customlist,s:Complete_edit Redit       :call s:Edit(&lt;bang&gt;0,&lt;count&gt;,'' ,&lt;f-args&gt;)
-  command!   -buffer -bar -nargs=* -bang    -complete=customlist,s:Complete_edit REedit      :call s:Edit(&lt;bang&gt;0,&lt;count&gt;,'E',&lt;f-args&gt;)
-  command!   -buffer -bar -nargs=* -bang    -complete=customlist,s:Complete_edit RSedit      :call s:Edit(&lt;bang&gt;0,&lt;count&gt;,'S',&lt;f-args&gt;)
-  command!   -buffer -bar -nargs=* -bang    -complete=customlist,s:Complete_edit RVedit      :call s:Edit(&lt;bang&gt;0,&lt;count&gt;,'V',&lt;f-args&gt;)
-  command!   -buffer -bar -nargs=* -bang    -complete=customlist,s:Complete_edit RTedit      :call s:Edit(&lt;bang&gt;0,&lt;count&gt;,'T',&lt;f-args&gt;)
-  command! -buffer -bar -nargs=* -complete=customlist,s:Complete_find    A  :call s:Alternate(&lt;bang&gt;0,&quot;&quot;, &lt;f-args&gt;)
-  command! -buffer -bar -nargs=* -complete=customlist,s:Complete_find    AE :call s:Alternate(&lt;bang&gt;0,&quot;E&quot;,&lt;f-args&gt;)
-  command! -buffer -bar -nargs=* -complete=customlist,s:Complete_find    AS :call s:Alternate(&lt;bang&gt;0,&quot;S&quot;,&lt;f-args&gt;)
-  command! -buffer -bar -nargs=* -complete=customlist,s:Complete_find    AV :call s:Alternate(&lt;bang&gt;0,&quot;V&quot;,&lt;f-args&gt;)
-  command! -buffer -bar -nargs=* -complete=customlist,s:Complete_find    AT :call s:Alternate(&lt;bang&gt;0,&quot;T&quot;,&lt;f-args&gt;)
-  command! -buffer -bar -nargs=* -complete=customlist,s:Complete_edit    AN :call s:Related(&lt;bang&gt;0,&quot;&quot; ,&lt;f-args&gt;)
-  command! -buffer -bar -nargs=* -complete=customlist,s:Complete_edit    R  :call s:Related(&lt;bang&gt;0,&quot;&quot; ,&lt;f-args&gt;)
-  command! -buffer -bar -nargs=* -complete=customlist,s:Complete_edit    RE :call s:Related(&lt;bang&gt;0,&quot;E&quot;,&lt;f-args&gt;)
-  command! -buffer -bar -nargs=* -complete=customlist,s:Complete_edit    RS :call s:Related(&lt;bang&gt;0,&quot;S&quot;,&lt;f-args&gt;)
-  command! -buffer -bar -nargs=* -complete=customlist,s:Complete_edit    RV :call s:Related(&lt;bang&gt;0,&quot;V&quot;,&lt;f-args&gt;)
-  command! -buffer -bar -nargs=* -complete=customlist,s:Complete_edit    RT :call s:Related(&lt;bang&gt;0,&quot;T&quot;,&lt;f-args&gt;)
+  command! -buffer -bar -nargs=? -complete=customlist,s:Complete_cd Rcd   :cd `=rails#app().path(&lt;q-args&gt;)`
+  command! -buffer -bar -nargs=? -complete=customlist,s:Complete_cd Rlcd :lcd `=rails#app().path(&lt;q-args&gt;)`
+  command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find Rfind    :call s:Find(&lt;count&gt;,'&lt;bang&gt;' ,&lt;f-args&gt;)
+  command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find REfind   :call s:Find(&lt;count&gt;,'E&lt;bang&gt;',&lt;f-args&gt;)
+  command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find RSfind   :call s:Find(&lt;count&gt;,'S&lt;bang&gt;',&lt;f-args&gt;)
+  command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find RVfind   :call s:Find(&lt;count&gt;,'V&lt;bang&gt;',&lt;f-args&gt;)
+  command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find RTfind   :call s:Find(&lt;count&gt;,'T&lt;bang&gt;',&lt;f-args&gt;)
+  command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find Rsfind   :&lt;count&gt;RSfind&lt;bang&gt; &lt;args&gt;
+  command! -buffer -bar -nargs=* -count=1 -complete=customlist,s:Complete_find Rtabfind :&lt;count&gt;RTfind&lt;bang&gt; &lt;args&gt;
+  command! -buffer -bar -nargs=* -bang    -complete=customlist,s:Complete_edit Redit    :call s:Edit(&lt;count&gt;,'&lt;bang&gt;' ,&lt;f-args&gt;)
+  command! -buffer -bar -nargs=* -bang    -complete=customlist,s:Complete_edit REedit   :call s:Edit(&lt;count&gt;,'E&lt;bang&gt;',&lt;f-args&gt;)
+  command! -buffer -bar -nargs=* -bang    -complete=customlist,s:Complete_edit RSedit   :call s:Edit(&lt;count&gt;,'S&lt;bang&gt;',&lt;f-args&gt;)
+  command! -buffer -bar -nargs=* -bang    -complete=customlist,s:Complete_edit RVedit   :call s:Edit(&lt;count&gt;,'V&lt;bang&gt;',&lt;f-args&gt;)
+  command! -buffer -bar -nargs=* -bang    -complete=customlist,s:Complete_edit RTedit   :call s:Edit(&lt;count&gt;,'T&lt;bang&gt;',&lt;f-args&gt;)
+  command! -buffer -bar -nargs=* -range=0 -complete=customlist,s:Complete_edit RDedit   :call s:Edit(&lt;count&gt;,'&lt;line1&gt;D&lt;bang&gt;',&lt;f-args&gt;)
+  command! -buffer -bar -nargs=* -range=0 -complete=customlist,s:Complete_related A     :call s:Alternate('&lt;bang&gt;', &lt;line1&gt;,&lt;line2&gt;,&lt;count&gt;,&lt;f-args&gt;)
+  command! -buffer -bar -nargs=* -range=0 -complete=customlist,s:Complete_related AE    :call s:Alternate('E&lt;bang&gt;',&lt;line1&gt;,&lt;line2&gt;,&lt;count&gt;,&lt;f-args&gt;)
+  command! -buffer -bar -nargs=* -range=0 -complete=customlist,s:Complete_related AS    :call s:Alternate('S&lt;bang&gt;',&lt;line1&gt;,&lt;line2&gt;,&lt;count&gt;,&lt;f-args&gt;)
+  command! -buffer -bar -nargs=* -range=0 -complete=customlist,s:Complete_related AV    :call s:Alternate('V&lt;bang&gt;',&lt;line1&gt;,&lt;line2&gt;,&lt;count&gt;,&lt;f-args&gt;)
+  command! -buffer -bar -nargs=* -range=0 -complete=customlist,s:Complete_related AT    :call s:Alternate('T&lt;bang&gt;',&lt;line1&gt;,&lt;line2&gt;,&lt;count&gt;,&lt;f-args&gt;)
+  command! -buffer -bar -nargs=* -range=0 -complete=customlist,s:Complete_related AD    :call s:Alternate('D&lt;bang&gt;',&lt;line1&gt;,&lt;line2&gt;,&lt;count&gt;,&lt;f-args&gt;)
+  command! -buffer -bar -nargs=* -range=0 -complete=customlist,s:Complete_related AN    :call s:Related('&lt;bang&gt;' ,&lt;line1&gt;,&lt;line2&gt;,&lt;count&gt;,&lt;f-args&gt;)
+  command! -buffer -bar -nargs=* -range=0 -complete=customlist,s:Complete_related R     :call s:Related('&lt;bang&gt;' ,&lt;line1&gt;,&lt;line2&gt;,&lt;count&gt;,&lt;f-args&gt;)
+  command! -buffer -bar -nargs=* -range=0 -complete=customlist,s:Complete_related RE    :call s:Related('E&lt;bang&gt;',&lt;line1&gt;,&lt;line2&gt;,&lt;count&gt;,&lt;f-args&gt;)
+  command! -buffer -bar -nargs=* -range=0 -complete=customlist,s:Complete_related RS    :call s:Related('S&lt;bang&gt;',&lt;line1&gt;,&lt;line2&gt;,&lt;count&gt;,&lt;f-args&gt;)
+  command! -buffer -bar -nargs=* -range=0 -complete=customlist,s:Complete_related RV    :call s:Related('V&lt;bang&gt;',&lt;line1&gt;,&lt;line2&gt;,&lt;count&gt;,&lt;f-args&gt;)
+  command! -buffer -bar -nargs=* -range=0 -complete=customlist,s:Complete_related RT    :call s:Related('T&lt;bang&gt;',&lt;line1&gt;,&lt;line2&gt;,&lt;count&gt;,&lt;f-args&gt;)
+  command! -buffer -bar -nargs=* -range=0 -complete=customlist,s:Complete_related RD    :call s:Related('D&lt;bang&gt;',&lt;line1&gt;,&lt;line2&gt;,&lt;count&gt;,&lt;f-args&gt;)
 endfunction
 
 function! s:djump(def)
@@ -1563,8 +1695,7 @@ function! s:djump(def)
   endif
 endfunction
 
-function! s:Find(bang,count,arg,...)
-  let cmd = a:arg . (a:bang ? '!' : '')
+function! s:Find(count,cmd,...)
   let str = &quot;&quot;
   if a:0
     let i = 1
@@ -1584,11 +1715,10 @@ function! s:Find(bang,count,arg,...)
     let file = s:RailsFind()
     let tail = &quot;&quot;
   endif
-  call s:findedit((a:count==1?'' : a:count).cmd,file.tail,str)
+  call s:findedit((a:count==1?'' : a:count).a:cmd,file.tail,str)
 endfunction
 
-function! s:Edit(bang,count,arg,...)
-  let cmd = a:arg . (a:bang ? '!' : '')
+function! s:Edit(count,cmd,...)
   if a:0
     let str = &quot;&quot;
     let i = 1
@@ -1597,9 +1727,9 @@ function! s:Edit(bang,count,arg,...)
       let i += 1
     endwhile
     let file = a:{i}
-    call s:findedit(s:editcmdfor(cmd),file,str)
+    call s:findedit(s:editcmdfor(a:cmd),file,str)
   else
-    exe s:editcmdfor(cmd)
+    exe s:editcmdfor(a:cmd)
   endif
 endfunction
 
@@ -1731,7 +1861,7 @@ function! s:RailsFind()
   if res != &quot;&quot;|return res.&quot;\n&quot;.s:findview(res)|endif
   let res = s:findamethod('render\s*:\%(template\|action\)\s\+=&gt;\s*','\1.'.format.'\n\1')
   if res != &quot;&quot;|return res|endif
-  let res = s:sub(s:findamethod('render','\1'),'^/','')
+  let res = s:sub(s:findfromview('render','\1'),'^/','')
   if RailsFileType() =~ '^view\&gt;' | let res = s:sub(res,'[^/]+$','_&amp;') | endif
   if res != &quot;&quot;|return res.&quot;\n&quot;.s:findview(res)|endif
   let res = s:findamethod('redirect_to\s*(\=\s*:action\s\+=&gt;\s*','\1')
@@ -1746,12 +1876,15 @@ function! s:RailsFind()
     let res = s:findview(contr.'/'.view)
     if res != &quot;&quot;|return res|endif
   endif
-  let isf_keep = &amp;isfname
-  set isfname=@,48-57,/,-,_,: &quot;,\&quot;,'
-  &quot; TODO: grab visual selection in visual mode
-  let cfile = expand(&quot;&lt;cfile&gt;&quot;)
+  let old_isfname = &amp;isfname
+  try
+    set isfname=@,48-57,/,-,_,: &quot;,\&quot;,'
+    &quot; TODO: grab visual selection in visual mode
+    let cfile = expand(&quot;&lt;cfile&gt;&quot;)
+  finally
+    let &amp;isfname = old_isfname
+  endtry
   let res = s:RailsIncludefind(cfile,1)
-  let &amp;isfname = isf_keep
   return res
 endfunction
 
@@ -1891,11 +2024,11 @@ endfunction
 
 function! s:addfilecmds(type)
   let l = s:sub(a:type,'^.','\l&amp;')
-  let cmds = 'ESVT '
+  let cmds = 'ESVTD '
   let cmd = ''
   while cmds != ''
     let cplt = &quot; -complete=customlist,&quot;.s:sid.l.&quot;List&quot;
-    exe &quot;command! -buffer -bar -nargs=*&quot;.cplt.&quot; R&quot;.cmd.l.&quot; :call s:&quot;.l.'Edit(&lt;bang&gt;0,&quot;'.cmd.'&quot;,&lt;f-args&gt;)'
+    exe &quot;command! -buffer -bar &quot;.(cmd == 'D' ? '-range=0 ' : '').&quot;-nargs=*&quot;.cplt.&quot; R&quot;.cmd.l.&quot; :call s:&quot;.l.'Edit(&quot;'.(cmd == 'D' ? '&lt;line1&gt;' : '').cmd.'&lt;bang&gt;&quot;,&lt;f-args&gt;)'
     let cmd = strpart(cmds,0,1)
     let cmds = strpart(cmds,1)
   endwhile
@@ -1903,7 +2036,6 @@ endfunction
 
 function! s:BufFinderCommands()
   command! -buffer -bar -nargs=+ Rnavcommand :call s:Navcommand(&lt;bang&gt;0,&lt;f-args&gt;)
-  command! -buffer -bar -nargs=+ Rcommand    :call s:warn(&quot;Warning: :Rcommand has been deprecated in favor of :Rnavcommand&quot;)|call s:Navcommand(&lt;bang&gt;0,&lt;f-args&gt;)
   call s:addfilecmds(&quot;metal&quot;)
   call s:addfilecmds(&quot;model&quot;)
   call s:addfilecmds(&quot;view&quot;)
@@ -1911,14 +2043,14 @@ function! s:BufFinderCommands()
   call s:addfilecmds(&quot;migration&quot;)
   call s:addfilecmds(&quot;observer&quot;)
   call s:addfilecmds(&quot;helper&quot;)
-  call s:addfilecmds(&quot;api&quot;)
   call s:addfilecmds(&quot;layout&quot;)
   call s:addfilecmds(&quot;fixtures&quot;)
+  call s:addfilecmds(&quot;locale&quot;)
   if rails#app().has('test') || rails#app().has('spec')
     call s:addfilecmds(&quot;unittest&quot;)
     call s:addfilecmds(&quot;functionaltest&quot;)
   endif
-  if rails#app().has('test') || rails#app().has('cucumber')
+  if rails#app().has('test') || rails#app().has('spec') || rails#app().has('cucumber')
     call s:addfilecmds(&quot;integrationtest&quot;)
   endif
   if rails#app().has('spec')
@@ -2035,6 +2167,10 @@ function! s:fixturesList(A,L,P)
   return s:completion_filter(rails#app().relglob(&quot;test/fixtures/&quot;,&quot;**/*&quot;)+rails#app().relglob(&quot;spec/fixtures/&quot;,&quot;**/*&quot;),a:A)
 endfunction
 
+function! s:localeList(A,L,P)
+  return s:completion_filter(rails#app().relglob(&quot;config/locales/&quot;,&quot;**/*&quot;),a:A)
+endfunction
+
 function! s:migrationList(A,L,P)
   if a:A =~ '^\d'
     let migrations = rails#app().relglob(&quot;db/migrate/&quot;,a:A.&quot;[0-9_]*&quot;,&quot;.rb&quot;)
@@ -2046,10 +2182,6 @@ function! s:migrationList(A,L,P)
   endif
 endfunction
 
-function! s:apiList(A,L,P)
-  return s:autocamelize(rails#app().relglob(&quot;app/apis/&quot;,&quot;**/*&quot;,&quot;_api.rb&quot;),a:A)
-endfunction
-
 function! s:unittestList(A,L,P)
   let found = []
   if rails#app().has('test')
@@ -2073,14 +2205,20 @@ function! s:functionaltestList(A,L,P)
 endfunction
 
 function! s:integrationtestList(A,L,P)
+  if a:A =~# '^\u'
+    return s:autocamelize(rails#app().relglob(&quot;test/integration/&quot;,&quot;**/*&quot;,&quot;_test.rb&quot;),a:A)
+  endif
   let found = []
   if rails#app().has('test')
-    let found += s:autocamelize(rails#app().relglob(&quot;test/integration/&quot;,&quot;**/*&quot;,&quot;_test.rb&quot;),a:A)
+    let found += rails#app().relglob(&quot;test/integration/&quot;,&quot;**/*&quot;,&quot;_test.rb&quot;)
+  endif
+  if rails#app().has('spec')
+    let found += rails#app().relglob(&quot;spec/integration/&quot;,&quot;**/*&quot;,&quot;_spec.rb&quot;)
   endif
   if rails#app().has('cucumber')
-    let found += s:completion_filter(rails#app().relglob(&quot;features/&quot;,&quot;**/*&quot;,&quot;.feature&quot;),a:A)
+    let found += rails#app().relglob(&quot;features/&quot;,&quot;**/*&quot;,&quot;.feature&quot;)
   endif
-  return found
+  return s:completion_filter(found,a:A)
 endfunction
 
 function! s:specList(A,L,P)
@@ -2154,7 +2292,7 @@ function! s:Navcommand(bang,...)
   let cmds = 'ESVT '
   let cmd = ''
   while cmds != ''
-    exe 'command! -buffer -bar -bang -nargs=* -complete=customlist,'.s:sid.'CommandList R'.cmd.name.&quot; :call s:CommandEdit(&lt;bang&gt;0,'&quot;.cmd.&quot;','&quot;.name.&quot;',\&quot;&quot;.prefix.&quot;\&quot;,&quot;.string(suffix).&quot;,&quot;.string(filter).&quot;,&quot;.string(default).&quot;,&lt;f-args&gt;)&quot;
+    exe 'command! -buffer -bar -bang -nargs=* -complete=customlist,'.s:sid.'CommandList R'.cmd.name.&quot; :call s:CommandEdit('&quot;.cmd.&quot;&lt;bang&gt;','&quot;.name.&quot;',\&quot;&quot;.prefix.&quot;\&quot;,&quot;.string(suffix).&quot;,&quot;.string(filter).&quot;,&quot;.string(default).&quot;,&lt;f-args&gt;)&quot;
     let cmd = strpart(cmds,0,1)
     let cmds = strpart(cmds,1)
   endwhile
@@ -2177,7 +2315,7 @@ function! s:CommandList(A,L,P)
   endif
 endfunction
 
-function! s:CommandEdit(bang,cmd,name,prefix,suffix,filter,default,...)
+function! s:CommandEdit(cmd,name,prefix,suffix,filter,default,...)
   if a:0 &amp;&amp; a:1 == &quot;&amp;&quot;
     let s:last_prefix = a:prefix
     let s:last_suffix = a:suffix
@@ -2197,12 +2335,12 @@ function! s:CommandEdit(bang,cmd,name,prefix,suffix,filter,default,...)
     else
       let default = a:default
     endif
-    call s:EditSimpleRb(a:bang,a:cmd,a:name,a:0 ? a:1 : default,a:prefix,a:suffix)
+    call s:EditSimpleRb(a:cmd,a:name,a:0 ? a:1 : default,a:prefix,a:suffix)
   endif
 endfunction
 
-function! s:EditSimpleRb(bang,cmd,name,target,prefix,suffix,...)
-  let cmd = s:findcmdfor(a:cmd.(a:bang?'!':''))
+function! s:EditSimpleRb(cmd,name,target,prefix,suffix,...)
+  let cmd = s:findcmdfor(a:cmd)
   if a:target == &quot;&quot;
     &quot; Good idea to emulate error numbers like this?
     return s:error(&quot;E471: Argument required&quot;)
@@ -2224,13 +2362,14 @@ endfunction
 
 function! s:app_migration(file) dict
   let arg = a:file
-  if arg =~ '^0\+$'
+  if arg =~ '^0$\|^0\=[#:]'
+    let suffix = s:sub(arg,'^0*','')
     if self.has_file('db/schema.rb')
-      return 'db/schema.rb'
+      return 'db/schema.rb'.suffix
     elseif self.has_file('db/'.s:environment().'_structure.sql')
-      return 'db/'.s:environment().'_structure.sql'
+      return 'db/'.s:environment().'_structure.sql'.suffix
     else
-      return 'db/schema.rb'
+      return 'db/schema.rb'.suffix
     endif
   elseif arg =~ '^\d$'
     let glob = '00'.arg.'_*.rb'
@@ -2252,8 +2391,8 @@ endfunction
 
 call s:add_methods('app', ['migration'])
 
-function! s:migrationEdit(bang,cmd,...)
-  let cmd = s:findcmdfor(a:cmd.(a:bang?'!':''))
+function! s:migrationEdit(cmd,...)
+  let cmd = s:findcmdfor(a:cmd)
   let arg = a:0 ? a:1 : ''
   let migr = arg == &quot;.&quot; ? &quot;db/migrate&quot; : rails#app().migration(arg)
   if migr != ''
@@ -2263,7 +2402,7 @@ function! s:migrationEdit(bang,cmd,...)
   endif
 endfunction
 
-function! s:fixturesEdit(bang,cmd,...)
+function! s:fixturesEdit(cmd,...)
   if a:0
     let c = rails#underscore(a:1)
   else
@@ -2275,42 +2414,51 @@ function! s:fixturesEdit(bang,cmd,...)
   let e = fnamemodify(c,':e')
   let e = e == '' ? e : '.'.e
   let c = fnamemodify(c,':r')
-  let file = 'test/fixtures/'.c.e
-  if file =~ '\.\w\+$' &amp;&amp; !rails#app().has_file(&quot;spec/fixtures/&quot;.c.e)
-    call s:edit(a:cmd.(a:bang?'!':''),file)
+  let file = get(rails#app().test_suites(),0,'test').'/fixtures/'.c.e
+  if file =~ '\.\w\+$' &amp;&amp; rails#app().find_file(c.e,[&quot;test/fixtures&quot;,&quot;spec/fixtures&quot;]) ==# ''
+    call s:edit(a:cmd,file)
   else
-    call s:findedit(a:cmd.(a:bang?'!':''),rails#app().find_file(c.e,[&quot;test/fixtures&quot;,&quot;spec/fixtures&quot;],[&quot;.yml&quot;,&quot;.csv&quot;],file))
+    call s:findedit(a:cmd,rails#app().find_file(c.e,[&quot;test/fixtures&quot;,&quot;spec/fixtures&quot;],[&quot;.yml&quot;,&quot;.csv&quot;],file))
   endif
 endfunction
 
-function! s:metalEdit(bang,cmd,...)
+function! s:localeEdit(cmd,...)
+  let c = a:0 ? a:1 : rails#app().default_locale()
+  if c =~# '\.'
+    call s:edit(a:cmd,rails#app().find_file(c,'config/locales',[],'config/locales/'.c))
+  else
+    call s:findedit(a:cmd,rails#app().find_file(c,'config/locales',['.yml','.rb'],'config/locales/'.c))
+  endif
+endfunction
+
+function! s:metalEdit(cmd,...)
   if a:0
-    call s:EditSimpleRb(a:bang,a:cmd,&quot;metal&quot;,a:1,&quot;app/metal/&quot;,&quot;.rb&quot;)
+    call s:EditSimpleRb(a:cmd,&quot;metal&quot;,a:1,&quot;app/metal/&quot;,&quot;.rb&quot;)
   else
-    call s:EditSimpleRb(a:bang,a:cmd,&quot;metal&quot;,'config/boot',&quot;&quot;,&quot;.rb&quot;)
+    call s:EditSimpleRb(a:cmd,&quot;metal&quot;,'config/boot',&quot;&quot;,&quot;.rb&quot;)
   endif
 endfunction
 
-function! s:modelEdit(bang,cmd,...)
-  call s:EditSimpleRb(a:bang,a:cmd,&quot;model&quot;,a:0? a:1 : s:model(1),&quot;app/models/&quot;,&quot;.rb&quot;)
+function! s:modelEdit(cmd,...)
+  call s:EditSimpleRb(a:cmd,&quot;model&quot;,a:0? a:1 : s:model(1),&quot;app/models/&quot;,&quot;.rb&quot;)
 endfunction
 
-function! s:observerEdit(bang,cmd,...)
-  call s:EditSimpleRb(a:bang,a:cmd,&quot;observer&quot;,a:0? a:1 : s:model(1),&quot;app/models/&quot;,&quot;_observer.rb&quot;)
+function! s:observerEdit(cmd,...)
+  call s:EditSimpleRb(a:cmd,&quot;observer&quot;,a:0? a:1 : s:model(1),&quot;app/models/&quot;,&quot;_observer.rb&quot;)
 endfunction
 
-function! s:viewEdit(bang,cmd,...)
+function! s:viewEdit(cmd,...)
   if a:0 &amp;&amp; a:1 =~ '^[^!#:]'
     let view = matchstr(a:1,'[^!#:]*')
   elseif RailsFileType() == 'controller'
-    let view = s:lastmethod()
+    let view = s:lastmethod(line('.'))
   else
     let view = ''
   endif
   if view == ''
     return s:error(&quot;No view name given&quot;)
   elseif view == '.'
-    return s:edit(a:cmd.(a:bang?'!':''),'app/views')
+    return s:edit(a:cmd,'app/views')
   elseif view !~ '/' &amp;&amp; s:controller(1) != ''
     let view = s:controller(1) . '/' . view
   endif
@@ -2328,15 +2476,15 @@ function! s:viewEdit(bang,cmd,...)
         return s:error('No such directory')
       endif
     endif
-    call s:edit(a:cmd.(a:bang?'!':''),found)
+    call s:edit(a:cmd,found)
   elseif file =~ '\.\w\+$'
-    call s:findedit(a:cmd.(a:bang?'!':''),file)
+    call s:findedit(a:cmd,file)
   else
     let format = s:format('html')
     if glob(rails#app().path(file.'.'.format).'.*[^~]') != ''
       let file .= '.' . format
     endif
-    call s:findedit(a:cmd.(a:bang?'!':''),file)
+    call s:findedit(a:cmd,file)
   endif
 endfunction
 
@@ -2383,9 +2531,9 @@ function! s:findlayout(name)
   return s:findview(&quot;layouts/&quot;.(a:name == '' ? 'application' : a:name))
 endfunction
 
-function! s:layoutEdit(bang,cmd,...)
+function! s:layoutEdit(cmd,...)
   if a:0
-    return s:viewEdit(a:bang,a:cmd,&quot;layouts/&quot;.a:1)
+    return s:viewEdit(a:cmd,&quot;layouts/&quot;.a:1)
   endif
   let file = s:findlayout(s:controller(1))
   if file == &quot;&quot;
@@ -2394,10 +2542,10 @@ function! s:layoutEdit(bang,cmd,...)
   if file == &quot;&quot;
     let file = &quot;app/views/layouts/application.html.erb&quot;
   endif
-  call s:edit(a:cmd.(a:bang?'!':''),s:sub(file,'^/',''))
+  call s:edit(a:cmd,s:sub(file,'^/',''))
 endfunction
 
-function! s:controllerEdit(bang,cmd,...)
+function! s:controllerEdit(cmd,...)
   let suffix = '.rb'
   if a:0 == 0
     let controller = s:controller(1)
@@ -2410,37 +2558,33 @@ function! s:controllerEdit(bang,cmd,...)
   if rails#app().has_file(&quot;app/controllers/&quot;.controller.&quot;_controller.rb&quot;) || !rails#app().has_file(&quot;app/controllers/&quot;.controller.&quot;.rb&quot;)
     let suffix = &quot;_controller&quot;.suffix
   endif
-  return s:EditSimpleRb(a:bang,a:cmd,&quot;controller&quot;,controller,&quot;app/controllers/&quot;,suffix)
-endfunction
-
-function! s:helperEdit(bang,cmd,...)
-  return s:EditSimpleRb(a:bang,a:cmd,&quot;helper&quot;,a:0? a:1 : s:controller(1),&quot;app/helpers/&quot;,&quot;_helper.rb&quot;)
+  return s:EditSimpleRb(a:cmd,&quot;controller&quot;,controller,&quot;app/controllers/&quot;,suffix)
 endfunction
 
-function! s:apiEdit(bang,cmd,...)
-  return s:EditSimpleRb(a:bang,a:cmd,&quot;api&quot;,a:0 ? a:1 : s:controller(1),&quot;app/apis/&quot;,&quot;_api.rb&quot;)
+function! s:helperEdit(cmd,...)
+  return s:EditSimpleRb(a:cmd,&quot;helper&quot;,a:0? a:1 : s:controller(1),&quot;app/helpers/&quot;,&quot;_helper.rb&quot;)
 endfunction
 
-function! s:stylesheetEdit(bang,cmd,...)
+function! s:stylesheetEdit(cmd,...)
   let name = a:0 ? a:1 : s:controller(1)
   if rails#app().has('sass') &amp;&amp; rails#app().has_file('public/stylesheets/sass/'.name.'.sass')
-    return s:EditSimpleRb(a:bang,a:cmd,&quot;stylesheet&quot;,name,&quot;public/stylesheets/sass/&quot;,&quot;.sass&quot;,1)
+    return s:EditSimpleRb(a:cmd,&quot;stylesheet&quot;,name,&quot;public/stylesheets/sass/&quot;,&quot;.sass&quot;,1)
   else
-    return s:EditSimpleRb(a:bang,a:cmd,&quot;stylesheet&quot;,name,&quot;public/stylesheets/&quot;,&quot;.css&quot;,1)
+    return s:EditSimpleRb(a:cmd,&quot;stylesheet&quot;,name,&quot;public/stylesheets/&quot;,&quot;.css&quot;,1)
   endif
 endfunction
 
-function! s:javascriptEdit(bang,cmd,...)
-  return s:EditSimpleRb(a:bang,a:cmd,&quot;javascript&quot;,a:0? a:1 : &quot;application&quot;,&quot;public/javascripts/&quot;,&quot;.js&quot;,1)
+function! s:javascriptEdit(cmd,...)
+  return s:EditSimpleRb(a:cmd,&quot;javascript&quot;,a:0? a:1 : &quot;application&quot;,&quot;public/javascripts/&quot;,&quot;.js&quot;,1)
 endfunction
 
-function! s:unittestEdit(bang,cmd,...)
+function! s:unittestEdit(cmd,...)
   let f = rails#underscore(a:0 ? matchstr(a:1,'[^!#:]*') : s:model(1))
   let jump = a:0 ? matchstr(a:1,'[!#:].*') : ''
   if jump =~ '!'
-    let cmd = s:editcmdfor(a:cmd.(a:bang?'!':''))
+    let cmd = s:editcmdfor(a:cmd)
   else
-    let cmd = s:findcmdfor(a:cmd.(a:bang?'!':''))
+    let cmd = s:findcmdfor(a:cmd)
   endif
   let mapping = {'test': ['test/unit/','_test.rb'], 'spec': ['spec/models/','_spec.rb']}
   let tests = map(filter(rails#app().test_suites(),'has_key(mapping,v:val)'),'get(mapping,v:val)')
@@ -2459,16 +2603,16 @@ function! s:unittestEdit(bang,cmd,...)
       return s:findedit(cmd,prefix.f.suffix.jump)
     endif
   endfor
-  return s:EditSimpleRb(a:bang,a:cmd,&quot;unittest&quot;,f.jump,tests[0][0],tests[0][1],1)
+  return s:EditSimpleRb(a:cmd,&quot;unittest&quot;,f.jump,tests[0][0],tests[0][1],1)
 endfunction
 
-function! s:functionaltestEdit(bang,cmd,...)
+function! s:functionaltestEdit(cmd,...)
   let f = rails#underscore(a:0 ? matchstr(a:1,'[^!#:]*') : s:controller(1))
   let jump = a:0 ? matchstr(a:1,'[!#:].*') : ''
   if jump =~ '!'
-    let cmd = s:editcmdfor(a:cmd.(a:bang?'!':''))
+    let cmd = s:editcmdfor(a:cmd)
   else
-    let cmd = s:findcmdfor(a:cmd.(a:bang?'!':''))
+    let cmd = s:findcmdfor(a:cmd)
   endif
   let mapping = {'test': ['test/functional/','_test.rb'], 'spec': ['spec/controllers/','_spec.rb']}
   let tests = map(filter(rails#app().test_suites(),'has_key(mapping,v:val)'),'get(mapping,v:val)')
@@ -2484,25 +2628,21 @@ function! s:functionaltestEdit(bang,cmd,...)
       return s:findedit(cmd,prefix.f.'_api'.suffix.jump)
     endif
   endfor
-  return s:EditSimpleRb(a:bang,a:cmd,&quot;functionaltest&quot;,f.jump,tests[0][0],tests[0][1],1)
+  return s:EditSimpleRb(a:cmd,&quot;functionaltest&quot;,f.jump,tests[0][0],tests[0][1],1)
 endfunction
 
-function! s:integrationtestEdit(bang,cmd,...)
+function! s:integrationtestEdit(cmd,...)
   if !a:0
-    if rails#app().has('cucumber')
-      return s:EditSimpleRb(a:bang,a:cmd,&quot;integrationtest&quot;,&quot;support/env&quot;,&quot;features/&quot;,&quot;.rb&quot;)
-    else
-      return s:EditSimpleRb(a:bang,a:cmd,&quot;integrationtest&quot;,&quot;test_helper&quot;,&quot;test/&quot;,&quot;.rb&quot;)
-    endif
+    return s:EditSimpleRb(a:cmd,&quot;integrationtest&quot;,&quot;test/test_helper\nfeatures/support/env\nspec/spec_helper&quot;,&quot;&quot;,&quot;.rb&quot;)
   endif
   let f = rails#underscore(matchstr(a:1,'[^!#:]*'))
   let jump = matchstr(a:1,'[!#:].*')
   if jump =~ '!'
-    let cmd = s:editcmdfor(a:cmd.(a:bang?'!':''))
+    let cmd = s:editcmdfor(a:cmd)
   else
-    let cmd = s:findcmdfor(a:cmd.(a:bang?'!':''))
+    let cmd = s:findcmdfor(a:cmd)
   endif
-  let mapping = {'test': ['test/integration/','_test.rb'], 'cucumber': ['features/','.feature']}
+  let mapping = {'test': ['test/integration/','_test.rb'], 'spec': ['spec/integration/','_spec.rb'], 'cucumber': ['features/','.feature']}
   let tests = map(filter(rails#app().test_suites(),'has_key(mapping,v:val)'),'get(mapping,v:val)')
   if empty(tests)
     let tests = [mapping['test']]
@@ -2514,19 +2654,19 @@ function! s:integrationtestEdit(bang,cmd,...)
       return s:findedit(cmd,prefix.rails#underscore(f).suffix.jump)
     endif
   endfor
-  return s:EditSimpleRb(a:bang,a:cmd,&quot;integrationtest&quot;,f.jump,tests[0][0],tests[0][1],1)
+  return s:EditSimpleRb(a:cmd,&quot;integrationtest&quot;,f.jump,tests[0][0],tests[0][1],1)
 endfunction
 
-function! s:specEdit(bang,cmd,...)
+function! s:specEdit(cmd,...)
   if a:0
-    return s:EditSimpleRb(a:bang,a:cmd,&quot;spec&quot;,a:1,&quot;spec/&quot;,&quot;_spec.rb&quot;)
+    return s:EditSimpleRb(a:cmd,&quot;spec&quot;,a:1,&quot;spec/&quot;,&quot;_spec.rb&quot;)
   else
-    call s:EditSimpleRb(a:bang,a:cmd,&quot;spec&quot;,&quot;spec_helper&quot;,&quot;spec/&quot;,&quot;.rb&quot;)
+    call s:EditSimpleRb(a:cmd,&quot;spec&quot;,&quot;spec_helper&quot;,&quot;spec/&quot;,&quot;.rb&quot;)
   endif
 endfunction
 
-function! s:pluginEdit(bang,cmd,...)
-  let cmd = s:findcmdfor(a:cmd.(a:bang?'!':''))
+function! s:pluginEdit(cmd,...)
+  let cmd = s:findcmdfor(a:cmd)
   let plugin = &quot;&quot;
   let extra = &quot;&quot;
   if RailsFilePath() =~ '\&lt;vendor/plugins/.'
@@ -2535,7 +2675,7 @@ function! s:pluginEdit(bang,cmd,...)
   endif
   if a:0
     if a:1 =~ '^[^/.]*/\=$' &amp;&amp; rails#app().has_file(&quot;vendor/plugins/&quot;.a:1.&quot;/init.rb&quot;)
-      return s:EditSimpleRb(a:bang,a:cmd,&quot;plugin&quot;,s:sub(a:1,'/$',''),&quot;vendor/plugins/&quot;,&quot;/init.rb&quot;)
+      return s:EditSimpleRb(a:cmd,&quot;plugin&quot;,s:sub(a:1,'/$',''),&quot;vendor/plugins/&quot;,&quot;/init.rb&quot;)
     elseif plugin == &quot;&quot;
       call s:edit(cmd,&quot;vendor/plugins/&quot;.s:sub(a:1,'\.$',''))
     elseif a:1 == &quot;.&quot;
@@ -2546,11 +2686,11 @@ function! s:pluginEdit(bang,cmd,...)
       call s:findedit(cmd,&quot;vendor/plugins/&quot;.a:1.&quot;\nvendor/plugins/&quot;.plugin.&quot;/&quot;.a:1)
     endif
   else
-    return s:EditSimpleRb(a:bang,a:cmd,&quot;plugin&quot;,plugin,&quot;vendor/plugins/&quot;,&quot;/init.rb&quot;)
+    return s:EditSimpleRb(a:cmd,&quot;plugin&quot;,plugin,&quot;vendor/plugins/&quot;,&quot;/init.rb&quot;)
   endif
 endfunction
 
-function! s:taskEdit(bang,cmd,...)
+function! s:taskEdit(cmd,...)
   let plugin = &quot;&quot;
   let extra = &quot;&quot;
   if RailsFilePath() =~ '\&lt;vendor/plugins/.'
@@ -2558,30 +2698,31 @@ function! s:taskEdit(bang,cmd,...)
     let extra = plugin.&quot;/tasks/\n&quot;.plugin.&quot;/lib/tasks/\n&quot;
   endif
   if a:0
-    call s:EditSimpleRb(a:bang,a:cmd,&quot;task&quot;,a:1,extra.&quot;lib/tasks/&quot;,&quot;.rake&quot;)
+    call s:EditSimpleRb(a:cmd,&quot;task&quot;,a:1,extra.&quot;lib/tasks/&quot;,&quot;.rake&quot;)
   else
-    call s:findedit((a:bang ? &quot;!&quot; : &quot;&quot;),(plugin != &quot;&quot; ? plugin.&quot;/Rakefile\n&quot; : &quot;&quot;).&quot;Rakefile&quot;)
+    call s:findedit(a:cmd,(plugin != &quot;&quot; ? plugin.&quot;/Rakefile\n&quot; : &quot;&quot;).&quot;Rakefile&quot;)
   endif
 endfunction
 
-function! s:libEdit(bang,cmd,...)
+function! s:libEdit(cmd,...)
   let extra = &quot;&quot;
   if RailsFilePath() =~ '\&lt;vendor/plugins/.'
     let extra = s:sub(RailsFilePath(),'&lt;vendor/plugins/[^/]*/\zs.*','lib/').&quot;\n&quot;
   endif
   if a:0
-    call s:EditSimpleRb(a:bang,a:cmd,&quot;lib&quot;,a:0? a:1 : &quot;&quot;,extra.&quot;lib/&quot;,&quot;.rb&quot;)
+    call s:EditSimpleRb(a:cmd,&quot;lib&quot;,a:0? a:1 : &quot;&quot;,extra.&quot;lib/&quot;,&quot;.rb&quot;)
   else
-    call s:EditSimpleRb(a:bang,a:cmd,&quot;lib&quot;,&quot;routes&quot;,&quot;config/&quot;,&quot;.rb&quot;)
+    call s:EditSimpleRb(a:cmd,&quot;lib&quot;,&quot;routes&quot;,&quot;config/&quot;,&quot;.rb&quot;)
+    call s:warn('Warning: :Rlib with no argument has been deprecated in favor of :Rinitializer')
   endif
 endfunction
 
-function! s:environmentEdit(bang,cmd,...)
-  return s:EditSimpleRb(a:bang,a:cmd,&quot;environment&quot;,a:0? a:1 : &quot;../environment&quot;,&quot;config/environments/&quot;,&quot;.rb&quot;)
+function! s:environmentEdit(cmd,...)
+  return s:EditSimpleRb(a:cmd,&quot;environment&quot;,a:0? a:1 : &quot;../environment&quot;,&quot;config/environments/&quot;,&quot;.rb&quot;)
 endfunction
 
-function! s:initializerEdit(bang,cmd,...)
-  return s:EditSimpleRb(a:bang,a:cmd,&quot;initializer&quot;,a:0? a:1 : &quot;../routes&quot;,&quot;config/initializers/&quot;,&quot;.rb&quot;)
+function! s:initializerEdit(cmd,...)
+  return s:EditSimpleRb(a:cmd,&quot;initializer&quot;,a:0? a:1 : &quot;../routes&quot;,&quot;config/initializers/&quot;,&quot;.rb&quot;)
 endfunction
 
 &quot; }}}1
@@ -2609,6 +2750,8 @@ function! s:findcmdfor(cmd)
     return 'vert '.num.'sfind'.bang
   elseif cmd == 'T'
     return num.'tabfind'.bang
+  elseif cmd == 'D'
+    return num.'read'.bang
   else
     return num.cmd.bang
   endif
@@ -2681,88 +2824,162 @@ function! s:edit(cmd,file,...)
   endif
 endfunction
 
-function! s:Alternate(bang,cmd,...)
+function! s:Alternate(cmd,line1,line2,count,...)
   if a:0
-    return call('s:Find',[a:bang,1,a:cmd]+a:000)
+    if a:count &amp;&amp; a:cmd !~# 'D'
+      return call('s:Find',[1,a:line1.a:cmd]+a:000)
+    elseif a:count
+      return call('s:Edit',[1,a:line1.a:cmd]+a:000)
+    else
+      return call('s:Edit',[1,a:cmd]+a:000)
+    endif
   else
-    let cmd = a:cmd.(a:bang?&quot;!&quot;:&quot;&quot;)
-    let file = s:AlternateFile()
-    if file != &quot;&quot;
-      call s:findedit(cmd,file)
+    let file = s:getopt(a:count ? 'related' : 'alternate', 'bl')
+    if file == ''
+      let file = rails#buffer().related(a:count)
+    endif
+    if file != ''
+      call s:findedit(a:cmd,file)
     else
       call s:warn(&quot;No alternate file is defined&quot;)
     endif
   endif
 endfunction
 
-function! s:AlternateFile()
-  let f = RailsFilePath()
-  let t = RailsFileType()
-  let altopt = s:getopt(&quot;alternate&quot;,&quot;bl&quot;)
-  if altopt != &quot;&quot;
-    return altopt
-  elseif f =~ '\&lt;config/environments/'
+function! s:Related(cmd,line1,line2,count,...)
+  if a:count == 0 &amp;&amp; a:0 == 0
+    return s:Alternate(a:cmd,a:line1,a:line1,a:line1)
+  else
+    return call('s:Alternate',[a:cmd,a:line1,a:line2,a:count]+a:000)
+  endif
+endfunction
+
+function! s:Complete_related(A,L,P)
+  if a:L =~# '^[[:alpha:]]'
+    return s:Complete_edit(a:A,a:L,a:P)
+  else
+    return s:Complete_find(a:A,a:L,a:P)
+  endif
+endfunction
+
+function! s:readable_related(...) dict abort
+  let f = self.name()
+  let t = self.type_name()
+  if a:0 &amp;&amp; a:1
+    let lastmethod = self.last_method(a:1)
+    if t =~ '^\%(controller\|model-mailer\)\&gt;' &amp;&amp; lastmethod != &quot;&quot;
+      let root = s:sub(s:sub(s:sub(f,'/application\.rb$','/shared_controller.rb'),'/%(controllers|models)/','/views/'),'%(_controller)=\.rb$','/'.lastmethod)
+      let format = self.last_format(a:1)
+      if format == '' | let format = 'html' | endif
+      if glob(self.app().path().'/'.root.'.'.format.'.*[^~]') != ''
+        return root . '.' . format
+      else
+        return root
+      endif
+    elseif f =~ '\&lt;config/environments/'
+      return &quot;config/database.yml#&quot;. fnamemodify(f,':t:r')
+    elseif f =~ '\&lt;config/database\.yml$'
+      if lastmethod != &quot;&quot;
+        return &quot;config/environments/&quot;.lastmethod.&quot;.rb&quot;
+      else
+        return &quot;config/environment.rb&quot;
+      endif
+    elseif f =~ '\&lt;config/routes\.rb$'      | return &quot;config/database.yml&quot;
+    elseif f =~ '\&lt;config/environment\.rb$' | return &quot;config/routes.rb&quot;
+    elseif t =~ '^view-layout\&gt;'
+      return s:sub(s:sub(s:sub(f,'/views/','/controllers/'),'/layouts/(\k+)\..*$','/\1_controller.rb'),'&lt;application_controller\.rb$','application.rb')
+    elseif t =~ '^view\&gt;'
+      let controller  = s:sub(s:sub(f,'/views/','/controllers/'),'/(\k+%(\.\k+)=)\..*$','_controller.rb#\1')
+      let controller2 = s:sub(s:sub(f,'/views/','/controllers/'),'/(\k+%(\.\k+)=)\..*$','.rb#\1')
+      let model       = s:sub(s:sub(f,'/views/','/models/'),'/(\k+)\..*$','.rb#\1')
+      if self.app().has_file(s:sub(controller,'#.{-}$',''))
+        return controller
+      elseif self.app().has_file(s:sub(controller2,'#.{-}$',''))
+        return controller2
+      elseif self.app().has_file(s:sub(model,'#.{-}$','')) || model =~ '_mailer\.rb#'
+        return model
+      else
+        return controller
+      endif
+    elseif t =~ '^controller\&gt;'
+      return s:sub(s:sub(f,'/controllers/','/helpers/'),'%(_controller)=\.rb$','_helper.rb')
+    &quot; elseif t=~ '^helper\&gt;'
+      &quot; return s:findlayout(s:controller())
+    elseif t =~ '^model-arb\&gt;'
+      let table_name = matchstr(join(self.getline(1,50),&quot;\n&quot;),'\n\s*set_table_name\s*[:&quot;'']\zs\w\+')
+      if table_name == ''
+        let table_name = rails#pluralize(s:gsub(s:sub(fnamemodify(f,':r'),'.{-}&lt;app/models/',''),'/','_'))
+      endif
+      return self.app().migration('0#'.table_name)
+    elseif t =~ '^model-aro\&gt;'
+      return s:sub(f,'_observer\.rb$','.rb')
+    elseif f =~ '\&lt;db/schema\.rb$'
+      return self.app().migration(1)
+    endif
+  endif
+  if f =~ '\&lt;config/environments/'
     return &quot;config/environment.rb&quot;
   elseif f == 'README'
     return &quot;config/database.yml&quot;
   elseif f =~ '\&lt;config/database\.yml$'   | return &quot;config/routes.rb&quot;
   elseif f =~ '\&lt;config/routes\.rb$'      | return &quot;config/environment.rb&quot;
   elseif f =~ '\&lt;config/environment\.rb$' | return &quot;config/database.yml&quot;
-  elseif f =~ '\&lt;db/migrate/\d\d\d_'
-    let num = matchstr(f,'\&lt;db/migrate/0*\zs\d\+\ze_')-1
-    return rails#app().migration(num)
+  elseif f =~ '\&lt;db/migrate/'
+    let migrations = sort(self.app().relglob('db/migrate/','*','.rb'))
+    let me = matchstr(f,'\&lt;db/migrate/\zs.*\ze\.rb$')
+    if !exists('l:lastmethod') || lastmethod == 'down'
+      let candidates = reverse(filter(copy(migrations),'v:val &lt; me'))
+      let migration = &quot;db/migrate/&quot;.get(candidates,0,migrations[-1]).&quot;.rb&quot;
+    else
+      let candidates = filter(copy(migrations),'v:val &gt; me')
+      let migration = &quot;db/migrate/&quot;.get(candidates,0,migrations[0]).&quot;.rb&quot;
+    endif
+    return migration . (exists('l:lastmethod') &amp;&amp; lastmethod != '' ? '#'.lastmethod : '')
   elseif f =~ '\&lt;application\.js$'
     return &quot;app/helpers/application_helper.rb&quot;
-  elseif t =~ '^js\&gt;'
+  elseif t =~ '^javascript\&gt;'
     return &quot;public/javascripts/application.js&quot;
   elseif f =~ '\&lt;db/schema\.rb$'
-    return rails#app().migration('')
+    return self.app().migration('')
   elseif t =~ '^view\&gt;'
-    if t =~ '\&lt;layout\&gt;'
-      let dest = fnamemodify(f,':r:s?/layouts\&gt;??').'/layout.'.fnamemodify(f,':e')
-    else
-      let dest = f
-    endif
-    &quot; Go to the (r)spec, helper, controller, or (mailer) model
-    let spec1      = fnamemodify(dest,':s?\&lt;app/?spec/?').&quot;_spec.rb&quot;
-    let spec2      = fnamemodify(dest,':r:s?\&lt;app/?spec/?').&quot;_spec.rb&quot;
-    let spec3      = fnamemodify(dest,':r:r:s?\&lt;app/?spec/?').&quot;_spec.rb&quot;
-    let helper     = fnamemodify(dest,':h:s?/views/?/helpers/?').&quot;_helper.rb&quot;
-    let controller = fnamemodify(dest,':h:s?/views/?/controllers/?').&quot;_controller.rb&quot;
-    let model      = fnamemodify(dest,':h:s?/views/?/models/?').&quot;.rb&quot;
-    if rails#app().has_file(spec1)
+    let spec1 = fnamemodify(f,':s?\&lt;app/?spec/?').&quot;_spec.rb&quot;
+    let spec2 = fnamemodify(f,':r:s?\&lt;app/?spec/?').&quot;_spec.rb&quot;
+    let spec3 = fnamemodify(f,':r:r:s?\&lt;app/?spec/?').&quot;_spec.rb&quot;
+    if self.app().has_file(spec1)
       return spec1
-    elseif rails#app().has_file(spec2)
+    elseif self.app().has_file(spec2)
       return spec2
-    elseif rails#app().has_file(spec3)
+    elseif self.app().has_file(spec3)
       return spec3
-    elseif rails#app().has_file(helper)
-      return helper
-    elseif rails#app().has_file(controller)
-      let jumpto = expand(&quot;%:t:r&quot;)
-      return controller.'#'.jumpto
-    elseif rails#app().has_file(model)
-      return model
+    elseif self.app().has('spec')
+      return spec2
     else
-      return helper
+      if t =~ '\&lt;layout\&gt;'
+        let dest = fnamemodify(f,':r:s?/layouts\&gt;??').'/layout.'.fnamemodify(f,':e')
+      else
+        let dest = f
+      endif
+      return s:sub(s:sub(dest,'&lt;app/views/','test/functional/'),'/[^/]*$','_controller_test.rb')
     endif
   elseif t =~ '^controller-api\&gt;'
     let api = s:sub(s:sub(f,'/controllers/','/apis/'),'_controller\.rb$','_api.rb')
     return api
+  elseif t =~ '^api\&gt;'
+    return s:sub(s:sub(f,'/apis/','/controllers/'),'_api\.rb$','_controller.rb')
   elseif t =~ '^helper\&gt;'
     let controller = s:sub(s:sub(f,'/helpers/','/controllers/'),'_helper\.rb$','_controller.rb')
     let controller = s:sub(controller,'application_controller','application')
     let spec = s:sub(s:sub(f,'&lt;app/','spec/'),'\.rb$','_spec.rb')
-    if rails#app().has_file(spec)
+    if self.app().has_file(spec)
       return spec
     else
       return controller
     endif
   elseif t =~ '\&lt;fixtures\&gt;' &amp;&amp; f =~ '\&lt;spec/'
-    let file = rails#singularize(expand(&quot;%:t:r&quot;)).'_spec.rb'
+    let file = rails#singularize(fnamemodify(f,&quot;:t:r&quot;)).'_spec.rb'
     return file
   elseif t =~ '\&lt;fixtures\&gt;'
-    let file = rails#singularize(expand(&quot;%:t:r&quot;)).'_test.rb' &quot; .expand('%:e')
+    let file = rails#singularize(fnamemodify(f,&quot;:t:r&quot;)).'_test.rb'
     return file
   elseif f == ''
     call s:warn(&quot;No filename present&quot;)
@@ -2794,7 +3011,7 @@ function! s:AlternateFile()
     elseif t == 'spec-lib'
       return s:sub(file,'&lt;spec/','')
     elseif t == 'lib'
-      return s:sub(f, '&lt;lib/(.*)\.rb$', 'test/unit/\1_test\.rb').&quot;\n&quot;.s:sub(f, '&lt;lib/(.*)\.rb$', 'spec/lib/\1_spec\.rb')
+      return s:sub(f, '&lt;lib/(.*)\.rb$', 'test/unit/\1_test.rb').&quot;\n&quot;.s:sub(f, '&lt;lib/(.*)\.rb$', 'spec/lib/\1_spec.rb')
     elseif t =~ '^spec\&gt;'
       return s:sub(file,'&lt;spec/','app/')
     elseif file =~ '\&lt;vendor/.*/lib/'
@@ -2809,94 +3026,7 @@ function! s:AlternateFile()
   endif
 endfunction
 
-function! s:Related(bang,cmd,...)
-  if a:0
-    return call('s:Edit',[a:bang,1,a:cmd]+a:000)
-  else
-    let cmd = a:cmd.(a:bang?&quot;!&quot;:&quot;&quot;)
-    let file = s:RelatedFile()
-    if file != &quot;&quot;
-      call s:findedit(cmd,file)
-    else
-      call s:warn(&quot;No related file is defined&quot;)
-    endif
-  endif
-endfunction
-
-function! s:RelatedFile()
-  let f = RailsFilePath()
-  let t = RailsFileType()
-  let lastmethod = s:lastmethod()
-  if s:getopt(&quot;related&quot;,&quot;l&quot;) != &quot;&quot;
-    return s:getopt(&quot;related&quot;,&quot;l&quot;)
-  elseif t =~ '^\%(controller\|model-mailer\)\&gt;' &amp;&amp; lastmethod != &quot;&quot;
-    let root = s:sub(s:sub(s:sub(f,'/application\.rb$','/shared_controller.rb'),'/%(controllers|models)/','/views/'),'%(_controller)=\.rb$','/'.lastmethod)
-    let format = s:format('html')
-    if glob(rails#app().path().'/'.root.'.'.format.'.*[^~]') != ''
-      return root . '.' . format
-    else
-      return root
-    endif
-  elseif s:getopt(&quot;related&quot;,&quot;b&quot;) != &quot;&quot;
-    return s:getopt(&quot;related&quot;,&quot;b&quot;)
-  elseif f =~ '\&lt;config/environments/'
-    return &quot;config/database.yml#&quot;. expand(&quot;%:t:r&quot;)
-  elseif f == 'README'
-    return &quot;config/database.yml&quot;
-  elseif f =~ '\&lt;config/database\.yml$'
-    let lm = s:lastmethod()
-    if lm != &quot;&quot;
-      return &quot;config/environments/&quot;.lm.&quot;.rb\nconfig/environment.rb&quot;
-    else
-      return &quot;config/environment.rb&quot;
-    endif
-  elseif f =~ '\&lt;config/routes\.rb$'      | return &quot;config/database.yml&quot;
-  elseif f =~ '\&lt;config/environment\.rb$' | return &quot;config/routes.rb&quot;
-  elseif f =~ '\&lt;db/migrate/\d\d\d_'
-    let num = matchstr(f,'\&lt;db/migrate/0*\zs\d\+\ze_')+1
-    let migr = rails#app().migration(num)
-    return migr == '' ? &quot;db/schema.rb&quot; : migr
-  elseif t =~ '^test\&gt;' &amp;&amp; f =~ '\&lt;test/\w\+/'
-    let target = s:sub(f,'.*&lt;test/\w+/','test/mocks/test/')
-    let target = s:sub(target,'_test\.rb$','.rb')
-    return target
-  elseif f =~ '\&lt;application\.js$'
-    return &quot;app/helpers/application_helper.rb&quot;
-  elseif t =~ '^js\&gt;'
-    return &quot;public/javascripts/application.js&quot;
-  elseif t =~ '^view-layout\&gt;'
-    return s:sub(s:sub(s:sub(f,'/views/','/controllers/'),'/layouts/(\k+)\..*$','/\1_controller.rb'),'&lt;application_controller\.rb$','application.rb')
-  elseif t =~ '^view\&gt;'
-    let controller  = s:sub(s:sub(f,'/views/','/controllers/'),'/(\k+%(\.\k+)=)\..*$','_controller.rb#\1')
-    let controller2 = s:sub(s:sub(f,'/views/','/controllers/'),'/(\k+%(\.\k+)=)\..*$','.rb#\1')
-    let model       = s:sub(s:sub(f,'/views/','/models/'),'/(\k+)\..*$','.rb#\1')
-    if filereadable(s:sub(controller,'#.{-}$',''))
-      return controller
-    elseif filereadable(s:sub(controller2,'#.{-}$',''))
-      return controller2
-    elseif filereadable(s:sub(model,'#.{-}$','')) || model =~ '_mailer\.rb#'
-      return model
-    else
-      return controller
-    endif
-  elseif t =~ '^controller-api\&gt;'
-    return s:sub(s:sub(f,'/controllers/','/apis/'),'_controller\.rb$','_api.rb')
-  elseif t =~ '^controller\&gt;'
-    return s:sub(s:sub(f,'/controllers/','/helpers/'),'%(_controller)=\.rb$','_helper.rb')
-  elseif t=~ '^helper\&gt;'
-    return s:findlayout(s:controller())
-  elseif t =~ '^model-arb\&gt;'
-    return rails#app().migration('create_'.rails#pluralize(s:gsub(s:model(),'/','_')))
-  elseif t =~ '^model-aro\&gt;'
-    return s:sub(f,'_observer\.rb$','.rb')
-  elseif t =~ '^api\&gt;'
-    return s:sub(s:sub(f,'/apis/','/controllers/'),'_api\.rb$','_controller.rb')
-  elseif f =~ '\&lt;db/schema\.rb$'
-    return rails#app().migration(1)
-  else
-    return &quot;&quot;
-  endif
-endfunction
+call s:add_methods('readable',['related'])
 
 &quot; }}}1
 &quot; Partial Extraction {{{1
@@ -3005,10 +3135,13 @@ function! s:Extract(bang,...) range abort
   silent exe range.&quot;yank&quot;
   let partial = @@
   let @@ = buf
-  let ai = &amp;ai
-  let &amp;ai = 0
-  silent exe &quot;norm! :&quot;.first.&quot;,&quot;.last.&quot;change\&lt;CR&gt;&quot;.fspaces.renderstr.&quot;\&lt;CR&gt;.\&lt;CR&gt;&quot;
-  let &amp;ai = ai
+  let old_ai = &amp;ai
+  try
+    let &amp;ai = 0
+    silent exe &quot;norm! :&quot;.first.&quot;,&quot;.last.&quot;change\&lt;CR&gt;&quot;.fspaces.renderstr.&quot;\&lt;CR&gt;.\&lt;CR&gt;&quot;
+  finally
+    let &amp;ai = old_ai
+  endtry
   if renderstr =~ '&lt;%'
     norm ^6w
   else
@@ -3222,7 +3355,7 @@ function! s:helpermethods()
         \.&quot;date_select datetime_select debug distance_of_time_in_words distance_of_time_in_words_to_now div_for dom_class dom_id draggable_element draggable_element_js drop_receiving_element drop_receiving_element_js &quot;
         \.&quot;error_message_on error_messages_for escape_javascript escape_once evaluate_remote_response excerpt &quot;
         \.&quot;field_set_tag fields_for file_field file_field_tag form form_for form_remote_for form_remote_tag form_tag &quot;
-        \.&quot;grouped_options_for_select &quot;
+        \.&quot;grouped_collection_select grouped_options_for_select &quot;
         \.&quot;hidden_field hidden_field_tag highlight &quot;
         \.&quot;image_path image_submit_tag image_tag input &quot;
         \.&quot;javascript_cdata_section javascript_include_tag javascript_path javascript_tag &quot;
@@ -3271,10 +3404,7 @@ call s:add_methods('app', ['user_classes','user_assertions'])
 function! s:BufSyntax()
   if (!exists(&quot;g:rails_syntax&quot;) || g:rails_syntax)
     let t = RailsFileType()
-    let s:prototype_functions = &quot;$ $$ $A $F $H $R $w&quot;
-    &quot; From the Prototype bundle for TextMate
-    let s:prototype_classes = &quot;Prototype Class Abstract Try PeriodicalExecuter Enumerable Hash ObjectRange Element Ajax Responders Base Request Updater PeriodicalUpdater Toggle Insertion Before Top Bottom After ClassNames Form Serializers TimedObserver Observer EventObserver Event Position Effect Effect2 Transitions ScopedQueue Queues DefaultOptions Parallel Opacity Move MoveBy Scale Highlight ScrollTo Fade Appear Puff BlindUp BlindDown SwitchOff DropOut Shake SlideDown SlideUp Squish Grow Shrink Pulsate Fold&quot;
-
+    let s:javascript_functions = &quot;$ $$ $A $F $H $R $w jQuery&quot;
     let rails_helper_methods = '+\.\@&lt;!\&lt;\('.s:gsub(s:helpermethods(),'\s+','\\|').'\)\&gt;+'
     let classes = s:gsub(join(rails#app().user_classes(),' '),'::',' ')
     if &amp;syntax == 'ruby'
@@ -3305,8 +3435,6 @@ function! s:BufSyntax()
       endif
       if t =~ '^controller\&gt;' || t =~ '^view\&gt;' || t=~ '^helper\&gt;'
         syn keyword rubyRailsMethod params request response session headers cookies flash
-        syn match rubyRailsError '[@:]\@&lt;!@\%(params\|request\|response\|session\|headers\|cookies\|flash\)\&gt;'
-        syn match rubyRailsError '\&lt;\%(render_partial\|puts\)\&gt;'
         syn keyword rubyRailsRenderMethod render
         syn keyword rubyRailsMethod logger
       endif
@@ -3318,8 +3446,7 @@ function! s:BufSyntax()
           syn keyword rubyRailsMethod local_assigns
         endif
       elseif t =~ '^controller\&gt;'
-        syn keyword rubyRailsControllerMethod helper helper_attr helper_method filter layout url_for serialize exempt_from_layout filter_parameter_logging hide_action cache_sweeper protect_from_forgery
-        syn match rubyRailsDeprecatedMethod '\&lt;render_\%(action\|text\|file\|template\|nothing\|without_layout\)\&gt;'
+        syn keyword rubyRailsControllerMethod helper helper_attr helper_method filter layout url_for serialize exempt_from_layout filter_parameter_logging hide_action cache_sweeper protect_from_forgery caches_page cache_page caches_action expire_page expire_action
         syn keyword rubyRailsRenderMethod render_to_string redirect_to head
         syn match   rubyRailsRenderMethod '\&lt;respond_to\&gt;?\@!'
         syn keyword rubyRailsFilterMethod before_filter append_before_filter prepend_before_filter after_filter append_after_filter prepend_after_filter around_filter append_around_filter prepend_around_filter skip_before_filter skip_after_filter
@@ -3400,7 +3527,6 @@ function! s:BufSyntax()
       else
         syn cluster erubyRailsRegions contains=erubyOneLiner,erubyBlock,erubyExpression,rubyInterpolation
       endif
-      syn match rubyRailsError '[@:]\@&lt;!@\%(params\|request\|response\|session\|headers\|cookies\|flash\)\&gt;' contained containedin=@erubyRailsRegions
       exe &quot;syn keyword erubyRailsHelperMethod &quot;.s:sub(s:helpermethods(),'&lt;select\s+','').&quot; contained containedin=@erubyRailsRegions&quot;
       syn match erubyRailsHelperMethod '\&lt;select\&gt;\%(\s*{\|\s*do\&gt;\|\s*(\=\s*&amp;\)\@!' contained containedin=@erubyRailsRegions
       syn keyword erubyRailsMethod debugger logger contained containedin=@erubyRailsRegions
@@ -3410,13 +3536,10 @@ function! s:BufSyntax()
         syn keyword erubyRailsMethod local_assigns contained containedin=@erubyRailsRegions
       endif
       syn keyword erubyRailsRenderMethod render contained containedin=@erubyRailsRegions
-      syn match rubyRailsError '[^@:]\@&lt;!@\%(params\|request\|response\|session\|headers\|cookies\|flash\)\&gt;' contained containedin=@erubyRailsRegions
-      syn match rubyRailsError '\&lt;\%(render_partial\|puts\)\&gt;' contained containedin=@erubyRailsRegions
       syn case match
       set isk+=$
-      exe &quot;syn keyword javascriptRailsClass contained &quot;.s:prototype_classes
-      exe &quot;syn keyword javascriptRailsFunction contained &quot;.s:prototype_functions
-      syn cluster htmlJavaScript add=javascriptRailsClass,javascriptRailsFunction
+      exe &quot;syn keyword javascriptRailsFunction contained &quot;.s:javascript_functions
+      syn cluster htmlJavaScript add=javascriptRailsFunction
     elseif &amp;syntax == &quot;yaml&quot;
       syn case match
       &quot; Modeled after syntax/eruby.vim
@@ -3437,15 +3560,13 @@ function! s:BufSyntax()
     elseif &amp;syntax == &quot;html&quot;
       syn case match
       set isk+=$
-      exe &quot;syn keyword javascriptRailsClass contained &quot;.s:prototype_classes
-      exe &quot;syn keyword javascriptRailsFunction contained &quot;.s:prototype_functions
-      syn cluster htmlJavaScript add=javascriptRailsClass,javascriptRailsFunction
+      exe &quot;syn keyword javascriptRailsFunction contained &quot;.s:javascript_functions
+      syn cluster htmlJavaScript add=javascriptRailsFunction
     elseif &amp;syntax == &quot;javascript&quot;
       &quot; The syntax file included with Vim incorrectly sets syn case ignore.
       syn case match
       set isk+=$
-      exe &quot;syn keyword javascriptRailsClass &quot;.s:prototype_classes
-      exe &quot;syn keyword javascriptRailsFunction &quot;.s:prototype_functions
+      exe &quot;syn keyword javascriptRailsFunction &quot;.s:javascript_functions
 
     endif
   endif
@@ -3464,13 +3585,11 @@ function! s:HiDefaults()
   hi def link rubyRailsViewMethod             rubyRailsMethod
   hi def link rubyRailsMigrationMethod        rubyRailsMethod
   hi def link rubyRailsControllerMethod       rubyRailsMethod
-  hi def link rubyRailsDeprecatedMethod       rubyRailsError
   hi def link rubyRailsFilterMethod           rubyRailsMethod
   hi def link rubyRailsTestControllerMethod   rubyRailsTestMethod
   hi def link rubyRailsTestMethod             rubyRailsMethod
   hi def link rubyRailsRakeMethod             rubyRailsMethod
   hi def link rubyRailsMethod                 railsMethod
-  hi def link rubyRailsError                  rubyError
   hi def link rubyRailsInclude                rubyInclude
   hi def link rubyRailsUserClass              railsUserClass
   hi def link rubyRailsUserMethod             railsUserMethod
@@ -3487,7 +3606,6 @@ function! s:HiDefaults()
   hi def link yamlRailsUserClass              railsUserClass
   hi def link yamlRailsUserMethod             railsUserMethod
   hi def link javascriptRailsFunction         railsMethod
-  hi def link javascriptRailsClass            railsClass
   hi def link railsUserClass                  railsClass
   hi def link railsMethod                     Function
   hi def link railsClass                      Type
@@ -3499,7 +3617,7 @@ endfunction
 function! rails#log_syntax()
   syn match   railslogRender      '^\s*\&lt;\%(Processing\|Rendering\|Rendered\|Redirected\|Completed\)\&gt;'
   syn match   railslogComment     '^\s*# .*'
-  syn match   railslogModel       '^\s*\u\%(\w\|:\)* \%(Load\%( Including Associations\| IDs For Limited Eager Loading\)\=\|Columns\|Count\|Update\|Destroy\|Delete all\)\&gt;' skipwhite nextgroup=railslogModelNum
+  syn match   railslogModel       '^\s*\u\%(\w\|:\)* \%(Load\%( Including Associations\| IDs For Limited Eager Loading\)\=\|Columns\|Count\|Create\|Update\|Destroy\|Delete all\)\&gt;' skipwhite nextgroup=railslogModelNum
   syn match   railslogModel       '^\s*SQL\&gt;' skipwhite nextgroup=railslogModelNum
   syn region  railslogModelNum    start='(' end=')' contains=railslogNumber contained skipwhite nextgroup=railslogSQL
   syn match   railslogSQL         '\u.*$' contained
@@ -3538,10 +3656,10 @@ endfunction
 
 function! s:addtostatus(letter,status)
   let status = a:status
-  if status !~ 'Rails' &amp;&amp; g:rails_statusline
-    let   status=substitute(status,'\C%'.tolower(a:letter),'%'.tolower(a:letter).'%{RailsStatusline()}','')
-    if status !~ 'Rails'
-      let status=substitute(status,'\C%'.toupper(a:letter),'%'.toupper(a:letter).'%{RailsSTATUSLINE()}','')
+  if status !~ 'rails' &amp;&amp; g:rails_statusline
+    let   status=substitute(status,'\C%'.tolower(a:letter),'%'.tolower(a:letter).'%{rails#statusline()}','')
+    if status !~ 'rails'
+      let status=substitute(status,'\C%'.toupper(a:letter),'%'.toupper(a:letter).'%{rails#STATUSLINE()}','')
     endif
   endif
   return status
@@ -3576,26 +3694,26 @@ endfunction
 
 function! s:InjectIntoStatusline(status)
   let status = a:status
-  if status !~ 'Rails'
+  if status !~ 'rails'
     let status = s:addtostatus('y',status)
     let status = s:addtostatus('r',status)
     let status = s:addtostatus('m',status)
     let status = s:addtostatus('w',status)
     let status = s:addtostatus('h',status)
-    if status !~ 'Rails'
-      let status=substitute(status,'%=','%{RailsStatusline()}%=','')
+    if status !~ 'rails'
+      let status=substitute(status,'%=','%{rails#statusline()}%=','')
     endif
-    if status !~ 'Rails' &amp;&amp; status != ''
-      let status .= '%{RailsStatusline()}'
+    if status !~ 'rails' &amp;&amp; status != ''
+      let status .= '%{rails#statusline()}'
     endif
   endif
   return status
 endfunction
 
-function! RailsStatusline()
+function! rails#statusline(...)
   if exists(&quot;b:rails_root&quot;)
     let t = RailsFileType()
-    if t != &quot;&quot;
+    if t != &quot;&quot; &amp;&amp; a:0 &amp;&amp; a:1
       return &quot;[Rails-&quot;.t.&quot;]&quot;
     else
       return &quot;[Rails]&quot;
@@ -3605,10 +3723,10 @@ function! RailsStatusline()
   endif
 endfunction
 
-function! RailsSTATUSLINE()
+function! rails#STATUSLINE(...)
   if exists(&quot;b:rails_root&quot;)
     let t = RailsFileType()
-    if t != &quot;&quot;
+    if t != &quot;&quot; &amp;&amp; a:0 &amp;&amp; a:1
       return &quot;,RAILS-&quot;.toupper(t)
     else
       return &quot;,RAILS&quot;
@@ -3774,15 +3892,9 @@ function! s:app_dbext_settings(environment) dict
   if !has_key(cache,a:environment)
     let dict = {}
     if self.has_file(&quot;config/database.yml&quot;)
-      let out = &quot;&quot;
-      if has(&quot;ruby&quot;)
-        ruby require 'yaml'; VIM::command('let out = %s' % File.open(VIM::evaluate(&quot;self.path()&quot;)+&quot;/config/database.yml&quot;) {|f| y = YAML::load(f); e = y[VIM::evaluate(&quot;a:environment&quot;)]; i=0; e=y[e] while e.respond_to?(:to_str) &amp;&amp; (i+=1)&lt;16; e.map {|k,v| &quot;#{k}=#{v}\n&quot; if v}.compact.join }.inspect) rescue nil
-      endif
-      if out == &quot;&quot;
-        let cmdb = 'require %{yaml}; File.open(%q{'.self.path().'/config/database.yml}) {|f| y = YAML::load(f); e = y[%{'
-        let cmde = '}]; i=0; e=y[e] while e.respond_to?(:to_str) &amp;&amp; (i+=1)&lt;16; e.each{|k,v|puts k.to_s+%{=}+v.to_s}}'
-        let out = self.lightweight_ruby_eval(cmdb.a:environment.cmde)
-      endif
+      let cmdb = 'require %{yaml}; File.open(%q{'.self.path().'/config/database.yml}) {|f| y = YAML::load(f); e = y[%{'
+      let cmde = '}]; i=0; e=y[e] while e.respond_to?(:to_str) &amp;&amp; (i+=1)&lt;16; e.each{|k,v|puts k.to_s+%{=}+v.to_s}}'
+      let out = self.lightweight_ruby_eval(cmdb.a:environment.cmde)
       let adapter = s:extractdbvar(out,'adapter')
       let adapter = get({'postgresql': 'pgsql', 'sqlite3': 'sqlite', 'sqlserver': 'sqlsrv', 'sybase': 'asa', 'oci': 'ora'},adapter,adapter)
       let dict['type'] = toupper(adapter)
@@ -3802,6 +3914,7 @@ function! s:app_dbext_settings(environment) dict
         let dict['dbname'] = self.path(dict['dbname'])
       endif
       let dict['profile'] = ''
+      let dict['srvname'] = s:extractdbvar(out,'host')
       let dict['host'] = s:extractdbvar(out,'host')
       let dict['port'] = s:extractdbvar(out,'port')
       let dict['dsnname'] = s:extractdbvar(out,'dsn')
@@ -3837,7 +3950,7 @@ function! s:BufDatabase(...)
     return
   endif
   let dict = self.dbext_settings(env)
-  for key in ['type', 'profile', 'bin', 'user', 'passwd', 'dbname', 'host', 'port', 'dsnname', 'extra', 'integratedlogin']
+  for key in ['type', 'profile', 'bin', 'user', 'passwd', 'dbname', 'srvname', 'host', 'port', 'dsnname', 'extra', 'integratedlogin']
     let b:dbext_{key} = get(dict,key,'')
   endfor
   if b:dbext_type == 'PGSQL'
@@ -3845,21 +3958,6 @@ function! s:BufDatabase(...)
   elseif exists('$PGPASSWORD')
     let $PGPASSWORD = ''
   endif
-  if a:0 &gt;= 3 &amp;&amp; a:3 &amp;&amp; exists(&quot;:Create&quot;)
-    if exists(&quot;b:dbext_dbname&quot;) &amp;&amp; exists(&quot;b:dbext_type&quot;) &amp;&amp; b:dbext_type !~? 'sqlite'
-      let db = b:dbext_dbname
-      if b:dbext_type == 'PGSQL'
-        &quot; I don't always have a default database for a user so using the
-        &quot; default user's database is a better choice for my setup.  It
-        &quot; probably won't work for everyone but nothing will.
-        let b:dbext_dbname = 'postgres'
-      else
-        let b:dbext_dbname = ''
-      endif
-      exe &quot;Create database &quot;.db
-      let b:dbext_dbname = db
-    endif
-  endif
   unlet! s:lock_database
 endfunction
 
@@ -4265,8 +4363,6 @@ endfunction
 call s:add_methods('app',['source_callback'])
 
 function! RailsBufInit(path)
-  let cpo_save = &amp;cpo
-  set cpo&amp;vim
   let firsttime = !(exists(&quot;b:rails_root&quot;) &amp;&amp; b:rails_root == a:path)
   let b:rails_root = a:path
   if !has_key(s:apps,a:path)
@@ -4274,11 +4370,12 @@ function! RailsBufInit(path)
     let s:apps[a:path].root = a:path
   endif
   let app = s:apps[a:path]
+  let buffer = rails#buffer()
   &quot; Apparently RailsFileType() can be slow if the underlying file system is
   &quot; slow (even though it doesn't really do anything IO related).  This caching
   &quot; is a temporary hack; if it doesn't cause problems it should probably be
   &quot; refactored.
-  let b:rails_cached_file_type = app.calculate_file_type(RailsFilePath())
+  let b:rails_cached_file_type = buffer.calculate_file_type()
   if g:rails_history_size &gt; 0
     if !exists(&quot;g:RAILS_HISTORY&quot;)
       let g:RAILS_HISTORY = &quot;&quot;
@@ -4360,41 +4457,40 @@ function! RailsBufInit(path)
   call app.source_callback(&quot;config/rails.vim&quot;)
   call s:BufModelines()
   call s:BufMappings()
-  let &amp;cpo = cpo_save
   return b:rails_root
 endfunction
 
 function! s:SetBasePath()
-  if rails#app().path() =~ '://'
+  let self = rails#buffer()
+  if self.app().path() =~ '://'
     return
   endif
-  let transformed_path = s:pathsplit(s:pathjoin([rails#app().path()]))[0]
-  let old_path = s:pathsplit(s:sub(&amp;l:path,'^\.,=',''))
+  let transformed_path = s:pathsplit(s:pathjoin([self.app().path()]))[0]
+  let old_path = s:pathsplit(s:sub(self.getvar('&amp;path'),'^\.,=',''))
   call filter(old_path,'!s:startswith(v:val,transformed_path)')
 
   let path = ['app', 'app/models', 'app/controllers', 'app/helpers', 'config', 'lib', 'app/views']
-  if s:controller() != ''
-    let path += ['app/views/'.s:controller(), 'public']
+  if self.controller_name() != ''
+    let path += ['app/views/'.self.controller_name(), 'public']
   endif
-  if rails#app().has('test')
+  if self.app().has('test')
     let path += ['test', 'test/unit', 'test/functional', 'test/integration']
   endif
-  if rails#app().has('spec')
-    let path += ['spec', 'spec/models', 'spec/controllers', 'spec/helpers', 'spec/views', 'spec/lib']
+  if self.app().has('spec')
+    let path += ['spec', 'spec/models', 'spec/controllers', 'spec/helpers', 'spec/views', 'spec/lib', 'spec/integration']
   endif
   let path += ['app/*', 'vendor', 'vendor/plugins/*/lib', 'vendor/plugins/*/test', 'vendor/rails/*/lib', 'vendor/rails/*/test']
-  call map(path,'rails#app().path(v:val)')
-  let &amp;l:path = s:pathjoin('.',rails#app().path(),path,old_path)
+  call map(path,'self.app().path(v:val)')
+  call self.setvar('&amp;path',s:pathjoin('.',[self.app().path()],path,old_path))
 endfunction
 
 function! s:BufSettings()
   if !exists('b:rails_root')
     return ''
   endif
+  let self = rails#buffer()
   call s:SetBasePath()
-  let rp = s:gsub(rails#app().path(),'[ ,]','\\&amp;')
-  let &amp;l:errorformat = s:efm
-  setlocal makeprg=rake
+  let rp = s:gsub(self.app().path(),'[ ,]','\\&amp;')
   if stridx(&amp;tags,rp) == -1
     let &amp;l:tags = rp . &quot;/tmp/tags,&quot; . &amp;tags . &quot;,&quot; . rp . &quot;/tags&quot;
   endif
@@ -4411,42 +4507,39 @@ function! s:BufSettings()
           \.&quot;Static Files (*.html, *.css, *.js)\t&quot;.statics.&quot;\n&quot;
           \.&quot;All Files (*.*)\t*.*\n&quot;
   endif
-  setlocal includeexpr=RailsIncludeexpr()
-  let &amp;l:suffixesadd=&quot;.rb,.&quot;.s:gsub(s:view_types,',',',.').&quot;,.css,.js,.yml,.csv,.rake,.sql,.html,.xml&quot;
-  if &amp;ft =~ '^\%(e\=ruby\|[yh]aml\|javascript\|css\|sass\)$'
-    setlocal sw=2 sts=2 et
-    if exists('+completefunc')
-      if &amp;completefunc == ''
-        set completefunc=syntaxcomplete#Complete
-      endif
+  call self.setvar('&amp;includeexpr','RailsIncludeexpr()')
+  call self.setvar('&amp;suffixesadd', &quot;.rb,.&quot;.s:gsub(s:view_types,',',',.').&quot;,.css,.js,.yml,.csv,.rake,.sql,.html,.xml&quot;)
+  let ft = self.getvar('&amp;filetype')
+  if ft =~ '^\%(e\=ruby\|[yh]aml\|javascript\|css\|sass\)$'
+    call self.setvar('&amp;shiftwidth',2)
+    call self.setvar('&amp;softtabstop',2)
+    call self.setvar('&amp;expandtab',1)
+    if exists('+completefunc') &amp;&amp; self.getvar('&amp;completefunc') == ''
+      call self.setvar('&amp;completefunc','syntaxcomplete#Complete')
     endif
   endif
-  if &amp;filetype == &quot;ruby&quot;
-    let &amp;l:suffixesadd=&quot;.rb,.&quot;.s:gsub(s:view_types,',',',.').&quot;,.yml,.csv,.rake,s.rb&quot;
-    if expand('%:e') == 'rake'
-      setlocal define=^\\s*def\\s\\+\\(self\\.\\)\\=\\\|^\\s*\\%(task\\\|file\\)\\s\\+[:'\&quot;]
-    else
-      setlocal define=^\\s*def\\s\\+\\(self\\.\\)\\=
-    endif
+  if ft == 'ruby'
+    call self.setvar('&amp;suffixesadd',&quot;.rb,.&quot;.s:gsub(s:view_types,',',',.').&quot;,.yml,.csv,.rake,s.rb&quot;)
+    call self.setvar('&amp;define',self.define_pattern())
     &quot; This really belongs in after/ftplugin/ruby.vim but we'll be nice
-    if exists(&quot;g:loaded_surround&quot;) &amp;&amp; !exists(&quot;b:surround_101&quot;)
-      let b:surround_5   = &quot;\r\nend&quot;
-      let b:surround_69  = &quot;\1expr: \1\rend&quot;
-      let b:surround_101 = &quot;\r\nend&quot;
+    if exists('g:loaded_surround') &amp;&amp; self.getvar('surround_101') == ''
+      call self.setvar('surround_5',   &quot;\r\nend&quot;)
+      call self.setvar('surround_69',  &quot;\1expr: \1\rend&quot;)
+      call self.setvar('surround_101', &quot;\r\nend&quot;)
     endif
-  elseif &amp;filetype == 'yaml' || expand('%:e') == 'yml'
-    setlocal define=^\\%(\\h\\k*:\\)\\@=
-    let &amp;l:suffixesadd=&quot;.yml,.csv,.rb,.&quot;.s:gsub(s:view_types,',',',.').&quot;,.rake,s.rb&quot;
-  elseif &amp;filetype == &quot;eruby&quot;
-    let &amp;l:suffixesadd=&quot;.&quot;.s:gsub(s:view_types,',',',.').&quot;,.rb,.css,.js,.html,.yml,.csv&quot;
+  elseif ft == 'yaml' || fnamemodify(self.name(),':e') == 'yml'
+    call self.setvar('&amp;define',self.define_pattern())
+    call self.setvar('&amp;suffixesadd',&quot;.yml,.csv,.rb,.&quot;.s:gsub(s:view_types,',',',.').&quot;,.rake,s.rb&quot;)
+  elseif ft == 'eruby'
+    call self.setvar('&amp;suffixesadd',&quot;.&quot;.s:gsub(s:view_types,',',',.').&quot;,.rb,.css,.js,.html,.yml,.csv&quot;)
     if exists(&quot;g:loaded_allml&quot;)
       &quot; allml is available on vim.org.
-      let b:allml_stylesheet_link_tag = &quot;&lt;%= stylesheet_link_tag '\r' %&gt;&quot;
-      let b:allml_javascript_include_tag = &quot;&lt;%= javascript_include_tag '\r' %&gt;&quot;
-      let b:allml_doctype_index = 10
+      call self.setvar('allml_stylesheet_link_tag', &quot;&lt;%= stylesheet_link_tag '\r' %&gt;&quot;)
+      call self.setvar('allml_javascript_include_tag', &quot;&lt;%= javascript_include_tag '\r' %&gt;&quot;)
+      call self.setvar('allml_doctype_index', 10)
     endif
   endif
-  if &amp;filetype == &quot;eruby&quot; || &amp;filetype == &quot;yaml&quot;
+  if ft == 'eruby' || ft == 'yaml'
     &quot; surround.vim
     if exists(&quot;g:loaded_surround&quot;)
       &quot; The idea behind the || part here is that one can normally define the
@@ -4455,19 +4548,19 @@ function! s:BufSettings()
       &quot; difficult if you really don't want a hyphen in Rails ERuby files.  If
       &quot; this is your desire, you will need to accomplish it via a rails.vim
       &quot; autocommand.
-      if !exists(&quot;b:surround_45&quot;) || b:surround_45 == &quot;&lt;% \r %&gt;&quot; &quot; -
-        let b:surround_45 = &quot;&lt;% \r -%&gt;&quot;
+      if self.getvar('surround_45') == '' || self.getvar('surround_45') == &quot;&lt;% \r %&gt;&quot; &quot; -
+        call self.setvar('surround_45', &quot;&lt;% \r -%&gt;&quot;)
       endif
-      if !exists(&quot;b:surround_61&quot;) &quot; =
-        let b:surround_61 = &quot;&lt;%= \r %&gt;&quot;
+      if self.getvar('surround_61') == '' &quot; =
+        call self.setvar('surround_61', &quot;&lt;%= \r %&gt;&quot;)
       endif
-      if !exists(&quot;b:surround_35&quot;) &quot; #
-        let b:surround_35 = &quot;&lt;%# \r %&gt;&quot;
+      if self.getvar(&quot;surround_35&quot;) == '' &quot; #
+        call self.setvar('surround_35', &quot;&lt;%# \r %&gt;&quot;)
       endif
-      if !exists(&quot;b:surround_101&quot;) || b:surround_101 == &quot;&lt;% \r %&gt;\n&lt;% end %&gt;&quot; &quot;e
-        let b:surround_5   = &quot;&lt;% \r -%&gt;\n&lt;% end -%&gt;&quot;
-        let b:surround_69  = &quot;&lt;% \1expr: \1 -%&gt;\r&lt;% end -%&gt;&quot;
-        let b:surround_101 = &quot;&lt;% \r -%&gt;\n&lt;% end -%&gt;&quot;
+      if self.getvar('surround_101') == '' || self.getvar('surround_101')== &quot;&lt;% \r %&gt;\n&lt;% end %&gt;&quot; &quot;e
+        call self.setvar('surround_5',   &quot;&lt;% \r -%&gt;\n&lt;% end -%&gt;&quot;)
+        call self.setvar('surround_69',  &quot;&lt;% \1expr: \1 -%&gt;\r&lt;% end -%&gt;&quot;)
+        call self.setvar('surround_101', &quot;&lt;% \r -%&gt;\n&lt;% end -%&gt;&quot;)
       endif
     endif
   endif
@@ -4485,6 +4578,7 @@ augroup railsPluginAuto
   autocmd BufWritePost */config/database.yml      call rails#cache_clear(&quot;dbext_settings&quot;)
   autocmd BufWritePost */test/test_helper.rb      call rails#cache_clear(&quot;user_assertions&quot;)
   autocmd BufWritePost */config/routes.rb         call rails#cache_clear(&quot;named_routes&quot;)
+  autocmd BufWritePost */config/environment.rb    call rails#cache_clear(&quot;default_locale&quot;)
   autocmd BufWritePost */config/environments/*.rb call rails#cache_clear(&quot;environments&quot;)
   autocmd BufWritePost */tasks/**.rake            call rails#cache_clear(&quot;rake_tasks&quot;)
   autocmd BufWritePost */generators/**            call rails#cache_clear(&quot;generators&quot;)</diff>
      <filename>dot.vim/autoload/rails.vim</filename>
    </modified>
    <modified>
      <diff>@@ -14,6 +14,7 @@ Author: Tim Pope &lt;vimNOSPAM@tpope.info&gt;		|rails-plugin-author|
 |rails-controller-navigation|	    Controller Navigation Commands
 |rails-misc-navigation|		    Miscellaneous Navigation Commands
 |rails-custom-navigation|	    Custom Navigation Commands
+|rails-rake|			Rake
 |rails-scripts|			Script Wrappers
 |rails-refactoring|		Refactoring Helpers
 |rails-partials|		    Partial Extraction
@@ -50,23 +51,23 @@ Rails application development.
    out of your way if you're not using its features.  (If you find a situation
    where this is not a case, contact the |rails-plugin-author|.)
 
-3. Provides reasonable settings for working with Rails applications.  Rake is
-   the 'makeprg' (and it always knows where your Rakefile is), 'shiftwidth'
-   is 2, and 'path' includes an appropriate collection of directories from
-   your application. |rails-options|
-
-4. Easy navigation of the Rails directory structure.  |gf| considers context
+3. Easy navigation of the Rails directory structure.  |gf| considers context
    and knows about partials, fixtures, and much more.  There are two commands,
    :A (alternate) and :R (related) for easy jumping between files, including
    favorites like model to migration, template to helper, and controller to
    functional test.  For more advanced usage, :Rmodel, :Rview, :Rcontroller,
    and several other commands are provided.  |rails-navigation|
 
-5. Enhanced syntax highlighting.  From has_and_belongs_to_many to
+4. Enhanced syntax highlighting.  From has_and_belongs_to_many to
    distance_of_time_in_words, it's here.  For easy completion of these long
    method names, 'completefunc' is set to enable syntax based completion on
    |i_CTRL-X_CTRL-U|. |rails-syntax|
 
+5. Interface to rake.  Use :Rake to run the current test, spec, or feature.
+   Use :.Rake to do a focused run of just the method, example, or scenario on
+   the current line.  :Rake can also run arbitrary migrations, load individual
+   fixtures, and more. |rails-rake|
+
 6. Interface to script/*.  Generally, use &quot;:Rscript about&quot; to call
    &quot;script/about&quot;.  Most commands have wrappers with additional features:
    &quot;:Rgenerate controller Blog&quot; generates a blog controller and edits
@@ -79,8 +80,8 @@ Rails application development.
    |:Rinvert| takes a self.up migration and writes a self.down.
    |rails-refactoring|
 
-8. Integration with other plugins.  |:Rproject| creates a new project.vim
-   project or spawns NERDTree.  If dbext.vim is installed, it will be
+8. Integration with other plugins.  |:Rtree| spawns NERDTree.vim or creates a
+   new project.vim project.  If dbext.vim is installed, it will be
    transparently configured to reflect database.yml.  Cream users get some
    additional mappings, and all GUI users get a menu. |rails-integration|
 
@@ -134,24 +135,9 @@ actually edit a file from a Rails application.
 :Rails {directory}	The only global command.  Creates a new Rails
 			application in {directory}, and loads the README.
 
-						*rails-:Rake*
-:[range]Rake {targets}	Like calling |:make| {targets} (with 'makeprg' being
-			rake).  However, in some contexts, if {targets} are
-			omitted, :Rake defaults to something sensible (like
-			db:migrate in a migration, or your current test).
-			In tests (and specs), giving a line argument runs only
-			the test method (or example) at that line.  Use :.Rake
-			to run the test method at the cursor position.  Use
-			:.Rake inside a self.up or self.down method in a
-			migration to run the db:migrate:up or db:migrate:down
-			task for that particular migration.
-
-						*rails-:Rake!*
-:[range]Rake! {targets}	Called with a bang, :Rake will use an alternate
-			'errorformat' which attempts to parse the full stack
-			backtrace.  For purely informative rake tasks (stats,
-			routes, notes, etc), the preview pane is opened with
-			the full output of the command.
+:Rails!			Show the version of rails.vim installed.  If rails.vim
+			is active for the current buffer, also show the type
+			of Rails file detected.
 
 						*rails-:Rcd*
 :Rcd [{directory}]	|:cd| to /path/to/railsapp/{directory}.
@@ -189,15 +175,19 @@ actually edit a file from a Rails application.
 
 						*rails-:Rpreview*
 :Rpreview [{path}]	Creates a URL from http://localhost:3000/ and the
-			{path} given.  If {path} is omitted, a sensible
-			default is used (considers the current
-			controller/template, but does not take routing into
-			account).  The not too useful default is to then edit
-			this URL using Vim itself, allowing |netrw| to
+			{path} given.  The not too useful default is to then
+			edit this URL using Vim itself, allowing |netrw| to
 			download it.  More useful is to define a :OpenURL
 			command, which will be used instead (see
-			|rails-:OpenURL|).
-			
+			|rails-:OpenURL|).  If {path} is omitted, a sensible
+			default is used (considers the current
+			controller/template, but does not take routing into
+			account).  The default is overridden by comments like
+			the following that are either before the current
+			method call or at the top of the file: &gt;
+		# GET /users
+		# PUT /users/1
+&lt;
 						*rails-:Rpreview!*
 :Rpreview! [{path}]	As with :Rpreview, except :OpenURL is never used.
 
@@ -300,19 +290,21 @@ Alternate and Related Files ~
 Two commands, :A and :R, are used quickly jump to an &quot;alternate&quot; and a
 &quot;related&quot; file, defined below.
 
-		*rails-:A* *rails-:AE* *rails-:AS* *rails-:AV* *rails-:AT*
+	*rails-:A* *rails-:AE* *rails-:AS* *rails-:AV* *rails-:AT* *rails-:AD*
 :A			These commands were picked to mimic Michael Sharpe's
 :AE			a.vim.  Briefly, they edit the &quot;alternate&quot; file, in
 :AS			either the same window (:A and :AE), a new split
-:AV			window (:AS), a new vertically split window (:AV), or
-:AT			a new tab (:AT).  A mapping for :A is [f .
+:AV			window (:AS), a new vertically split window (:AV), a
+:AT			new tab (:AT), or read it into the current buffer
+:AD                     (:AD).  A mapping for :A is [f .
 
-		*rails-:R* *rails-:RE* *rails-:RS* *rails-:RV* *rails-:RT*
+	*rails-:R* *rails-:RE* *rails-:RS* *rails-:RV* *rails-:RT* *rails-:RD*
 :R			These are similar |rails-:A| and friends above, only
 :RE			they jump to the &quot;related&quot; file rather than the
 :RS			&quot;alternate.&quot;  A mapping for :R is ]f .
 :RV			
 :RT
+:RD
 
 					*rails-alternate* *rails-related*
 The alternate file is most frequently the test file, though there are
@@ -321,12 +313,12 @@ location in the file.  For example, when editing a controller, the related
 file is template for the method currently being edited.
 
 The easiest way to learn these commands is to experiment.  A few examples of
-alternate and related files follow:
+alternate and related files for a Test::Unit application follow:
 
 Current file		Alternate file		Related file ~
-model			unit test		related migration
+model			unit test		schema definition
 controller (in method)	functional test		template (view)
-template (view)		helper			controller (jump to method)
+template (view)		functional test  	controller (jump to method)
 migration		previous migration	next migration
 config/routes.rb	config/database.yml	config/environment.rb
 
@@ -343,12 +335,12 @@ can override the mapping from model related files to controller related files
 (Rset controller=hiring) and vice versa (Rset model=employee).  See
 |rails-:Rset|.
 
-Each of the following commands has variants for splitting, vertical splitting
-and opening in a new tab.  For :Rmodel, those variants would be :RSmodel,
-:RVmodel, and :RTmodel.  There is also :REmodel which is a synonym for :Rmodel
-(future versions might allow customization of the behavior of :Rmodel).  They
-also allow for jumping to methods or line numbers using the same syntax as
-|:Redit|.
+Each of the following commands has variants for splitting, vertical splitting,
+opening in a new tab, and reading the file into the current buffer.  For
+:Rmodel, those variants would be :RSmodel, :RVmodel, :RTmodel, and :RDmodel.
+There is also :REmodel which is a synonym for :Rmodel (future versions might
+allow customization of the behavior of :Rmodel).  They also allow for jumping
+to methods or line numbers using the same syntax as |:Redit|.
 
 
 Model Navigation Commands ~
@@ -432,16 +424,15 @@ like: &gt;
 			that cannot be found.  A new layout will be created if
 			an extension is given.
 
-						*rails-:Rapi*
-:Rapi [{name}]		Edit the API for the specified controller.  This
-			command is deprecated; add it yourself with
-			|:Rnavcommand| if you still desire it.
-
 						*rails-:Rfunctionaltest*
 :Rfunctionaltest [{name}]
 			Edit the functional test or controller spec for the
 			specified controller.
 
+						*rails-:Rapi*
+:Rapi [{name}]		This command is obsolete; add it yourself with
+			|:Rnavcommand| if you still desire it.
+
 Miscellaneous Navigation Commands  ~
 						*rails-misc-navigation*
 
@@ -455,6 +446,7 @@ The following commands are not clearly associated with models or controllers.
 :Rmetal						|rails-:Rmetal|
 :Renvironment					|rails-:Renvironment|
 :Rinitializer					|rails-:Rinitializer|
+:Rlocale					|rails-:Rlocale|
 :Rintegrationtest				|rails-:Rintegrationtest|
 :Rspec						|rails-:Rspec|
 
@@ -497,11 +489,17 @@ The following commands are not clearly associated with models or controllers.
 :Rinitializer [{name}]  Edit the config/initializers file specified.  With no
 			argument, defaults to editing config/routes.rb.
 
+						*rails-:Rlocale*
+:Rlocale [{name}]	Edit the config/locale file specified, optionally
+			adding a yml or rb extension if none is given.  With
+			no argument, checks config/environment.rb for the
+			default locale.
+
 						*rails-:Rintegrationtest*
 :Rintegrationtest [{name}]
-			Edit the integration test or cucumber feature
-			specified.  With no argument, defaults to editing
-			test/test_helper.rb.
+			Edit the integration test, integration spec, or
+			cucumber feature specified.  With no argument,
+			defaults to editing test/test_helper.rb.
 
 						*rails-:Rspec*
 :Rspec [{name}]		Edit the given spec.  With no argument, defaults to
@@ -533,7 +531,7 @@ in an initialization routine of some sort (e.g., an autocommand); see
 			is used as a default.
 
 						*rails-:Rcommand*
-:Rcommand		Deprecated alias for |:Rnavcommand|
+:Rcommand		Obsolete alias for |:Rnavcommand|.
 
 Examples: &gt;
 	Rnavcommand api      app/apis -glob=**/* -suffix=_api.rb
@@ -547,6 +545,64 @@ above is |CTRL-^|.  This keystroke edits the previous file, and is helpful to
 back out of any of the above commands.
 
 ==============================================================================
+RAKE						*rails-rake*
+
+Rake integration happens through the :Rake command.
+
+						*rails-:Rake*
+:[range]Rake {targets}	Calls |:make!| {targets} (with 'makeprg' being rake)
+			and opens the quickfix window if there were any
+			errors.  If {targets} are omitted, :Rake defaults to
+			something sensible as described below.  Giving a line
+			number argument may affect that default.
+
+						*rails-:Rake!*
+:[range]Rake! {targets}	Called with a bang, :Rake will forgo opening the
+			quickfix window.
+
+						*rails-rake-defaults*
+
+Generally, the default task is one that runs the test you'd expect.  For
+example, if you're in a view in an RSpec application, the view spec is run,
+but if it's a Test::Unit application, the functional test for the
+corresponding controller is run.  The following table lists the most
+interesting mappings:
+
+File			Task ~
+unit test		test:units TEST=...
+functional test		test:functionals TEST=...
+integration test	test:integration TEST=...
+spec			spec SPEC=...
+feature			cucumber FEATURE=...
+model			test:units TEST=...		spec SPEC=...
+controller		test:functionals TEST=...	spec SPEC=...
+helper			test:functionals TEST=...	spec SPEC=...
+view			test:functionals TEST=...	spec SPEC=...
+fixtures		db:fixtures:load FIXTURES=...
+migration		db:migrate VERSION=...
+config/routes.rb	routes
+db/seeds.rb		db:seed
+
+Additionally, when :Rake is given a line number (e.g., :.Rake), the following
+additional tasks can be invoked:
+
+File			Task ~
+unit test		test:units TEST=... TESTOPTS=-n...
+functional test		test:functionals TEST=... TESTOPTS=-n...
+integration test	test:integration TEST=... TESTOPTS=-n...
+spec			spec SPEC=... SPEC_OPTS=--line=...
+feature			cucumber FEATURE=...:...
+controller		routes CONTROLLER=...
+fixtures		db:fixtures:identify LABEL=...
+migration in self.up	db:migrate:up VERSION=...
+migration in self.down	db:migrate:down VERSION=...
+migration elsewhere	db:migrate:redo VERSION=...
+task			... (try to guess currently edited declaration)
+
+Finally, you can override the default task with a comment like &quot;# rake ...&quot;
+before the method pointed to by [range] or at the top of the file.
+
+==============================================================================
 SCRIPT WRAPPERS					*rails-scripts*
 
 The following commands are wrappers around the scripts in the script directory
@@ -559,14 +615,7 @@ A limited amount of completion with &lt;Tab&gt; is supported.
 			calling script/console.
 
 						*rails-:Rconsole*
-:Rconsole {options}	Start script/console.  This command has been
-			deprecated for the pragmatic reason of making
-			|:Rcontroller| easier to tab complete.  To compensate
-			for the eventual disappearance of this command,
-			|:Rscript| now defaults to calling script/console if
-			no other arguments are given.  (If in spite of this
-			you still feel you would miss this command, speak up
-			now!)
+:Rconsole {options}	Obsolete. Call |:Rscript| instead.
 
 						*rails-:Rrunner*
 :[range]Rrunner {code}	Executes {code} with script/runner.  Differs from
@@ -619,7 +668,7 @@ The :Rextract command can be used to extract a partial to a new file.
 
 						*rails-:Rpartial*
 :[range]Rpartial [{controller}/]{name}	
-			Deprecated alias for :Rextract.
+			Obsolete alias for :Rextract.
 
 If this is your file, in app/views/blog/show.html.erb: &gt;
 
@@ -680,13 +729,14 @@ A handful of Vim plugins are enhanced by rails.vim.  All plugins mentioned can
 be found at http://www.vim.org/.  Cream and GUI menus (for lack of a better
 place) are also covered in this section.
 
-					*rails-:Rproject* *rails-project*
-:Rproject [{file}]	This command is only provided when the |project|
-			plugin is installed.  Invoke :Project (typically
-			without an argument), and search for the root of the
-			current Rails application.  If it is not found, create
-			a new project, with appropriate directories (app,
-			etc., but not vendor).
+					*rails-:Rtree* *rails-:Rproject*
+:Rtree [{arg}]		If |NERDTree| is installed, open a tree for the
+			application root or the given subdirectory.
+			Otherwise, if when the |project| plugin is installed,
+			invoke :Project (typically without an argument), and
+			search for the root of the current Rails application.
+			If it is not found, create a new project, with
+			appropriate directories (app, etc., but not vendor).
 
 						*rails-:Rdbext* *rails-dbext*
 :Rdbext [{environment}] This command is only provided when the |dbext| plugin
@@ -700,13 +750,6 @@ place) are also covered in this section.
 			rails.vim loads if |g:rails_dbext| is set (which it is
 			by default).
 
-						*rails-:Rdbext!*
-:Rdbext! [{environment}]
-			Load the database configuration as above, and then
-			attempt a CREATE DATABASE for it.  This is primarily
-			useful for demonstrations, and has been largely
-			superseded by |:Rake| db:create.
-
 						*rails-surround*
 The |surround| plugin available from vim.org enables adding and removing
 &quot;surroundings&quot; like parentheses, quotes, and HTML tags.  Even by itself, it is
@@ -914,11 +957,6 @@ The 'includeexpr' option is set to enable the magic described in |rails-gf|.
 Useful information is added to the 'statusline', when |g:rails_statusline| is
 enabled.
 
-					*rails-'makeprg'*	*rails-'mp'*
-					*rails-'errorformat'*	*rails-'efm'*
-Rake is used as the 'makeprg', so |:make| will work as expected.  Also, 
-'errorformat' is set appropriately to handle your tests.
-
 					*rails-'filetype'*	*rails-'ft'*
 The 'filetype' is sometimes adjusted for Rails files.  Most notably, *.rxml
 and *.rjs are treated as Ruby files, and files that have been falsely
@@ -941,15 +979,16 @@ loaded, you can use an autocommand like the following in your vimrc: &gt;
 	autocmd User Rails		silent! Rlcd
 	autocmd User Rails		map &lt;buffer&gt; &lt;F9&gt; :Rake&lt;CR&gt;
 You can also have autocommands that only apply to certain types of files.
-These are based off the information shown in the 'statusline' (see
-|rails-'statusline'|), with hyphens changed to periods. A few examples: &gt;
+These are based off the information shown when running the |:Rails!|
+command, with hyphens changed to periods. A few examples: &gt;
 	autocmd User Rails.controller*	iabbr &lt;buffer&gt; wsn wsdl_service_name
 	autocmd User Rails.model.arb*	iabbr &lt;buffer&gt; vfo validates_format_of
 	autocmd User Rails.view.erb*    imap  &lt;buffer&gt; &lt;C-Z&gt; &lt;%=  %&gt;&lt;C-O&gt;3h
 End all such Rails autocommands with asterisks, even if you have an exact
-specification.  There is also a filename matching syntax: &gt;
-	autocmd User Rails/db/schema.rb  Rset task=db:schema:dump
-	autocmd User Rails/**/foo_bar.rb Rabbrev FB:: FooBar
+specification, to allow for more specific subtypes to be added in the future.
+There is also a filename matching syntax: &gt;
+	autocmd User Rails/config/environment.rb Rabbrev c config
+	autocmd User Rails/**/foo_bar.rb         Rabbrev FB:: FooBar
 Use the filetype based syntax whenever possible, reserving the filename based
 syntax for more advanced cases.
 
@@ -989,8 +1028,6 @@ Option		 Meaning ~
 b:alternate	 Custom alternate file for :A, relative to the Rails root
 b:controller	 Default controller for certain commands (e.g., :Rhelper)
 b:model		 Default model for certain commands (e.g., :Rfixtures)
-l:preview	 URL stub for :Rpreview (e.g., blog/show/1)
-b:task		 Default task used with :Rake
 l:related	 Custom related file for :R, relative to the Rails root
 a:root_url	 Root URL for commands like :Rpreview
 
@@ -1107,8 +1144,10 @@ b:rails_url.
 						*g:rails_statusline*  &gt;
 	let g:rails_statusline=1
 Give a clue in the statusline when this plugin is enabled.  Enabled by
-default.  (Does anybody care about this?  Years after writing it the author is
-beginning to think it is mostly a waste of space.)
+default.  This used to be a far more verbose indicator which included the
+type of Rails file.  If you actually liked this, you can add either
+%{rails#statusline(1)} or %{rails#STATUSLINE(1)} to 'statusline' explicitly
+(and let the author know, because this fallback is likely getting the boot).
 
 						*g:rails_syntax*  &gt;
 	let g:rails_syntax=1</diff>
      <filename>dot.vim/doc/rails.txt</filename>
    </modified>
    <modified>
      <diff>@@ -83,16 +83,12 @@ multiple-items-example	yankring.txt	/*multiple-items-example*
 rails	rails.txt	/*rails*
 rails-'cfu'	rails.txt	/*rails-'cfu'*
 rails-'completefunc'	rails.txt	/*rails-'completefunc'*
-rails-'efm'	rails.txt	/*rails-'efm'*
-rails-'errorformat'	rails.txt	/*rails-'errorformat'*
 rails-'et'	rails.txt	/*rails-'et'*
 rails-'expandtab'	rails.txt	/*rails-'expandtab'*
 rails-'filetype'	rails.txt	/*rails-'filetype'*
 rails-'ft'	rails.txt	/*rails-'ft'*
 rails-'includeexpr'	rails.txt	/*rails-'includeexpr'*
 rails-'inex'	rails.txt	/*rails-'inex'*
-rails-'makeprg'	rails.txt	/*rails-'makeprg'*
-rails-'mp'	rails.txt	/*rails-'mp'*
 rails-'pa'	rails.txt	/*rails-'pa'*
 rails-'path'	rails.txt	/*rails-'path'*
 rails-'shiftwidth'	rails.txt	/*rails-'shiftwidth'*
@@ -104,12 +100,14 @@ rails-'sua'	rails.txt	/*rails-'sua'*
 rails-'suffixesadd'	rails.txt	/*rails-'suffixesadd'*
 rails-'sw'	rails.txt	/*rails-'sw'*
 rails-:A	rails.txt	/*rails-:A*
+rails-:AD	rails.txt	/*rails-:AD*
 rails-:AE	rails.txt	/*rails-:AE*
 rails-:AS	rails.txt	/*rails-:AS*
 rails-:AT	rails.txt	/*rails-:AT*
 rails-:AV	rails.txt	/*rails-:AV*
 rails-:OpenURL	rails.txt	/*rails-:OpenURL*
 rails-:R	rails.txt	/*rails-:R*
+rails-:RD	rails.txt	/*rails-:RD*
 rails-:RE	rails.txt	/*rails-:RE*
 rails-:RS	rails.txt	/*rails-:RS*
 rails-:RT	rails.txt	/*rails-:RT*
@@ -125,7 +123,6 @@ rails-:Rcommand	rails.txt	/*rails-:Rcommand*
 rails-:Rconsole	rails.txt	/*rails-:Rconsole*
 rails-:Rcontroller	rails.txt	/*rails-:Rcontroller*
 rails-:Rdbext	rails.txt	/*rails-:Rdbext*
-rails-:Rdbext!	rails.txt	/*rails-:Rdbext!*
 rails-:Rdestroy	rails.txt	/*rails-:Rdestroy*
 rails-:Rdoc	rails.txt	/*rails-:Rdoc*
 rails-:Rdoc!	rails.txt	/*rails-:Rdoc!*
@@ -144,6 +141,7 @@ rails-:Rjavascript	rails.txt	/*rails-:Rjavascript*
 rails-:Rlayout	rails.txt	/*rails-:Rlayout*
 rails-:Rlcd	rails.txt	/*rails-:Rlcd*
 rails-:Rlib	rails.txt	/*rails-:Rlib*
+rails-:Rlocale	rails.txt	/*rails-:Rlocale*
 rails-:Rlog	rails.txt	/*rails-:Rlog*
 rails-:Rmetal	rails.txt	/*rails-:Rmetal*
 rails-:Rmigration	rails.txt	/*rails-:Rmigration*
@@ -168,6 +166,7 @@ rails-:Rspec	rails.txt	/*rails-:Rspec*
 rails-:Rstylesheet	rails.txt	/*rails-:Rstylesheet*
 rails-:Rtags	rails.txt	/*rails-:Rtags*
 rails-:Rtask	rails.txt	/*rails-:Rtask*
+rails-:Rtree	rails.txt	/*rails-:Rtree*
 rails-:Runittest	rails.txt	/*rails-:Runittest*
 rails-:Rview	rails.txt	/*rails-:Rview*
 rails-:Ry	rails.txt	/*rails-:Ry*
@@ -202,8 +201,9 @@ rails-navigation	rails.txt	/*rails-navigation*
 rails-options	rails.txt	/*rails-options*
 rails-partials	rails.txt	/*rails-partials*
 rails-plugin-author	rails.txt	/*rails-plugin-author*
-rails-project	rails.txt	/*rails-project*
 rails-rails-integration	rails.txt	/*rails-rails-integration*
+rails-rake	rails.txt	/*rails-rake*
+rails-rake-defaults	rails.txt	/*rails-rake-defaults*
 rails-refactoring	rails.txt	/*rails-refactoring*
 rails-related	rails.txt	/*rails-related*
 rails-rspec	rails.txt	/*rails-rspec*</diff>
      <filename>dot.vim/doc/tags</filename>
    </modified>
    <modified>
      <diff>@@ -1,8 +1,8 @@
 &quot;=============================================================================
 &quot; File: gist.vim
 &quot; Author: Yasuhiro Matsumoto &lt;mattn.jp@gmail.com&gt;
-&quot; Last Change: 03-Jul-2009.
-&quot; Version: 2.7
+&quot; Last Change: 31-Oct-2009.
+&quot; Version: 3.1
 &quot; WebPage: http://github.com/mattn/gist-vim/tree/master
 &quot; Usage:
 &quot;
@@ -18,10 +18,17 @@
 &quot;   :Gist -a
 &quot;     post whole text to gist with anonymous.
 &quot;
+&quot;   :Gist -m
+&quot;     post multi buffer to gist.
+&quot;
 &quot;   :Gist -e
 &quot;     edit the gist. (shoud be work on gist buffer)
 &quot;     you can update the gist with :w command on gist buffer.
 &quot;
+&quot;   :Gist -d
+&quot;     delete the gist. (should be work on gist buffer)
+&quot;     password authentication is needed.
+&quot;
 &quot;   :Gist -e foo.js
 &quot;     edit the gist with name 'foo.js'. (shoud be work on gist buffer)
 &quot;
@@ -159,10 +166,10 @@ function! s:GistList(user, token, gistls)
       exe &quot;normal \&lt;c-w&gt;&quot;.winnum.&quot;w&quot;
     endif
     setlocal modifiable
-    silent %d _
   else
     exec 'silent split gist:'.a:gistls
   endif
+  silent %d _
   exec 'silent 0r! curl -s '.url
   silent! %s/&gt;/&gt;\r/g
   silent! %s/&lt;/\r&lt;/g
@@ -228,7 +235,6 @@ function! s:GistGet(user, token, gistid, clipboard)
       exe &quot;normal \&lt;c-w&gt;&quot;.winnum.&quot;w&quot;
     endif
     setlocal modifiable
-    silent %d _
   else
     exec 'silent split gist:'.a:gistid
   endif
@@ -301,13 +307,67 @@ function! s:GistUpdate(user, token, content, gistid, gistnm)
   let res = substitute(res, '^.*: ', '', '')
   if len(res) &gt; 0 &amp;&amp; res != 'http://gist.github.com/gists' 
     setlocal nomodified
-    echo 'done: '.res
+    echo 'Done: '.res
   else
     echoerr 'Edit failed'
   endif
   return res
 endfunction
 
+function! s:GistGetSessionID(user, password)
+  let query = [
+    \ 'login=%s',
+    \ 'password=%s',
+    \ ]
+  let squery = printf(join(query, '&amp;'),
+    \ s:encodeURIComponent(a:user),
+    \ s:encodeURIComponent(a:password))
+  unlet query
+
+  let file = tempname()
+  exec 'redir! &gt; '.file 
+  silent echo squery
+  redir END
+  let quote = &amp;shellxquote == '&quot;' ?  &quot;'&quot; : '&quot;'
+  let url = 'https://gist.github.com/session'
+  let res = system('curl -i -d @'.quote.file.quote.' '.url)
+  call delete(file)
+  let loc = matchstr(split(res, '\(\r\?\n\|\r\n\?\)'), '^Location: ')
+  let loc = substitute(res, '^.*: ', '', '')
+  if len(loc)
+    let res = matchstr(split(res, '\(\r\?\n\|\r\n\?\)'), '^Set-Cookie: ')
+    let res = substitute(res, '^.*: \([^;]\+\).*$', '\1', '')
+  else
+    let res = ''
+  endif
+  return res
+endfunction
+
+function! s:GistDelete(user, token, gistid)
+  let password = inputsecret('Password:') 
+  if len(password) == 0
+    echo 'Canceled'
+    return
+  endif
+  echon &quot;Login to gist... &quot;
+  let cookie = s:GistGetSessionID(a:user, password)
+  if len(cookie) == 0
+    echo 'Failed'
+    return
+  endif
+  echon &quot; Deleting gist... &quot;
+  let quote = &amp;shellxquote == '&quot;' ?  &quot;'&quot; : '&quot;'
+  let url = 'http://gist.github.com/delete/'.a:gistid
+  let res = system('curl -i -b '.quote.cookie.quote.' '.url)
+  let res = matchstr(split(res, '\(\r\?\n\|\r\n\?\)'), '^Location: ')
+  let res = substitute(res, '^.*: ', '', '')
+  if len(res) &gt; 0 &amp;&amp; res != 'http://gist.github.com/gists' 
+    echo 'Done: '
+  else
+    echoerr 'Delete failed'
+  endif
+endfunction
+
 function! s:GistPost(user, token, content, private)
   let ext = expand('%:e')
   let ext = len(ext) ? '.'.ext : ''
@@ -326,7 +386,7 @@ function! s:GistPost(user, token, content, private)
   endif
 
   if a:private
-    call add(query, 'private=on')
+    call add(query, 'action_button=private')
   endif
   let squery = printf(join(query, '&amp;'),
     \ s:encodeURIComponent(ext),
@@ -347,8 +407,70 @@ function! s:GistPost(user, token, content, private)
   call delete(file)
   let res = matchstr(split(res, '\(\r\?\n\|\r\n\?\)'), '^Location: ')
   let res = substitute(res, '^.*: ', '', '')
-  if len(res) &gt; 0 &amp;&amp; res != 'http://gist.github.com/gists' 
-    echo 'done: '.res
+  if len(res) &gt; 0 &amp;&amp; res =~ '^\(http\|https\):\/\/gist\.github\.com\/' 
+    echo 'Done: '.res
+  else
+    echoerr 'Post failed'
+  endif
+  return res
+endfunction
+
+function! s:GistPostBuffers(user, token, private)
+  let bufnrs = range(1, last_buffer_nr())
+  let bn = bufnr('%')
+  let query = []
+  if len(a:user) &gt; 0 &amp;&amp; len(a:token) &gt; 0
+    call add(query, 'login=%s')
+    call add(query, 'token=%s')
+  else
+    call add(query, '%.0s%.0s')
+  endif
+  if a:private
+    call add(query, 'action_button=private')
+  endif
+  let squery = printf(join(query, &quot;&amp;&quot;),
+    \ s:encodeURIComponent(a:user),
+    \ s:encodeURIComponent(a:token)) . '&amp;'
+
+  let query = [
+    \ 'file_ext[gistfile]=%s',
+    \ 'file_name[gistfile]=%s',
+    \ 'file_contents[gistfile]=%s',
+    \ ]
+  let format = join(query, &quot;&amp;&quot;) . '&amp;'
+
+  let index = 1
+  for bufnr in bufnrs
+    if buflisted(bufnr) == 0 || bufwinnr(bufnr) == -1
+      continue
+    endif
+    echo &quot;Creating gist content&quot;.index.&quot;... &quot;
+    silent! exec &quot;buffer! &quot;.bufnr
+    let content = join(getline(1, line('$')), &quot;\n&quot;)
+    let ext = expand('%:e')
+    let ext = len(ext) ? '.'.ext : ''
+    let name = expand('%:t')
+    let squery .= printf(substitute(format, 'gistfile', 'gistfile'.index, 'g'),
+      \ s:encodeURIComponent(ext),
+      \ s:encodeURIComponent(name),
+      \ s:encodeURIComponent(content))
+    let index = index + 1
+  endfor
+  silent! exec &quot;buffer! &quot;.bn
+
+  let file = tempname()
+  exec 'redir! &gt; '.file 
+  silent echo squery
+  redir END
+  echo &quot;Posting it to gist... &quot;
+  let quote = &amp;shellxquote == '&quot;' ?  &quot;'&quot; : '&quot;'
+  let url = 'http://gist.github.com/gists'
+  let res = system('curl -i -d @'.quote.file.quote.' '.url)
+  call delete(file)
+  let res = matchstr(split(res, '\(\r\?\n\|\r\n\?\)'), '^Location: ')
+  let res = substitute(res, '^.*: ', '', '')
+  if len(res) &gt; 0 &amp;&amp; res =~ '^\(http\|https\):\/\/gist\.github\.com\/' 
+    echo 'Done: '.res
   else
     echoerr 'Post failed'
   endif
@@ -379,7 +501,9 @@ function! Gist(line1, line2, ...)
   let gistls = ''
   let gistnm = ''
   let private = 0
+  let multibuffer = 0
   let clipboard = 0
+  let deletepost = 0
   let editpost = 0
   let listmx = '^\(-l\|--list\)\s*\([^\s]\+\)\?$'
   let bufnamemx = '^gist:\(\d\+\)$'
@@ -390,6 +514,8 @@ function! Gist(line1, line2, ...)
       let gistls = '-all'
     elseif arg =~ '^\(-l\|--list\)$'
       let gistls = g:github_user
+    elseif arg =~ '^\(-m\|--multibuffer\)$'
+      let multibuffer = 1
     elseif arg =~ '^\(-p\|--private\)$'
       let private = 1
     elseif arg =~ '^\(-a\|--anonymous\)$'
@@ -397,11 +523,14 @@ function! Gist(line1, line2, ...)
       let token = ''
     elseif arg =~ '^\(-c\|--clipboard\)$'
       let clipboard = 1
+    elseif arg =~ '^\(-d\|--delete\)$' &amp;&amp; bufname =~ bufnamemx
+      let deletepost = 1
+      let gistid = substitute(bufname, bufnamemx, '\1', '')
     elseif arg =~ '^\(-e\|--edit\)$' &amp;&amp; bufname =~ bufnamemx
       let editpost = 1
       let gistid = substitute(bufname, bufnamemx, '\1', '')
     elseif len(gistnm) == 0
-      if editpost == 1
+      if editpost == 1 || deletepost == 1
         let gistnm = arg
       elseif len(gistls) &gt; 0
         let gistls = arg
@@ -421,24 +550,31 @@ function! Gist(line1, line2, ...)
   &quot;echo &quot;private=&quot;.private
   &quot;echo &quot;clipboard=&quot;.clipboard
   &quot;echo &quot;editpost=&quot;.editpost
+  &quot;echo &quot;deletepost=&quot;.deletepost
 
   if len(gistls) &gt; 0
     call s:GistList(user, token, gistls)
-  elseif len(gistid) &gt; 0 &amp;&amp; editpost == 0
+  elseif len(gistid) &gt; 0 &amp;&amp; editpost == 0 &amp;&amp; deletepost == 0
     call s:GistGet(user, token, gistid, clipboard)
   else
-    let content = join(getline(a:line1, a:line2), &quot;\n&quot;)
-    if editpost == 1
-      let url = s:GistUpdate(user, token, content, gistid, gistnm)
+    if multibuffer == 1
+      let url = s:GistPostBuffers(user, token, private)
     else
-      let url = s:GistPost(user, token, content, private)
-    endif
-    if len(url) &gt; 0 &amp;&amp; g:gist_open_browser_after_post
-      let cmd = substitute(g:gist_browser_command, '%URL%', url, 'g')
-      if cmd =~ '^!'
-        silent! exec  cmd
+      let content = join(getline(a:line1, a:line2), &quot;\n&quot;)
+      if editpost == 1
+        let url = s:GistUpdate(user, token, content, gistid, gistnm)
+      elseif deletepost == 1
+        let url = s:GistDelete(user, token, gistid)
       else
-        call system(cmd)
+        let url = s:GistPost(user, token, content, private)
+      endif
+      if len(url) &gt; 0 &amp;&amp; g:gist_open_browser_after_post
+        let cmd = substitute(g:gist_browser_command, '%URL%', url, 'g')
+        if cmd =~ '^!'
+          silent! exec  cmd
+        else
+          call system(cmd)
+        endif
       endif
     endif
   endif
@@ -446,3 +582,4 @@ function! Gist(line1, line2, ...)
 endfunction
 
 command! -nargs=? -range=% Gist :call Gist(&lt;line1&gt;, &lt;line2&gt;, &lt;f-args&gt;)
+&quot; vim:set et:</diff>
      <filename>dot.vim/plugin/gist.vim</filename>
    </modified>
    <modified>
      <diff>@@ -70,7 +70,7 @@ call s:SetOptDefault(&quot;rails_statusline&quot;,1)
 call s:SetOptDefault(&quot;rails_syntax&quot;,1)
 call s:SetOptDefault(&quot;rails_mappings&quot;,1)
 call s:SetOptDefault(&quot;rails_abbreviations&quot;,1)
-call s:SetOptDefault(&quot;rails_ctags_arguments&quot;,&quot;--exclude=facebox.js --exclude=\&quot;*.*.js\&quot;&quot;)
+call s:SetOptDefault(&quot;rails_ctags_arguments&quot;,&quot;--exclude=\&quot;*.js\&quot;&quot;)
 call s:SetOptDefault(&quot;rails_expensive&quot;,1)
 call s:SetOptDefault(&quot;rails_dbext&quot;,g:rails_expensive)
 call s:SetOptDefault(&quot;rails_default_file&quot;,&quot;README&quot;)</diff>
      <filename>dot.vim/plugin/rails.vim</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>7af2ed545580640dabf50106ecdf7e6587a81f88</id>
    </parent>
  </parents>
  <author>
    <name>kenchan</name>
    <email>kenichi.taka@gmail.com</email>
  </author>
  <url>http://github.com/kenchan/dotfiles/commit/34ede5be04582a653b89f79538bde1fa244b6921</url>
  <id>34ede5be04582a653b89f79538bde1fa244b6921</id>
  <committed-date>2009-11-05T02:12:29-08:00</committed-date>
  <authored-date>2009-11-05T02:12:29-08:00</authored-date>
  <message>executed GLVS</message>
  <tree>67b989ef7af3b6aadc3d84556b6edc5528ebc3f9</tree>
  <committer>
    <name>kenchan</name>
    <email>kenichi.taka@gmail.com</email>
  </committer>
</commit>
