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