Configure Vim for rails Development

Source: Internet
Author: User

Automatic Configuration using scripts

Or this convenient, http://code.google.com/p/vimide/, 1 minute to get .... Recommended...

 
Http://code.google.com/p/vimide/

 

Self-asynchronous Configuration

Although it is slow, you can understand the entire process.

1. Install Vim

 
Sudo apt-Get install Vim

Note: Vim installed in Ubuntu is a simplified version by default, and many things are not supported, such as syntax highlighting.

 

2. modify the configuration file

If you want to configure your vim, you also need to configure the file. vimrc, which is placed in your user root directory.

~ /. Vimrc Configuration

 

 
Set guifont = Monaco \ 11 "set guifontwide = wenquanyi \ Zen \ Hei: H12: cgbk "sets the file browser directory to the current directory set bsdir = buffer" sets the encoding set ENC = UTF-8 "sets the file encoding set fenc = UTF-8" sets the file encoding detection type and supports the format set fencs = UTF-8, ucs-bom, gb18030, GBK, gb2312, cp936 "set enable syntax highlighting syntax on" show row number set number "Search Result High Brightness Display Set hlsearch" tab width set tabstop = 4 set cindent shiftwidth = 4 set autoindent shiftwidth = 4 filetype plugin indent on "ing F8 to the map that starts the nerdtree plug-in <F8>: nerdtree <CR> "Maps CTRL-S to save, because this operation is too accustomed to imap <C-S> <C-C>: W <CR>

 

3 plug-ins

You can download the ZIP files from the vim website, and decompress the files in the tar.gz package ~ /. Vim directory. If it is a plugin_name.vim file, it is easier to directly put it in ~ /. Vim/plugin is easy to worry about and worry-free. On the download page, there is generally an install detail description, that is, the installation instructions, take a look, you will take a lot of detours.

 

Installed plug-ins:

 
Rails. vim is a rails plug-in and is indispensable. snipmate is a plug-in that is known to have the same performance for vim and Mac's textmate. It is also mandatory. the nerd_tree shows the directory tree. I think it is better than the project. vim is much easier to use, so I have not installed a project. vim supertab. vim nerd_commenter.vim is quick to add and delete comment, but I seem to have never used it. lookupfile. vim looks for files. You don't need to use it if you just want to develop rails. bufexplorer. vim buffer switches genutils. vim JavaScript. vim blackboard. VIM: it is very important to imitate the color of textmate. monaco font is not a plug-in, but the font is very beautiful: attackers and other commands do not need to, directly press Ctrl + T to fuzzy query the file name faster

4

 

5. Use

1) Not all Vim plug-ins are automatically enabled. Generally, VIM plug-ins are started using commands. I didn't know this when I was using it, so I went crazy for a while.

For example, to use the nerdtree plug-in, enter the following command:

: Nerdtree // I have mapped this command to F8. Please refer to the configuration file above.

 

2) the rails. Vim plug-in has only one global command rails, which creates a new rails project.

 

3) Other rails. vim commands can be used only when files of the rails project are opened. I am very depressed. for example, you want to find a user. open the RB file, which should have been rfind user. RB, but because your vim does not open any file in the rails project, this command is unavailable !!

 

4) Start the rails Project

 
CD to project directory
 
Vim
 
Press F8 to start the nerdtree plug-in and display the directory tree of my project.

5) Common commands

 
# If you want to find a file
 
: Rfind routes. Rb
 
 
 
# If you want to open a model
 
: Rmodel user
 
 
# If you want to open a conotroller
 
: Rcontroller users
 
: Rcont users
 
 
 
# If you want to open a view
 
: Rview users/Index
 
: Rview users/_ User
 
# If the file in your current window is under APP/views/users /,
 
: Rview show# Equivalent to: rview users/show
 
 
 
# If your current cursor is in the Controller's index method, you can directly press R to transfer to the View File index.html. ERB.
 
 
 
# Other methods such
 
: Rserver# Start the server
 
: Rserver!# Stop a server
: Rjavascript js_name# Open a JS File
 
 
 
# There are many more. Enter the Help Command for yourself.
 
: Help rails

Refer:Http://www.iteye.com/topic/494254

http://code.google.com/p/vimide/

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.