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
- sudo apt-get install vim
- 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
- Set guifont=monaco\
- "Set Guifontwide=wenquanyi\ zen\ Hei:h12:cGBK
- "Set the file browser directory as the current directory
- Set Bsdir=buffer
- The Set encoding
- Set enc=utf-8
- The Set file encoding
- Set fenc=utf-8
- "Set file encoding detection type and support format
- Set fencs=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
- "Set open syntax highlighting
- Syntax on
- The Display line number
- Set number
- "Find results High brightness display
- Set Hlsearch
- The tab width
- Set tabstop=4
- Set Cindent shiftwidth=4
- Set Autoindent shiftwidth=4
- FileType plugin indent on
- "Map the F8 to the boot Nerdtree plugin
- Map <F8>:nerdtree<cr>
- "Map the Ctrl-s to save, because the operation is so used to
- IMAP <C-S> <C-C>:w<CR>
~/.GVIMRC This is the configuration for the GUI interface
Java code
- "Hide the Gvim menu and toolbars, press F2 to recall, and then press hide
- Set Guioptions-=m
- Set guioptions-=t
- Map <silent> <F2>:if &guioptions =~# ' T ' <Bar>
- \set guioptions-=t <Bar>
- \set Guioptions-=m <bar>
- \Else <Bar>
- \set guioptions =t <Bar>
- \set guioptions =m <Bar>
- \endif<cr>
- "Size of window when starting Gvim
- 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:
- Rails.vim This is a plug-in for rails, essential.
- Snipmate This is called to let Vim and Mac artifact TextMate have the same performance plug-in, is also required.
- Nerd_tree Show directory tree, I think it is more useful than that project.vim, so I did not install Project.vim
- Supertab.vim
- Nerd_commenter.vim quick to add to delete comment, but I seem to have not used.
- Lookupfile.vim looking for files, if you just use to develop rails, you can not.
- Bufexplorer.vim Buffer Switch
- Genutils.vim
- Javascript.vim
- Blackboard.vim This is the imitation of textmate color, very important.
- 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
- 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
- : Nerdtree
- I have mapped this command to F8, please look at the configuration file above.
- The Rails.vim plugin has only one global command rails, which creates a new rails project.
- 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!!
- 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
- #如果你要找一个文件
- : RFind routes.rb
- #如果你想打开一个model
- : Rmodel User
- #如果你想打开一个conotroller
- : Rcontroller Users
- : Rcont Users
- #如果你想打开一个view
- : Rview Users/index
- : Rview Users/_user
- #如果你的当前窗口的文件是在app the/views/users/.
- : Rview show #相当于: Rview users/show
- #如果你当前光标是controller的index方法中, press R directly to transfer to the view file Index.html.erb
- #其它的方法如
- : Rserver #启动服务器
- : rserver! #停止服务器
- : Rjavascript js_name #打开js文件
- #还有很多, enter the help command to see for yourself.
- : 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)