Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6152203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:52:50+00:00 2026-05-23T19:52:50+00:00

I’m trying to get up and working with vim with ruby on rails and

  • 0

I’m trying to get up and working with vim with ruby on rails and am having a few problems with omni-completion.

I have downloaded the rails.vim plugin for vim, which appears to be installed, with a vim call

:Rails! 

gives

rails.vim 4.3 (Rails-model-arb)

Calls to rails.vim specific functions like :Rcontroller work a dream so it all looks very promising. My problem is with omni-completion and syntax highlighting, when I ruby file for example Blog/app/models/post.rb with the following contents

1 class Post < ActiveRecord::Base
2   validates :name,  :presence => true
3   validates :title, :presence => true,
4                     :length   => { :minimum => 5 }
5   has_[<C-X><C-O> or <C-X><C-U> or <C-X><C-P>]
6 end

I expect supertab to use the rails omni-completion to provide me with options such as “has_many” etc. I’m a little muddled up as to what each of vims completion types do (keyword local completion, omni completion, user defined completion) from the rails documentation it suggests that user defined completion should provide this functionality. When try it gives the following error:

-- User defined completion (^U^N^P) Pattern not found
Press ENTER or type command to continue

when I try the first time:

Error loading rails environment
Problem loading class "Post", was it already completed?
Press ENTER or type command to continue

when I try another time it gives me
— Omni completion (^O^N^P) Pattern not found

However omnicompletion does work in many cases, for example if i type meth it will give me a list with method, method_defined?, method_missing, methods to choose from.

Im using pathogen to handle my vim files but my .vimrc file contains the following relavent lines.

set nocompatible
call pathogen#helptags()
call pathogen#runtime_append_all_bundles()
syntax on

filetype plugin on
filetype indent on

"set ofu=syntaxcomplete#Complete
set completeopt+=longest,menu,preview

" For code completion with a drop down menu
"au FileType python set omnifunc=pythoncomplete#Complete
let g:SuperTabDefaultCompletionType = "context"
let g:SuperTabContextDefaultCompletionType = "<c-x><c-o>"
let g:SuperTabContextTextOmniPrecedence = ['&omnifunc', '&completefunc']
let g:SuperTabCompletionContexts = ['s:ContextText', 's:ContextDiscover']
let g:SuperTabContextDiscoverDiscovery = ["&completefunc:<c-x><c-u>", "&omnifunc:<c-x><c-o>"]

" If you prefer the Omni-Completion tip window to close when a selection is
" " made, these lines close it on movement in insert mode or when leaving
" " insert mode
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
autocmd InsertLeave * if pumvisible() == 0|pclose|endif

" Set up java autocompletion
:setlocal completefunc=javacomplete#CompleteParamsInfo
au FileType java set omnifunc=javacomplete#CompleteParamsInfo

" Adding ruby completion??
" Turn on language specific omnifuncs
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1

rails.vim is in the ~/.vim/bundle/rails directory, supertab works fine and is installed under ~/.vim/bundle/supertab

I’ve spent such a long time trying to figure this small thing out but have had no success! Does anyone have any ideas on where I should go from this? I believe it could be something todo with the supertab definitions in the .vimrc file, or the ruby omni-completion definitions.

If I remove the line

autocmd FileType ruby,eruby let g:rubycomplete_rails = 1

from the .vimrc file the error loading rails error disappears but of course there is no completion of the text, only a user defined completion error.

This is my first post on StackOverflow after a lot of viewing, I hope I have supplied all the relavent details!

I installed vim with MacPorts and my current version is vim @7.3.146_0+huge+perl+python27+ruby, ruby is enabled but macports wanted to install its own version, thus 1.8.7 is installed under /opt/local/ruby despite me using rvm and having 1.9.2 installed with rails 3.0.7. This could perhaps be the problem? I haven’t found a way of telling macports to use a version of ruby which is already installed though.

Thanks for all your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T19:52:50+00:00Added an answer on May 23, 2026 at 7:52 pm

    I think the ruby completion is being overridden by the java line:

    :setlocal completefunc=javacomplete#CompleteParamsInfo
    

    If I comment that line out I can go into a model and do

    has_<C-X><C-U>
    

    to autocomplete has_many. (You shouldn’t even need the autocmd FileType ruby,eruby ... lines.)

    And yes it’s smart in that n<C-X><C-U> will give you named_scope in a model but number_to_currency and friends in a view.

    However rails.vim will not autocomplete custom methods, though I’m sure there are plugins out there that add that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I am trying to loop through a bunch of documents I have to put
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.