📜 ⬆️ ⬇️

VIM as a TexMate style Rails IDE thanks to Akita's set of scripts

This is my first post on Habré, please do not judge strictly :)

In the distant past, when I was still writing on c \ c ++, I used the excellent VIM editor, knew the minimum set of vim chips, and was generally pleased with his work. Somewhat later, I started learning Rails and programming in Ruby . I quickly realized that the basic delivery of VIM is not enough, I tried a couple of manuals found on the Internet to bring VIM to the level of a full-fledged IDE , came across pitfalls, and quickly gave up. At that moment, I wanted to learn first and foremost exactly Rails, not VIM.
I have a little thought with various other editors and IDEs like Aptana, Geany, Eclipse, etc. until I stumbled upon completely, at that time, satisfying me with Netbeans . About Netbeans can write, and it is written , a lot of good. As an IDE for developing on Ruby Netbeans is just great. I still use it if I work in Windows. But once I was for a long time, not at my own, but behind someone else's laptop, on which VIM was already standing, in a place where Internet traffic was severely limited. And Taksovik demanded urgent work. It was not ethical to pump out ~ 60mb of Netbeans and another nth amount of mb per plug-in, I started learning VIM again. And to my joy, I rather quickly came across a set of scripts from the Brazilian Akita on Rails and a screencast to boot. He, as I understood, gathered a bunch of useful plug-ins together and slightly added the config. Everything that will be discussed below is true not only for Ruby, but also for other languages ​​such as C, PHP, etc., there are ready-made snippets sets (more about them later) for them.

The main features of this set of scripts


  1. FuzzyFinderTexMate is a very convenient file search in the project by ctrl + f. For example, to find the config \ routes.rb file you need to type rorb. Or even less :)
  2. A set of snippets from TexMate and some of its own (in the sense of NERDSnippets). Very convenient, you type vf + TAB - you get validates_format_of: <+ attribute +>,: with => / <+ regex +> / <+,: on =>: <+ create +>,: message => "<+ is invalid +>" +>, where by TAB you jump between the parameters enclosed in <+ ... +>. Snippets are for everything, anything, their full list can be viewed in the snippets folder in the directory with the VIM configuration files.
  3. Project tree implemented with NERDTree. Available by \ + p (backslash and p). Switching from the project tree to the code editing window and back is done by ctrl + w and the arrow (where the arrow will be, there the cursor will jump), in the tree o - open \ close the folder \ file, R (shift + r) - update the tree and on the question (?) pretty clear help on hotkeys.
  4. Code highlighting (rb, html, rjs, js, erb, etc.)
  5. Opportunities from rails.vim type of transition on gf to a model file, if the cursor is on a call, for example, a constructor. All kinds: Rake,: Rgenerate, etc.
  6. Well, all the features and bells and whistles of VIM, for which he is so loved :)

')
And here is the screencast from the author on this topic (I recommend for viewing):


Stopped working. Link to another video hosting: blip.tv/file/3765175

I hope you are already rubbing your hands, because vim is a very fast, convenient, extensible and very resource-intensive editor.

Making it all so easy. The aforementioned Akita collected all this in one github project.

Installation


Linux and Mac:

cd ~
git clone git://github.com/akitaonrails/vimfiles.git .vim
cd .vim
git submodule init
git submodule update


If you have Windows, then first you need to install Exuberant CTags and msysGit , and then do the following:

cd %HOME%
git clone git://github.com/akitaonrails/vimfiles.git
cd vimfiles
git submodule init
git submodule update


Next, you open your ~ / .vimrc (on Windows% HOME% \ _ vimrc), and insert the following lines there:

source ~/.vim/vimrc ", Akita
" Windows %HOME%\vimfiles\vimrc
colorscheme vibrantink " TexMate
set nu "
set sw=2 " TAB 2
set sts=2 ",
let g:fuzzy_ignore = "gems/*"


Afterword



Actually, I am very pleased with the work of these scripts and VIM, and now on my main linux-laptop I have moved from Netbeans to VIM. The main arguments are convenience in operation (however, it is comparable), the speed of work, the absence of the need to work with the mouse (although VIM supports the mouse) and the download speed (cold start of Netbeans - 30 seconds).
Not without cost, of course, without small pitfalls. For all this beauty to work, you need VIM compiled with Ruby support. Where I originally set up this environment, Mandriva 2010 was installed, and for some reason, even in the most advanced vim-enhanced, there was no such support. However, a lot of things worked without it (but FuzzyFinderTexMate, for example, did not work). This is easily verified:
vim --version | grep ruby
or, if there is no grep, then simply vim --version and search + ruby ​​(compiled with support) or -ruby (compiled without support).

Just in case, I will say that I never worked in TexMate :)

Few links


Akita on Rails blog itself
Post about VIM + RAILS + IDE: part 1 , part 2
The same, but under Windows

Update number 2

How to correctly suggest in the comments: an article on Habré about Ruby applications debugging in VIM

Update:

PS If it is not difficult for you, please increase the karma so that I can transfer it to the thematic blog.
Moved, thanks! :)

Source: https://habr.com/ru/post/68013/


All Articles