Rails.vim Environment Installation (Ubuntu)

Source: Internet
Author: User
Tags gtk netbeans

It's been more than a year since I've been learning and developing Ruby & rails. But the official full-time rails project was developed with only poor 4 months of experience. During this time I have been using NetBeans 6.x as a development tool, so far I still think it is developing Ruby & The best development tool for the rails program (I didn't use the latest rubymine, and this is a paid product, and I won't pay for it, but I won't use the D version).

On the Internet, we can see that the students who develop rails use VIM to develop the artifact (there are also many in Javeeye). But since my vim level is only limited to using only a few commands (I,: W,: X, DD). So I've always felt that using vim to develop is a bit of a mystery.

A two-day trial of vim for Rails found that it wasn't as difficult as I thought it would be, and the biggest advantage of NetBeans was that it was fast! Open/Find files, search, and so on, everything is fast, what operation basically is to press ENTER, immediately out of the. The boot speed is much more needless to say. But the premise is that you have to install the plug-in you want to use, plus some of the common configuration of vim (before I heard the configuration, my heart began to retreat , in fact, not so scary, as long as you seriously in the online study, have to say that the configuration of vim on the internet is really very much.

Install Vim

My development machine operating system is Ubuntu 9.04, so the following installation configuration is for the Linux system. In addition to installing the command line interface vim, I also installed a GUI interface, in order to be able to start it independently.

Shell Code
    1. sudo apt-get install vim
    2. sudo apt-get install VIM-GTK//very clearly this is the vim supported by the GTK GUI, the startup command below the command line is: Gvim

To remind you, the default installation of the Ubuntu system Vim is a simplified version, a lot of things are not supported, such as syntax highlighting.

If you want to configure your vim, you also need two configuration files (one dedicated to Gvim), which are placed in your user root directory:

~/.VIMRC This is the configuration of vim

Java code
  1. Set guifont=monaco\
  2. "Set Guifontwide=wenquanyi\ zen\ Hei:h12:cGBK
  3. "Set the file browser directory as the current directory
  4. Set Bsdir=buffer
  5. The Set encoding
  6. Set enc=utf-8
  7. The Set file encoding
  8. Set fenc=utf-8
  9. "Set file encoding detection type and support format
  10. Set fencs=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
  11. "Set open syntax highlighting
  12. Syntax on
  13. The Display line number
  14. Set number
  15. "Find results High brightness display
  16. Set Hlsearch
  17. The tab width
  18. Set tabstop=4
  19. Set Cindent shiftwidth=4
  20. Set Autoindent shiftwidth=4
  21. FileType plugin indent on
  22. "Map the F8 to the boot Nerdtree plugin
  23. Map <F8>:nerdtree<cr>
  24. "Map the Ctrl-s to save, because the operation is so used to
  25. IMAP <C-S> <C-C>:w<CR>

~/.GVIMRC This is the configuration for the GUI interface

Java code
  1. "Hide the Gvim menu and toolbars, press F2 to recall, and then press hide
  2. Set Guioptions-=m
  3. Set guioptions-=t
  4. Map <silent> <F2>:if &guioptions =~# ' T ' <Bar>
  5. \set guioptions-=t <Bar>
  6. \set Guioptions-=m <bar>
  7. \Else <Bar>
  8. \set guioptions =t <Bar>
  9. \set guioptions =m <Bar>
  10. \endif<cr>
  11. "Size of window when starting Gvim
  12. Set lines=columns=113

Plug - ins

Can oneself to the VIM website to download, generally zip,tar.gz packing the file, the direct decompression puts in the ~/.vim directory to be possible, if is plugin_name.vim the document to be more simple, puts directly under the ~/.vim/plugin, the worry and the convenient. On the download page generally have an install detail instructions, that is the installation instructions, take a look at one more, you will go a lot less detours.

I installed the Vim plugin and I am referring to http://linuxtoy.org/archives/ruby-rails-on-linux.html:

    1. Rails.vim This is a plug-in for rails, essential.
    2. Snipmate This is called to let Vim and Mac artifact TextMate have the same performance plug-in, is also required.
    3. Nerd_tree Show directory tree, I think it is more useful than that project.vim, so I did not install Project.vim
    4. Supertab.vim
    5. Nerd_commenter.vim quick to add to delete comment, but I seem to have not used.
    6. Lookupfile.vim looking for files, if you just use to develop rails, you can not.
    7. Bufexplorer.vim Buffer Switch
    8. Genutils.vim
    9. Javascript.vim
    10. Blackboard.vim This is the imitation of textmate color, very important.
    11. Monaco fonts This is not a plugin, but this font is very beautiful: http://www.webdevkungfu.com/textmate-envy-aka-monaco-font-for-windows/

Basically, vim for rails is ready to use. Put on my:

Use

  1. Not all Vim plugins are automatically enabled. The general Vim plug-in is to use the command to start, I just do not know this when I used to be crazy for a while. For example, if you want to use the Nerdtree plugin, enter the following command first:
    Java code
    1. : Nerdtree
    2. I have mapped this command to F8, please look at the configuration file above.
  2. The Rails.vim plugin has only one global command rails, which creates a new rails project.
  3. Other Rails.vim commands are to find the rails project files to use, which I am very depressed. For example, if you want to find a user.rb file open, you should have used RFind user.rb, However, because your vim does not open any rails project files, this command is not available!!
  4. The following is my general use method:
    • Open VIM, first CD ~/my_project_path
    • Click F8, launch the Nerdtree plugin, and display my project directory tree.
    • General Rails uses commands:
      Ruby Code
      1. #如果你要找一个文件
      2. : RFind routes.rb
      3. #如果你想打开一个model
      4. : Rmodel User
      5. #如果你想打开一个conotroller
      6. : Rcontroller Users
      7. : Rcont Users
      8. #如果你想打开一个view
      9. : Rview Users/index
      10. : Rview Users/_user
      11. #如果你的当前窗口的文件是在app the/views/users/.
      12. : Rview show #相当于: Rview users/show
      13. #如果你当前光标是controller的index方法中, press R directly to transfer to the view file Index.html.erb
      14. #其它的方法如
      15. : Rserver #启动服务器
      16. : rserver! #停止服务器
      17. : Rjavascript js_name #打开js文件
      18. #还有很多, enter the help command to see for yourself.
      19. : Help Rails
    • Do not use: Rlog in vim to look at the log file, because I use the time, found that it is slow to update, to wait for the output. Or honestly, use tail on the terminal.

Tried for two days, think can also, high efficiency, fix that color, look very comfortable, there is the speed of vim, is really very fast, what is fast.

NetBeans's strengths lie in the way the files and methods jump, but it's slow to start, and slow to find, sometimes impatient.

I have not yet decided whether I will use VIM as a major development tool, after all, NetBeans has a lot of advantages I can not abandon, there is the habit of shortcut keys (I used to use the Java time, using Eclipse, to now use NetBeans or use Eclipse shortcut keys, This shows how difficult the habit is to change.

Rails.vim Environment Installation (Ubuntu)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.