Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 252 lines (165 sloc) 8.469 kb
693a7fa @tpope Convert FAQ to UNIX line endings
tpope authored
1 *vim-ruby.txt* *vim-ruby* *vim-ruby-faq*
2
3 VIM/RUBY CONFIGURATION FILES
4
5 The vim-ruby Project FAQ
6
699670a @dkearns Update all RubyForge URLs with new GitHub equivalents.
dkearns authored
7 https://github.com/vim-ruby/vim-ruby
693a7fa @tpope Convert FAQ to UNIX line endings
tpope authored
8
9 The vim-ruby project maintains Ruby-related configuration files for Vim. This
10 FAQ contains all you need to know about it.
11
12 *** TOC ***
13
14 ==============================================================================
15
16 *vim-ruby-faq-X* What is the vim-ruby project?
17
18 It maintains all the configuration files that help Vim edit Ruby code. By
19 installing these files, Vim will properly highlight and indent Ruby files, and
20 will be able to run them and go directly to the location of any errors.
21 Rakefiles, ERB files, and unit tests are also identified and supported.
22
23 If you make use of this project, make sure you read the installation and
24 configuration instructions in this FAQ.
25
26
27 *vim-ruby-faq-X* Doesn't Vim include these files?
28
29 Yes it does. You should only want to download and install this project if it
30 has changed since you last installed your version of Vim. Read the "News"
31 section of the |vim-ruby-homepage| to see when the most recent release was
32 made.
33
34
35 *vim-ruby-faq-X* How do you get it?
36
37 The easiest way is to run: >
38
39 gem install vim-ruby
40
41 (This really only downloads it. See installation instructions
42 |vim-ruby-install| below.)
43
44 If you don't have RubyGems, download a tarball from: >
45
699670a @dkearns Update all RubyForge URLs with new GitHub equivalents.
dkearns authored
46 https://github.com/vim-ruby/vim-ruby/downloads
693a7fa @tpope Convert FAQ to UNIX line endings
tpope authored
47
48 Again, see installation instructions below.
49
50
51 *vim-ruby-faq-X* How do you install it? *vim-ruby-install*
52
53 If you obtained the vim-ruby files via RubyGems, run: >
54
55 vim-ruby-install.rb
56
57 If you downloaded a tarball, unpack it, change to the created directory, and
58 run: >
59
60 ruby bin/vim-ruby-install.rb
61
62 Whichever way you run it, the effect is the same. The installer will:
63 - Search for a Vim config directory to put its files and ask you to confirm.
64 - Copy the configuration files to the appropriate places underneath the
65 directory you selected.
66
67 Here is an example installation transcript:
68
69 Possible Vim installation directories: ~
70 1) D:/Gavin/vimfiles ~
71 2) E:/Vim/vimfiles ~
72 ~
73 Please select one (or anything else to specify another directory): 2 ~
74 autoload/rubycomplete.vim -> E:/Vim/vimfiles/autoload/rubycomplete.vim ~
75 compiler/eruby.vim -> E:/Vim/vimfiles/compiler/eruby.vim ~
76 compiler/ruby.vim -> E:/Vim/vimfiles/compiler/ruby.vim ~
77 compiler/rubyunit.vim -> E:/Vim/vimfiles/compiler/rubyunit.vim ~
78 ftdetect/ruby.vim -> E:/Vim/vimfiles/ftdetect/ruby.vim ~
79 ftplugin/eruby.vim -> E:/Vim/vimfiles/ftplugin/eruby.vim ~
80 ftplugin/ruby.vim -> E:/Vim/vimfiles/ftplugin/ruby.vim ~
81 indent/eruby.vim -> E:/Vim/vimfiles/indent/eruby.vim ~
82 indent/ruby.vim -> E:/Vim/vimfiles/indent/ruby.vim ~
83 syntax/eruby.vim -> E:/Vim/vimfiles/syntax/eruby.vim ~
84 syntax/ruby.vim -> E:/Vim/vimfiles/syntax/ruby.vim ~
85
86 Existing files are overwritten. This is safe, because it's a slow-maturing
87 project, so new files are better than old ones. However, if you had edited the
88 files, you will have lost your changes. Better make your changes in, for
89 instance:
90
91 ~/.vim/after/ftplugin/ruby.vim ~
92
93 This file will be loaded _after_ the regular config files are loaded, so your
94 customisations will definitely take effect.
95
96
97 *vim-ruby-faq-X* What Vim config do I need? *vim-ruby-config*
98
99 Without the following lines in your .vimrc, _vimrc, or other startup file, the
100 files in the vim-ruby project will be largely useless. >
101
102 set nocompatible " We're running Vim, not Vi!
103 syntax on " Enable syntax highlighting
104 filetype on " Enable filetype detection
105 filetype indent on " Enable filetype-specific indenting
106 filetype plugin on " Enable filetype-specific plugins
107 compiler ruby " Enable compiler support for ruby
108
109 See |.vimrc| for more information about this important Vim configuration file.
110
111 See |matchit-install| for instructions on installing "matchit", which will
112 allow you to use |%| to bounce between Ruby keywords (class, def, while, ...)
113 and their respective "end" keywords.
114
115
116 *vim-ruby-faq-X* How do I know that everything's working?
117
118 If you've run the installer and added the configuration |vim-ruby-config|
119 above, everything should be fine when you restart Vim. To test this:
120 - Edit a Ruby file with Vim (make sure it has a .rb extension).
121 - The code should be syntax highlighted.
122 - Type in some code. When you start a new line, it should be automatically
123 indented to the correct spot.
124 - Add or remove some space from the beginning of a line of code and hit ==.
125 That line should be reindented.
126 - Put the cursor on a "class" or "def" keyword and hit %. The cursor should
127 now be on the matching "end" keyword.
128 - TODO: what else?
129
130
131 *vim-ruby-faq-X* How do I use it?
132
133 TODO: write.
134
135
136 *vim-ruby-faq-X* How do I customise it? *vim-ruby-customize*
137
138 The most important customisation for editing Ruby code is the amount of space to
139 indent. The following is a typical setup. Look up the various options to read
140 about them. >
141
142 set expandtab
143 set tabstop=2 shiftwidth=2 softtabstop=2
144 set autoindent
145
146 TODO: is autoindent necessary? What other options should go here? What about
147 Ruby comments?
148 FIXME: Autoindent is good. maybe mention |i_CTRL_D| and |i_CTRL_T| for
149 moving lines about in this context?
150 COMMENT: I never use ^D and ^T in insert mode, though I always knew what they
151 do. Might try them!
152
153
154 *vim-ruby-faq-X* I want feature X. Will you include it?
155
156 The idea of the vim-ruby project is to maintain configuration files that are
157 actually distributed with Vim. Therefore all functionality should be helpful to
158 all Vim/Ruby users. So the project does not deal with people's individual
159 tastes.
160
161 That said, we are considering creating a separate configuration file for less
162 universal features, whose features users can pick and choose. So don't hesitate
163 to send us your suggestions.
164
165
166 *vim-ruby-faq-X* What are some other cool Ruby-related Vim tricks I can use?
167
168 An example is the following (put it in ~/.vimrc/ftplugin/ruby_extra.vim or
169 similar): [similar? |$VIMRUNTIME| or what?] >
170
171 if !exists( "*EndToken" )
172 function EndToken()
173 let current_line = getline( '.' )
174 let braces_at_end = '{\s*\(|\(,\|\s\|\w\)*|\s*\)\?$'
175 if match( current_line, braces_at_end ) >= 0
176 return '}'
177 else
178 return 'end'
179 endif
180 endfunction
181 endif
182
183 imap <S-CR> <ESC>:execute 'normal o' . EndToken()<CR>O
184
185 This will help you create ruby blocks of code, by inserting "}" or "end" as
186 appropriate. Try creating these lines of code and hitting SHIFT-ENTER:
187
188 array.map { |elem| ~
189
190 def fibonacci(n) ~
191
192 For other suggestions, search the web or look at: >
193
699670a @dkearns Update all RubyForge URLs with new GitHub equivalents.
dkearns authored
194 https://github.com/vim-ruby/vim-ruby/wiki/VimRubySupport
693a7fa @tpope Convert FAQ to UNIX line endings
tpope authored
195
196
197 *vim-ruby-faq-X* How can I report a bug? *vim-ruby-bug-reporting*
198
199 Bug reports are most welcome. In order of preference:
699670a @dkearns Update all RubyForge URLs with new GitHub equivalents.
dkearns authored
200 - submit a bug at https://github.com/vim-ruby/vim-ruby/issues
693a7fa @tpope Convert FAQ to UNIX line endings
tpope authored
201 - send an email to the mailing list (see below)
202 - email the maintainer (email address appears in each configuration file)
203
204
205 *vim-ruby-list*
206 *vim-ruby-faq-X* Does the project have a mailing list?
207
208 Yes: vim-ruby-devel@rubyforge.org. Only subscribers can post. To join, visit:
209 >
210 http://rubyforge.org/mailman/listinfo/vim-ruby-devel
211
212 The list is mirrored at: >
213
214 http://news.gmane.org/gmane.comp.editors.vim.vim%2druby.devel
215
216
217 *vim-ruby-faq-X* Why is this project separate from Vim?
218
219 We can't use Vim's CVS to keep track of these files, so we organise it ourselves
220 and give Bram the latest files in time for each release of Vim. By keeping the
221 Ruby stuff together, we can release it all at once and people can update it
222 independently of Vim.
223
224
225 *vim-ruby-faq-X* I have another question...
226
227 The mailing list or the file maintainer is a good place to ask. Or perhaps
228 comp.lang.ruby, but please make sure you've read the FAQ thoroughly before
229 asking there.
230
231
232 *vim-ruby-faq-X* Can you repeat all the web pages listed in this FAQ?
233
234 Homepage *vim-ruby-homepage* : >
699670a @dkearns Update all RubyForge URLs with new GitHub equivalents.
dkearns authored
235 https://github.com/vim-ruby/vim-ruby/
693a7fa @tpope Convert FAQ to UNIX line endings
tpope authored
236
237 Bug tracker: >
699670a @dkearns Update all RubyForge URLs with new GitHub equivalents.
dkearns authored
238 https://github.com/vim-ruby/vim-ruby/issues
693a7fa @tpope Convert FAQ to UNIX line endings
tpope authored
239
240 Relevant Wiki page: >
699670a @dkearns Update all RubyForge URLs with new GitHub equivalents.
dkearns authored
241 https://github.com/vim-ruby/vim-ruby/wiki
693a7fa @tpope Convert FAQ to UNIX line endings
tpope authored
242
243 Mailing list archives: >
244 http://news.gmane.org/gmane.comp.editors.vim.vim%2druby.devel
245 http://rubyforge.org/pipermail/vim-ruby-devel/
246
247 Mailing list join: >
248 http://rubyforge.org/mailman/listinfo/vim-ruby-devel
249
250
251 vim: ft=help tw=78 noet :
Something went wrong with that request. Please try again.