utils 0.0.67 → 0.0.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/bin/edit +3 -1
- data/lib/utils/editor.rb +14 -0
- data/lib/utils/version.rb +1 -1
- data/utils.gemspec +3 -3
- metadata +3 -74
- data/lib/utils/config/vim/after/syntax/haml.vim +0 -9
- data/lib/utils/config/vim/after/syntax/html.vim +0 -11
- data/lib/utils/config/vim/autoload/Align.vim +0 -1029
- data/lib/utils/config/vim/autoload/AlignMaps.vim +0 -330
- data/lib/utils/config/vim/autoload/ctrlp/bookmarkdir.vim +0 -139
- data/lib/utils/config/vim/autoload/ctrlp/buffertag.vim +0 -238
- data/lib/utils/config/vim/autoload/ctrlp/changes.vim +0 -96
- data/lib/utils/config/vim/autoload/ctrlp/dir.vim +0 -90
- data/lib/utils/config/vim/autoload/ctrlp/line.vim +0 -63
- data/lib/utils/config/vim/autoload/ctrlp/mixed.vim +0 -83
- data/lib/utils/config/vim/autoload/ctrlp/mrufiles.vim +0 -119
- data/lib/utils/config/vim/autoload/ctrlp/quickfix.vim +0 -62
- data/lib/utils/config/vim/autoload/ctrlp/rtscript.vim +0 -49
- data/lib/utils/config/vim/autoload/ctrlp/tag.vim +0 -112
- data/lib/utils/config/vim/autoload/ctrlp/undo.vim +0 -154
- data/lib/utils/config/vim/autoload/ctrlp/utils.vim +0 -72
- data/lib/utils/config/vim/autoload/ctrlp.vim +0 -1772
- data/lib/utils/config/vim/autoload/rails.vim +0 -4570
- data/lib/utils/config/vim/autoload/rubycomplete.vim +0 -801
- data/lib/utils/config/vim/autoload/sqlcomplete.vim +0 -741
- data/lib/utils/config/vim/autoload/vimball.vim +0 -750
- data/lib/utils/config/vim/colors/flori.vim +0 -116
- data/lib/utils/config/vim/compiler/coffee.vim +0 -68
- data/lib/utils/config/vim/compiler/eruby.vim +0 -40
- data/lib/utils/config/vim/compiler/ruby.vim +0 -67
- data/lib/utils/config/vim/compiler/rubyunit.vim +0 -34
- data/lib/utils/config/vim/doc/Decho.txt +0 -372
- data/lib/utils/config/vim/doc/coffee-script.txt +0 -116
- data/lib/utils/config/vim/doc/ctrlp.txt +0 -1113
- data/lib/utils/config/vim/doc/fugitive.txt +0 -257
- data/lib/utils/config/vim/doc/rails.txt +0 -1022
- data/lib/utils/config/vim/doc/xml-plugin.txt +0 -226
- data/lib/utils/config/vim/ftdetect/coffee.vim +0 -8
- data/lib/utils/config/vim/ftdetect/eco.vim +0 -1
- data/lib/utils/config/vim/ftdetect/ragel.vim +0 -2
- data/lib/utils/config/vim/ftdetect/ruby.vim +0 -17
- data/lib/utils/config/vim/ftdetect/slim.vim +0 -2
- data/lib/utils/config/vim/ftplugin/coffee.vim +0 -221
- data/lib/utils/config/vim/ftplugin/eruby.vim +0 -100
- data/lib/utils/config/vim/ftplugin/ruby.vim +0 -260
- data/lib/utils/config/vim/ftplugin/xml.vim +0 -941
- data/lib/utils/config/vim/indent/IndentAnything_html.vim +0 -35
- data/lib/utils/config/vim/indent/coffee.vim +0 -338
- data/lib/utils/config/vim/indent/eruby.vim +0 -77
- data/lib/utils/config/vim/indent/javascript.vim +0 -116
- data/lib/utils/config/vim/indent/ruby.vim +0 -377
- data/lib/utils/config/vim/indent/slim.vim +0 -75
- data/lib/utils/config/vim/plugin/AlignMapsPlugin.vim +0 -242
- data/lib/utils/config/vim/plugin/AlignPlugin.vim +0 -41
- data/lib/utils/config/vim/plugin/Decho.vim +0 -592
- data/lib/utils/config/vim/plugin/IndentAnything.vim +0 -675
- data/lib/utils/config/vim/plugin/bufexplorer.vim +0 -1144
- data/lib/utils/config/vim/plugin/cecutil.vim +0 -508
- data/lib/utils/config/vim/plugin/ctrlp.vim +0 -61
- data/lib/utils/config/vim/plugin/fugitive.vim +0 -2041
- data/lib/utils/config/vim/plugin/lusty-explorer.vim +0 -1509
- data/lib/utils/config/vim/plugin/rails.vim +0 -339
- data/lib/utils/config/vim/plugin/rubyextra.vim +0 -193
- data/lib/utils/config/vim/plugin/surround.vim +0 -628
- data/lib/utils/config/vim/plugin/taglist.vim +0 -4546
- data/lib/utils/config/vim/plugin/test/IndentAnything/test.js +0 -131
- data/lib/utils/config/vim/plugin/vimballPlugin.vim +0 -40
- data/lib/utils/config/vim/syntax/Decho.vim +0 -101
- data/lib/utils/config/vim/syntax/coffee.vim +0 -217
- data/lib/utils/config/vim/syntax/eco.vim +0 -62
- data/lib/utils/config/vim/syntax/eruby.vim +0 -73
- data/lib/utils/config/vim/syntax/javascript.vim +0 -246
- data/lib/utils/config/vim/syntax/ragel.vim +0 -165
- data/lib/utils/config/vim/syntax/ruby.vim +0 -367
- data/lib/utils/config/vim/syntax/slim.vim +0 -117
- data/lib/utils/config/vimrc +0 -540
@@ -1,1022 +0,0 @@
|
|
1
|
-
*rails.txt* Plugin for working with Ruby on Rails applications
|
2
|
-
|
3
|
-
Author: Tim Pope <http://tpo.pe/>
|
4
|
-
License: Same terms as Vim itself (see |license|)
|
5
|
-
|
6
|
-
|rails-introduction| Introduction and Feature Summary
|
7
|
-
|rails-commands| General Commands
|
8
|
-
|rails-navigation| Navigation
|
9
|
-
|rails-gf| File Under Cursor - gf
|
10
|
-
|rails-alternate-related| Alternate and Related Files
|
11
|
-
|rails-type-navigation| File Type Commands
|
12
|
-
|rails-custom-navigation| Custom Navigation Commands
|
13
|
-
|rails-rake| Rake
|
14
|
-
|rails-scripts| Script Wrappers
|
15
|
-
|rails-refactoring| Refactoring Helpers
|
16
|
-
|rails-partials| Partial Extraction
|
17
|
-
|rails-migrations| Migration Inversion
|
18
|
-
|rails-integration| Integration
|
19
|
-
|rails-vim-integration| Integration with the Vim Universe
|
20
|
-
|rails-rails-integration| Integration with the Rails Universe
|
21
|
-
|rails-abbreviations| Abbreviations
|
22
|
-
|rails-syntax| Syntax Highlighting
|
23
|
-
|rails-options| Managed Vim Options
|
24
|
-
|rails-configuration| Configuration
|
25
|
-
|rails-global-settings| Global Settings
|
26
|
-
|rails-about| About rails.vim
|
27
|
-
|rails-license| License
|
28
|
-
|
29
|
-
This plugin is only available if 'compatible' is not set.
|
30
|
-
|
31
|
-
{Vi does not have any of this}
|
32
|
-
|
33
|
-
INTRODUCTION *rails-introduction* *rails*
|
34
|
-
|
35
|
-
Whenever you edit a file in a Rails application, this plugin will be
|
36
|
-
automatically activated. This sets various options and defines a few
|
37
|
-
buffer-specific commands.
|
38
|
-
|
39
|
-
If you are in a hurry to get started, with a minimal amount of reading, you
|
40
|
-
are encouraged to at least skim through the headings and command names in this
|
41
|
-
file, to get a better idea of what is offered. If you only read one thing,
|
42
|
-
make sure it is the navigation section: |rails-navigation|.
|
43
|
-
|
44
|
-
GENERAL COMMANDS *rails-commands*
|
45
|
-
|
46
|
-
All commands are buffer local, unless otherwise stated. This means you must
|
47
|
-
actually edit a file from a Rails application.
|
48
|
-
|
49
|
-
*rails-:Rails*
|
50
|
-
:Rails new {directory} The only global command. Creates a new Rails
|
51
|
-
application in {directory}, and loads the README.
|
52
|
-
|
53
|
-
:Rails! Show the version of rails.vim installed. If rails.vim
|
54
|
-
is active for the current buffer, also show the type
|
55
|
-
of Rails file detected.
|
56
|
-
|
57
|
-
*rails-:Rcd*
|
58
|
-
:Rcd [{directory}] |:cd| to /path/to/railsapp/{directory}.
|
59
|
-
|
60
|
-
*rails-:Rlcd*
|
61
|
-
:Rlcd [{directory}] |:lcd| to /path/to/railsapp/{directory}.
|
62
|
-
|
63
|
-
*rails-:Rdoc*
|
64
|
-
:Rdoc Browse to the Rails API, either in doc/api in the
|
65
|
-
current Rails application, gem_server if it is
|
66
|
-
running, or http://api.rubyonrails.org/ . Requires
|
67
|
-
:OpenURL to be defined (see |rails-:OpenURL|).
|
68
|
-
|
69
|
-
*rails-:Rdoc!*
|
70
|
-
:Rdoc! Make the appropriate |:helptags| call and invoke
|
71
|
-
|:help| rails.
|
72
|
-
|
73
|
-
*rails-:Redit*
|
74
|
-
:Redit {file} Edit {file}, relative to the application root. Append
|
75
|
-
:line or #method to jump within the file, as in
|
76
|
-
:Redit app/controllers/users_controller.rb:12 or
|
77
|
-
:Redit app/models/user.rb#activate .
|
78
|
-
|
79
|
-
*rails-:Rlog*
|
80
|
-
:Rlog [{logfile}] Split window and open {logfile} ($RAILS_ENV or
|
81
|
-
development by default). The control characters used
|
82
|
-
for highlighting are removed. If you have a :Tail
|
83
|
-
command (provided by |tailminusf|.vim), that is used;
|
84
|
-
otherwise, the file does NOT reload upon change.
|
85
|
-
Use |:checktime| to tell Vim to check for changes.
|
86
|
-
|G| has been mapped to do just that prior to jumping
|
87
|
-
to the end of the file, and q is mapped to close the
|
88
|
-
window. If the delay in loading is too long, you
|
89
|
-
might like :Rake log:clear.
|
90
|
-
|
91
|
-
*rails-:Rpreview*
|
92
|
-
:Rpreview [{path}] Creates a URL from http://localhost:3000/ and the
|
93
|
-
{path} given. The not too useful default is to then
|
94
|
-
edit this URL using Vim itself, allowing |netrw| to
|
95
|
-
download it. More useful is to define a :OpenURL
|
96
|
-
command, which will be used instead (see
|
97
|
-
|rails-:OpenURL|). If {path} is omitted, a sensible
|
98
|
-
default is used (considers the current
|
99
|
-
controller/template, but does not take routing into
|
100
|
-
account). The default is overridden by comments like
|
101
|
-
the following that are either before the current
|
102
|
-
method call or at the top of the file: >
|
103
|
-
# GET /users
|
104
|
-
# PUT /users/1
|
105
|
-
<
|
106
|
-
*rails-:Rpreview!*
|
107
|
-
:Rpreview! [{path}] As with :Rpreview, except :OpenURL is never used.
|
108
|
-
|
109
|
-
*rails-:Rtags*
|
110
|
-
:Rtags Calls ctags -R on the current application root and
|
111
|
-
writes the result to tmp/tags. Exuberant ctags must
|
112
|
-
be installed. Additional arguments can be passed to
|
113
|
-
ctags with |g:rails_ctags_arguments|.
|
114
|
-
|
115
|
-
*rails-:Rrefresh*
|
116
|
-
:Rrefresh Refreshes certain cached settings. Most noticeably,
|
117
|
-
this clears the cached list of classes that are syntax
|
118
|
-
highlighted as railsUserClass.
|
119
|
-
|
120
|
-
*rails-:Rrefresh!*
|
121
|
-
:Rrefresh! As above, and also reloads rails.vim.
|
122
|
-
|
123
|
-
*rails-:OpenURL*
|
124
|
-
:OpenURL {url} This is not a command provided by the plugin, but
|
125
|
-
rather provided by user and utilized by other plugin
|
126
|
-
features. This command should be defined to open the
|
127
|
-
provided {url} in a web browser. An example command
|
128
|
-
on a Mac might be: >
|
129
|
-
:command -bar -nargs=1 OpenURL :!open <args>
|
130
|
-
< The following appears to work on Windows: >
|
131
|
-
:command -bar -nargs=1 OpenURL :!start cmd /cstart /b <args>
|
132
|
-
< On Debian compatible distributions, the following is
|
133
|
-
the preferred method: >
|
134
|
-
:command -bar -nargs=1 OpenURL :!sensible-browser <args>
|
135
|
-
< If exists("$SECURITYSESSIONID"), has("gui_win32"), or
|
136
|
-
executable("sensible-browser") is true, the
|
137
|
-
corresponding command above will be automatically
|
138
|
-
defined. Otherwise, you must provide your own (which
|
139
|
-
is recommended, regardless).
|
140
|
-
|
141
|
-
NAVIGATION *rails-navigation*
|
142
|
-
|
143
|
-
Navigation is where the real power of this plugin lies. Efficient use of the
|
144
|
-
following features will greatly ease navigating the Rails file structure.
|
145
|
-
|
146
|
-
The 'path' has been modified to include all the best places to be.
|
147
|
-
>
|
148
|
-
:find blog_controller
|
149
|
-
:find book_test
|
150
|
-
<
|
151
|
-
*rails-:Rfind*
|
152
|
-
:Rfind [{file}] Find {file}. Very similar to :find, but things like
|
153
|
-
BlogController are properly handled, and tab complete
|
154
|
-
works.
|
155
|
-
|
156
|
-
File Under Cursor - gf ~
|
157
|
-
*rails-gf*
|
158
|
-
The |gf| command, which normally edits the current file under the cursor, has
|
159
|
-
been remapped to take context into account. |CTRL-W_f|(open in new window) and
|
160
|
-
|CTRL-W_gf| (open in new tab) are also remapped.
|
161
|
-
|
162
|
-
Example uses of |gf|, and where they might lead.
|
163
|
-
(* indicates cursor position)
|
164
|
-
>
|
165
|
-
Pos*t.first
|
166
|
-
< app/models/post.rb ~
|
167
|
-
>
|
168
|
-
has_many :c*omments
|
169
|
-
< app/models/comment.rb ~
|
170
|
-
>
|
171
|
-
link_to 'Home', :controller => 'bl*og'
|
172
|
-
< app/controllers/blog_controller.rb ~
|
173
|
-
>
|
174
|
-
<%= render 'sh*ared/sidebar' %>
|
175
|
-
< app/views/shared/_sidebar.html.erb ~
|
176
|
-
>
|
177
|
-
<%= stylesheet_link_tag 'scaf*fold' %>
|
178
|
-
< public/stylesheets/scaffold.css ~
|
179
|
-
>
|
180
|
-
class BlogController < Applica*tionController
|
181
|
-
< app/controllers/application_controller.rb ~
|
182
|
-
>
|
183
|
-
class ApplicationController < ActionCont*roller::Base
|
184
|
-
< .../action_controller/base.rb ~
|
185
|
-
>
|
186
|
-
fixtures :pos*ts
|
187
|
-
< test/fixtures/posts.yml ~
|
188
|
-
>
|
189
|
-
layout :pri*nt
|
190
|
-
< app/views/layouts/print.html.erb ~
|
191
|
-
>
|
192
|
-
<%= link_to "New", new_comme*nt_path %>
|
193
|
-
< app/controllers/comments_controller.rb (jumps to def new) ~
|
194
|
-
|
195
|
-
In the last example, the controller and action for the named route are
|
196
|
-
determined by evaluating routes.rb as Ruby and doing some introspection. This
|
197
|
-
means code from the application is executed. Keep this in mind when
|
198
|
-
navigating unfamiliar applications.
|
199
|
-
|
200
|
-
Alternate and Related Files ~
|
201
|
-
*rails-alternate-related*
|
202
|
-
Two commands, :A and :R, are used quickly jump to an "alternate" and a
|
203
|
-
"related" file, defined below.
|
204
|
-
|
205
|
-
*rails-:A* *rails-:AE* *rails-:AS* *rails-:AV* *rails-:AT* *rails-:AD*
|
206
|
-
:A These commands were picked to mimic Michael Sharpe's
|
207
|
-
:AE a.vim. Briefly, they edit the "alternate" file, in
|
208
|
-
:AS either the same window (:A and :AE), a new split
|
209
|
-
:AV window (:AS), a new vertically split window (:AV), a
|
210
|
-
:AT new tab (:AT), or read it into the current buffer
|
211
|
-
:AD (:AD). A mapping for :A is [f .
|
212
|
-
|
213
|
-
*rails-:R* *rails-:RE* *rails-:RS* *rails-:RV* *rails-:RT* *rails-:RD*
|
214
|
-
:R These are similar |rails-:A| and friends above, only
|
215
|
-
:RE they jump to the "related" file rather than the
|
216
|
-
:RS "alternate." A mapping for :R is ]f .
|
217
|
-
:RV
|
218
|
-
:RT
|
219
|
-
:RD
|
220
|
-
|
221
|
-
*rails-alternate* *rails-related*
|
222
|
-
The alternate file is most frequently the test file, though there are
|
223
|
-
exceptions. The related file varies, and is sometimes dependent on current
|
224
|
-
location in the file. For example, when editing a controller, the related
|
225
|
-
file is template for the method currently being edited.
|
226
|
-
|
227
|
-
The easiest way to learn these commands is to experiment. A few examples of
|
228
|
-
alternate and related files for a Test::Unit application follow:
|
229
|
-
|
230
|
-
Current file Alternate file Related file ~
|
231
|
-
model unit test schema definition
|
232
|
-
controller (in method) functional test template (view)
|
233
|
-
template (view) functional test controller (jump to method)
|
234
|
-
migration previous migration next migration
|
235
|
-
config/database.yml config/routes.rb config/environments/*.rb
|
236
|
-
|
237
|
-
Suggestions for further contexts to consider for the alternate file, related
|
238
|
-
file, and file under the cursor are welcome. They are subtly tweaked from
|
239
|
-
release to release.
|
240
|
-
|
241
|
-
File Type Navigation Commands ~
|
242
|
-
*rails-type-navigation*
|
243
|
-
For the less common cases, a more deliberate set of commands are provided.
|
244
|
-
Each of the upcoming commands takes an optional argument (with tab completion)
|
245
|
-
but defaults to a reasonable guess. Commands that default to the current
|
246
|
-
model or controller generally behave like you'd expect in other file types.
|
247
|
-
For example, in app/helpers/posts_helper.rb, the current controller is
|
248
|
-
"posts", and in test/fixtures/comments.yml, the current model is "comment".
|
249
|
-
In model related files, the current controller is the pluralized model name,
|
250
|
-
and in controller related files, the current model is the singularized
|
251
|
-
controller name.
|
252
|
-
|
253
|
-
Each of the following commands has variants for splitting, vertical splitting,
|
254
|
-
opening in a new tab, and reading the file into the current buffer. For
|
255
|
-
:Rmodel, those variants would be :RSmodel, :RVmodel, :RTmodel, and :RDmodel.
|
256
|
-
There is also :REmodel which is a synonym for :Rmodel (future versions might
|
257
|
-
allow customization of the behavior of :Rmodel). They also allow for jumping
|
258
|
-
to methods or line numbers using the same syntax as |:Redit|, and file
|
259
|
-
creation can be forced by adding a ! after the filename (not after the command
|
260
|
-
itself!).
|
261
|
-
|
262
|
-
:Rcontroller |rails-:Rcontroller|
|
263
|
-
:Renvironment |rails-:Renvironment|
|
264
|
-
:Rfixtures |rails-:Rfixtures|
|
265
|
-
:Rfunctionaltest |rails-:Rfunctionaltest|
|
266
|
-
:Rhelper |rails-:Rhelper|
|
267
|
-
:Rinitializer |rails-:Rinitializer|
|
268
|
-
:Rintegrationtest |rails-:Rintegrationtest|
|
269
|
-
:Rjavascript |rails-:Rjavascript|
|
270
|
-
:Rlayout |rails-:Rlayout|
|
271
|
-
:Rlib |rails-:Rlib|
|
272
|
-
:Rlocale |rails-:Rlocale|
|
273
|
-
:Rmailer |rails-:Rmailer|
|
274
|
-
:Rmetal |rails-:Rmetal|
|
275
|
-
:Rmigration |rails-:Rmigration|
|
276
|
-
:Rmodel |rails-:Rmodel|
|
277
|
-
:Robserver |rails-:Robserver|
|
278
|
-
:Rplugin |rails-:Rplugin|
|
279
|
-
:Rspec |rails-:Rspec|
|
280
|
-
:Rstylesheet |rails-:Rstylesheet|
|
281
|
-
:Rtask |rails-:Rtask|
|
282
|
-
:Runittest |rails-:Runittest|
|
283
|
-
:Rview |rails-:Rview|
|
284
|
-
|
285
|
-
*rails-:Rcontroller*
|
286
|
-
:Rcontroller [{name}] Edit the specified or current controller.
|
287
|
-
|
288
|
-
*rails-:Renvironment*
|
289
|
-
:Renvironment [{name}] Edit the config/environments file specified. With no
|
290
|
-
argument, defaults to editing config/application.rb
|
291
|
-
or config/environment.rb.
|
292
|
-
|
293
|
-
*rails-:Rfixtures*
|
294
|
-
:Rfixtures [{name}] Edit the fixtures for the given or current model. If
|
295
|
-
an argument is given, it must be pluralized, like the
|
296
|
-
final filename (this may change in the future). If
|
297
|
-
omitted, the current model is pluralized. An optional
|
298
|
-
extension can be given, to distinguish between YAML
|
299
|
-
and CSV fixtures.
|
300
|
-
|
301
|
-
*rails-:Rfunctionaltest*
|
302
|
-
:Rfunctionaltest [{name}]
|
303
|
-
Edit the functional test or controller spec for the
|
304
|
-
specified or current controller.
|
305
|
-
|
306
|
-
*rails-:Rhelper*
|
307
|
-
:Rhelper [{name}] Edit the helper for the specified name or current
|
308
|
-
controller.
|
309
|
-
|
310
|
-
*rails-:Rinitializer*
|
311
|
-
:Rinitializer [{name}] Edit the config/initializers file specified. With no
|
312
|
-
argument, defaults to editing config/routes.rb.
|
313
|
-
|
314
|
-
*rails-:Rintegrationtest*
|
315
|
-
:Rintegrationtest [{name}]
|
316
|
-
Edit the integration test, integration spec, or
|
317
|
-
cucumber feature specified. With no argument,
|
318
|
-
defaults to editing test/test_helper.rb.
|
319
|
-
|
320
|
-
*rails-:Rjavascript*
|
321
|
-
:Rjavascript [{name}] Edit the JavaScript for the specified name or current
|
322
|
-
controller. Also supports CoffeeScript in
|
323
|
-
app/scripts/.
|
324
|
-
|
325
|
-
*rails-:Rlayout*
|
326
|
-
:Rlayout [{name}] Edit the specified layout. Defaults to the layout for
|
327
|
-
the current controller, or the application layout if
|
328
|
-
that cannot be found. A new layout will be created if
|
329
|
-
an extension is given.
|
330
|
-
|
331
|
-
*rails-:Rlib*
|
332
|
-
:Rlib [{name}] Edit the library from the lib directory for the
|
333
|
-
specified name. If the current file is part of a
|
334
|
-
plugin, the libraries from that plugin can be
|
335
|
-
specified as well. With no argument, defaults to
|
336
|
-
editing db/seeds.rb.
|
337
|
-
|
338
|
-
*rails-:Rlocale*
|
339
|
-
:Rlocale [{name}] Edit the config/locale file specified, optionally
|
340
|
-
adding a yml or rb extension if none is given. With
|
341
|
-
no argument, checks config/environment.rb for the
|
342
|
-
default locale.
|
343
|
-
|
344
|
-
*rails-:Rmailer*
|
345
|
-
:Rmailer [{name}] Edit the mailer specified. This looks in both
|
346
|
-
app/mailers for Rails 3 and app/models for older
|
347
|
-
versions of Rails but only tab completes the former.
|
348
|
-
|
349
|
-
*rails-:Rmetal*
|
350
|
-
:Rmetal [{name}] Edit the app/metal file specified. With no argument,
|
351
|
-
defaults to editing config/boot.rb.
|
352
|
-
|
353
|
-
*rails-:Rmigration*
|
354
|
-
:Rmigration [{pattern}] If {pattern} is a number, find the migration for that
|
355
|
-
particular set of digits, zero-padding if necessary.
|
356
|
-
Otherwise, find the newest migration containing the
|
357
|
-
given pattern. Omitting the pattern selects the
|
358
|
-
latest migration. Give a numeric argument of 0 to edit
|
359
|
-
db/schema.rb.
|
360
|
-
|
361
|
-
*rails-:Rmodel*
|
362
|
-
:Rmodel [{name}] Edit the specified or current model.
|
363
|
-
|
364
|
-
*rails-:Robserver*
|
365
|
-
:Robserver [{name}] Find the observer with a name like
|
366
|
-
{model}_observer.rb. When in an observer, most
|
367
|
-
commands (like :Rmodel) will seek based on the
|
368
|
-
observed model ({model}) and not the actual observer
|
369
|
-
({model}_observer). However, for the command
|
370
|
-
:Runittest, a file of the form
|
371
|
-
{model}_observer_test.rb will be found.
|
372
|
-
|
373
|
-
*rails-:Rplugin*
|
374
|
-
:Rplugin [{plugin}[/{path}]]
|
375
|
-
Edits a file within a plugin. If the path to the file
|
376
|
-
is omitted, it defaults to init.rb. If no argument is
|
377
|
-
given, it defaults to editing the application Gemfile.
|
378
|
-
|
379
|
-
*rails-:Rspec*
|
380
|
-
:Rspec [{name}] Edit the given spec. With no argument, defaults to
|
381
|
-
editing spec/spec_helper.rb (If you want to jump to
|
382
|
-
the spec for the given file, use |:A| instead). This
|
383
|
-
command is only defined if there is a spec folder in
|
384
|
-
the root of the application.
|
385
|
-
|
386
|
-
*rails-:Rstylesheet*
|
387
|
-
:Rstylesheet [{name}] Edit the stylesheet for the specified name or current
|
388
|
-
controller. Also supports Sass and SCSS.
|
389
|
-
|
390
|
-
*rails-:Rtask*
|
391
|
-
:Rtask [{name}] Edit the .rake file from lib/tasks for the specified
|
392
|
-
name. If the current file is part of a plugin, the
|
393
|
-
tasks for that plugin can be specified as well. If no
|
394
|
-
argument is given, either the current plugin's
|
395
|
-
Rakefile or the application Rakefile will be edited.
|
396
|
-
|
397
|
-
*rails-:Runittest*
|
398
|
-
:Runittest [{name}] Edit the unit test or model spec for the specified
|
399
|
-
name or current model.
|
400
|
-
|
401
|
-
*rails-:Rview*
|
402
|
-
:Rview [[{controller}/]{view}]
|
403
|
-
Edit the specified view. The controller will default
|
404
|
-
sensibly, and the view name can be omitted when
|
405
|
-
editing a method of a controller. If a view name is
|
406
|
-
given with an extension, a new file will be created.
|
407
|
-
This is a quick way to create a new view.
|
408
|
-
|
409
|
-
Custom Navigation Commands ~
|
410
|
-
*rails-custom-navigation*
|
411
|
-
|
412
|
-
It is also possible to create custom navigation commands. This is best done
|
413
|
-
in an initialization routine of some sort (e.g., an autocommand); see
|
414
|
-
|rails-configuration| for details.
|
415
|
-
|
416
|
-
*rails-:Rnavcommand*
|
417
|
-
:Rnavcommand [options] {name} [{path} ...]
|
418
|
-
Create a navigation command with the supplied
|
419
|
-
name, looking in the supplied paths, using the
|
420
|
-
supplied options. The -suffix option specifies what
|
421
|
-
suffix to filter on, and strip from the filename, and
|
422
|
-
defaults to -suffix=.rb . The -glob option specifies
|
423
|
-
a file glob to use to find files, _excluding_ the
|
424
|
-
suffix. Useful values include -glob=* and -glob=**/*.
|
425
|
-
The -default option specifies a default argument (not
|
426
|
-
a full path). If it is specified as -default=model(),
|
427
|
-
-default=controller(), or -default=both(), the current
|
428
|
-
model, controller, or both (as with :Rintegrationtest)
|
429
|
-
is used as a default.
|
430
|
-
|
431
|
-
*rails-:Rcommand*
|
432
|
-
:Rcommand Obsolete alias for |:Rnavcommand|.
|
433
|
-
|
434
|
-
Examples: >
|
435
|
-
Rnavcommand api app/apis -glob=**/* -suffix=_api.rb
|
436
|
-
Rnavcommand config config -glob=*.* -suffix= -default=routes.rb
|
437
|
-
Rnavcommand concern app/concerns -glob=**/*
|
438
|
-
Rnavcommand exemplar test/exemplars spec/exemplars -glob=**/*
|
439
|
-
\ -default=model() -suffix=_exemplar.rb
|
440
|
-
|
441
|
-
Finally, one Vim feature that proves helpful in conjunction with all of the
|
442
|
-
above is |CTRL-^|. This keystroke edits the previous file, and is helpful to
|
443
|
-
back out of any of the above commands.
|
444
|
-
|
445
|
-
RAKE *rails-rake*
|
446
|
-
|
447
|
-
Rake integration happens through the :Rake command.
|
448
|
-
|
449
|
-
*rails-:Rake*
|
450
|
-
:[range]Rake {targets} Calls |:make!| {targets} (with 'makeprg' being rake,
|
451
|
-
or `bundle exec rake` if bundler.vim is active) and
|
452
|
-
opens the quickfix window if there were any errors.
|
453
|
-
An argument of "-" reruns the last task. If {targets}
|
454
|
-
are omitted, :Rake defaults to something sensible as
|
455
|
-
described below. Giving a line number argument may
|
456
|
-
affect that default.
|
457
|
-
|
458
|
-
*rails-:Rake!*
|
459
|
-
:[range]Rake! {targets} Called with a bang, :Rake will forgo opening the
|
460
|
-
quickfix window.
|
461
|
-
|
462
|
-
*rails-rake-defaults*
|
463
|
-
|
464
|
-
Generally, the default task is one that runs the test you'd expect. For
|
465
|
-
example, if you're in a view in an RSpec application, the view spec is run,
|
466
|
-
but if it's a Test::Unit application, the functional test for the
|
467
|
-
corresponding controller is run. The following table lists the most
|
468
|
-
interesting mappings:
|
469
|
-
|
470
|
-
File Task ~
|
471
|
-
unit test test:units TEST=...
|
472
|
-
functional test test:functionals TEST=...
|
473
|
-
integration test test:integration TEST=...
|
474
|
-
spec spec SPEC=...
|
475
|
-
feature cucumber FEATURE=...
|
476
|
-
model test:units TEST=... spec SPEC=...
|
477
|
-
controller test:functionals TEST=... spec SPEC=...
|
478
|
-
helper test:functionals TEST=... spec SPEC=...
|
479
|
-
view test:functionals TEST=... spec SPEC=...
|
480
|
-
fixtures db:fixtures:load FIXTURES=...
|
481
|
-
migration db:migrate VERSION=...
|
482
|
-
config/routes.rb routes
|
483
|
-
db/seeds.rb db:seed
|
484
|
-
|
485
|
-
Additionally, when :Rake is given a line number (e.g., :.Rake), the following
|
486
|
-
additional tasks can be invoked:
|
487
|
-
|
488
|
-
File Task ~
|
489
|
-
unit test test:units TEST=... TESTOPTS=-n...
|
490
|
-
functional test test:functionals TEST=... TESTOPTS=-n...
|
491
|
-
integration test test:integration TEST=... TESTOPTS=-n...
|
492
|
-
spec spec SPEC=...:...
|
493
|
-
feature cucumber FEATURE=...:...
|
494
|
-
controller routes CONTROLLER=...
|
495
|
-
fixtures db:fixtures:identify LABEL=...
|
496
|
-
migration in self.up db:migrate:up VERSION=...
|
497
|
-
migration in self.down db:migrate:down VERSION=...
|
498
|
-
migration elsewhere db:migrate:redo VERSION=...
|
499
|
-
task ... (try to guess currently edited declaration)
|
500
|
-
|
501
|
-
Finally, you can override the default task with a comment like "# rake ..."
|
502
|
-
before the method pointed to by [range] or at the top of the file.
|
503
|
-
|
504
|
-
SCRIPT WRAPPERS *rails-scripts*
|
505
|
-
|
506
|
-
The following commands are wrappers around the scripts in the script directory
|
507
|
-
of the Rails application. Most have extra features beyond calling the script.
|
508
|
-
A limited amount of completion with <Tab> is supported.
|
509
|
-
|
510
|
-
*rails-:Rscript*
|
511
|
-
:Rscript {script} {options}
|
512
|
-
Call ruby script/{script} {options}. Defaults to
|
513
|
-
calling script/console.
|
514
|
-
|
515
|
-
*rails-:Rconsole*
|
516
|
-
:Rconsole {options} Obsolete. Call |:Rscript| instead.
|
517
|
-
|
518
|
-
*rails-:Rrunner*
|
519
|
-
:[range]Rrunner {code} Executes {code} with script/runner. Differs from
|
520
|
-
:Rscript runner {code} in that the code is passed as
|
521
|
-
one argument. Also, |system()| is used instead of
|
522
|
-
|:!|. This is to help eliminate annoying "Press
|
523
|
-
ENTER" prompts. If a line number is given in the
|
524
|
-
range slot, the output is pasted into the buffer after
|
525
|
-
that line.
|
526
|
-
|
527
|
-
*rails-:Rp*
|
528
|
-
:[range]Rp {code} Like :Rrunner, but call the Ruby p method on the
|
529
|
-
result. Literally "p begin {code} end".
|
530
|
-
|
531
|
-
*rails-:Rpp* *rails-:Ry*
|
532
|
-
:[range]Rpp {code} Like :Rp, but with pp (pretty print) or y (YAML
|
533
|
-
:[range]Ry {code} output).
|
534
|
-
|
535
|
-
*rails-:Rgenerate*
|
536
|
-
:Rgenerate {options} Calls script/generate {options}, and then edits the
|
537
|
-
first file generated.
|
538
|
-
|
539
|
-
*rails-:Rdestroy*
|
540
|
-
:Rdestroy {options} Calls script/destroy {options}.
|
541
|
-
|
542
|
-
*rails-:Rserver*
|
543
|
-
:Rserver {options} Launches script/server {options} in the background.
|
544
|
-
On win32, this means |!start|. On other systems, this
|
545
|
-
uses the --daemon option.
|
546
|
-
|
547
|
-
*rails-:Rserver!*
|
548
|
-
:Rserver! {options} Same as |:Rserver|, only first attempts to kill any
|
549
|
-
other server using the same port. On non-Windows
|
550
|
-
systems, lsof must be installed for this to work.
|
551
|
-
|
552
|
-
REFACTORING HELPERS *rails-refactoring*
|
553
|
-
|
554
|
-
A few features are dedicated to helping you refactor your code.
|
555
|
-
|
556
|
-
Partial Extraction ~
|
557
|
-
*rails-partials*
|
558
|
-
|
559
|
-
The :Rextract command can be used to extract a partial to a new file.
|
560
|
-
|
561
|
-
*rails-:Rextract*
|
562
|
-
:[range]Rextract [{controller}/]{name}
|
563
|
-
Create a {name} partial from [range] lines (default:
|
564
|
-
current line).
|
565
|
-
|
566
|
-
*rails-:Rpartial*
|
567
|
-
:[range]Rpartial [{controller}/]{name}
|
568
|
-
Obsolete alias for :Rextract.
|
569
|
-
|
570
|
-
If this is your file, in app/views/blog/show.html.erb: >
|
571
|
-
|
572
|
-
1 <div>
|
573
|
-
2 <h2><%= @post.title %></h2>
|
574
|
-
3 <p><%= @post.body %></p>
|
575
|
-
4 </div>
|
576
|
-
|
577
|
-
And you issue this command: >
|
578
|
-
|
579
|
-
:2,3Rextract post
|
580
|
-
|
581
|
-
Your file will change to this: >
|
582
|
-
|
583
|
-
1 <div>
|
584
|
-
2 <%= render :partial => 'post' %>
|
585
|
-
3 </div>
|
586
|
-
|
587
|
-
And app/views/blog/_post.html.erb will now contain: >
|
588
|
-
|
589
|
-
1 <h2><%= post.title %></h2>
|
590
|
-
2 <p><%= post.body %></p>
|
591
|
-
|
592
|
-
As a special case, if the file had looked like this: >
|
593
|
-
|
594
|
-
1 <% for object in @posts -%>
|
595
|
-
2 <h2><%= object.title %></h2>
|
596
|
-
3 <p><%= object.body %></p>
|
597
|
-
4 <% end -%>
|
598
|
-
<
|
599
|
-
The end result would have been this: >
|
600
|
-
|
601
|
-
1 <%= render :partial => 'post', :collection => @posts %>
|
602
|
-
<
|
603
|
-
The easiest way to choose what to extract is to use |linewise-visual| mode.
|
604
|
-
Then, a simple >
|
605
|
-
:'<,'>Rextract blog/post
|
606
|
-
will suffice. (Note the use of a controller name in this example.)
|
607
|
-
|
608
|
-
Migration Inversion ~
|
609
|
-
*rails-migrations* *rails-:Rinvert*
|
610
|
-
:Rinvert In a migration, rewrite the self.up method into a
|
611
|
-
self.down method. If self.up is empty, the process is
|
612
|
-
reversed. This chokes on more complicated
|
613
|
-
instructions, but works reasonably well for simple
|
614
|
-
calls to create_table, add_column, and the like.
|
615
|
-
|
616
|
-
INTEGRATION *rails-integration*
|
617
|
-
|
618
|
-
Having one foot in Rails and one in Vim, rails.vim has two worlds with which
|
619
|
-
to interact.
|
620
|
-
|
621
|
-
Integration with the Vim Universe ~
|
622
|
-
*rails-vim-integration*
|
623
|
-
|
624
|
-
A handful of Vim plugins are enhanced by rails.vim. All plugins mentioned can
|
625
|
-
be found at http://www.vim.org/. Cream and GUI menus (for lack of a better
|
626
|
-
place) are also covered in this section.
|
627
|
-
|
628
|
-
*rails-:Rtree*
|
629
|
-
:Rtree [{arg}] If |NERDTree| is installed, open a tree for the
|
630
|
-
application root or the given subdirectory.
|
631
|
-
|
632
|
-
*rails-:Rdbext* *rails-dbext*
|
633
|
-
:Rdbext [{environment}] This command is only provided when the |dbext| plugin
|
634
|
-
is installed. Loads the {environment} configuration
|
635
|
-
(defaults to $RAILS_ENV or development) from
|
636
|
-
config/database.yml and uses it to configure dbext.
|
637
|
-
The configuration is cached on a per application
|
638
|
-
basis. With dbext version 8.00 and newer, this
|
639
|
-
command is called automatically when needed. When
|
640
|
-
dbext is configured, you can execute SQL directly from
|
641
|
-
Vim: >
|
642
|
-
:Select * from posts order by id desc
|
643
|
-
:Update comments set author_id = 1
|
644
|
-
<
|
645
|
-
*rails-surround*
|
646
|
-
The |surround| plugin available from vim.org enables adding and removing
|
647
|
-
"surroundings" like parentheses, quotes, and HTML tags. Even by itself, it is
|
648
|
-
quite useful for Rails development, particularly eRuby editing. When coupled
|
649
|
-
with this plugin, a few additional replacement surroundings are available in
|
650
|
-
eRuby files. See the |surround| documentation for details on how to use them.
|
651
|
-
The table below uses ^ to represent the position of the surrounded text.
|
652
|
-
|
653
|
-
Key Surrounding ~
|
654
|
-
= <%= ^ %>
|
655
|
-
- <% ^ -%>
|
656
|
-
# <%# ^ %>
|
657
|
-
<C-E> <% ^ -%>\n<% end -%>
|
658
|
-
|
659
|
-
The last surrounding is particularly useful in insert mode with the following
|
660
|
-
map in one's vimrc. Use Alt+o to open a new line below the current one. This
|
661
|
-
works nicely even in a terminal (where most alt/meta maps will fail) because
|
662
|
-
most terminals send <M-o> as <Esc>o anyways.
|
663
|
-
>
|
664
|
-
imap <M-o> <Esc>o
|
665
|
-
<
|
666
|
-
One can also use the <C-E> surrounding in a plain Ruby file to append a bare
|
667
|
-
"end" on the following line.
|
668
|
-
|
669
|
-
*rails-abolish*
|
670
|
-
Among the many features of |abolish| on vim.org is the ability to change the
|
671
|
-
inflection of the word under the cursor. For example, one can hit crs to
|
672
|
-
change from MixedCase to snake_case. This plugin adds two additional
|
673
|
-
inflections: crl for alternating between the singular and plural, and crt for
|
674
|
-
altering between tableize and classify. The latter is useful in changing
|
675
|
-
constructs like BlogPost.all to current_user.blog_posts.all and vice versa.
|
676
|
-
|
677
|
-
*rails-cream*
|
678
|
-
This plugin provides a few additional key bindings if it is running under
|
679
|
-
Cream, the user friendly editor which uses Vim as a back-end. Ctrl+Enter
|
680
|
-
finds the file under the cursor (as in |rails-gf|), and Alt+[ and Alt+] find
|
681
|
-
the alternate (|rails-alternate|) and related (|rails-related|) files.
|
682
|
-
|
683
|
-
*rails-menu*
|
684
|
-
If the GUI is running, a menu for several commonly used features is provided.
|
685
|
-
Also on this menu is a list of recently accessed projects. This list of
|
686
|
-
projects can persist across restarts if a 'viminfo' flag is set to enable
|
687
|
-
retaining certain global variables. If this interests you, add something like
|
688
|
-
the following to your vimrc: >
|
689
|
-
set viminfo^=!
|
690
|
-
<
|
691
|
-
Integration with the Rails Universe ~
|
692
|
-
*rails-rails-integration*
|
693
|
-
The general policy of rails.vim is to focus exclusively on the Ruby on Rails
|
694
|
-
core. Supporting plugins and other add-ons to Rails has the potential to
|
695
|
-
rapidly get out of hand. However, a few pragmatic exceptions have been made.
|
696
|
-
|
697
|
-
*rails-template-types*
|
698
|
-
Commands like :Rview use a hardwired list of extensions (erb, rjs, etc.)
|
699
|
-
when searching for files. In order to facilitate working with non-standard
|
700
|
-
template types, several popular extensions are featured in this list,
|
701
|
-
including haml, liquid, and mab (markaby). These extensions will disappear
|
702
|
-
once a related configuration option is added to rails.vim.
|
703
|
-
|
704
|
-
*rails-rspec*
|
705
|
-
The presence of a spec directory causes several additional behaviors to
|
706
|
-
activate. :A knows about specs and will jump to them (but Test::Unit files
|
707
|
-
still get priority). The associated controller or model of a spec is
|
708
|
-
detected, so all navigation commands should work as expected inside a spec
|
709
|
-
file. :Rake in a spec runs just that spec, and in a model, controller, or
|
710
|
-
helper, runs the associated spec.
|
711
|
-
|
712
|
-
|:Runittest| and |:Rfunctionaltest| lead double lives, handling model and
|
713
|
-
controller specs respectively. For helper and view specs, you can use
|
714
|
-
|:Rspec| or define your own navigation commands:
|
715
|
-
>
|
716
|
-
Rnavcommand spechelper spec/helpers -glob=**/*
|
717
|
-
\ -suffix=_helper_spec.rb -default=controller()
|
718
|
-
Rnavcommand specview spec/views -glob=**/* -suffix=_spec.rb
|
719
|
-
<
|
720
|
-
ABBREVIATIONS *rails-abbreviations* *rails-snippets*
|
721
|
-
|
722
|
-
Abbreviations are "snippets lite". They may later be extracted into a
|
723
|
-
separate plugin, or removed entirely.
|
724
|
-
|
725
|
-
*rails-:Rabbrev*
|
726
|
-
:Rabbrev List all Rails abbreviations.
|
727
|
-
|
728
|
-
:Rabbrev {abbr} {expn} [{extra}]
|
729
|
-
Define a new Rails abbreviation. {extra} is permitted
|
730
|
-
if and only if {expn} ends with "(".
|
731
|
-
|
732
|
-
*rails-:Rabbrev!*
|
733
|
-
:Rabbrev! {abbr} Remove an abbreviation.
|
734
|
-
|
735
|
-
Rails abbreviations differ from regular abbreviations in that they only expand
|
736
|
-
after a <C-]> (see |i_CTRL-]|) or a <Tab> (if <Tab> does not work, it is
|
737
|
-
likely mapped by another plugin). If the abbreviation ends in certain
|
738
|
-
punctuation marks, additional expansions are possible. A few examples will
|
739
|
-
hopefully clear this up (all of the following are enabled by default in
|
740
|
-
appropriate file types).
|
741
|
-
|
742
|
-
Command Sequence typed Resulting text ~
|
743
|
-
Rabbrev rp( render :partial\ => rp( render(:partial =>
|
744
|
-
Rabbrev rp( render :partial\ => rp<Tab> render :partial =>
|
745
|
-
Rabbrev vs( validates_size_of vs( validates_size_of(
|
746
|
-
Rabbrev pa[ params pa[:id] params[:id]
|
747
|
-
Rabbrev pa[ params pa<C-]> params
|
748
|
-
Rabbrev pa[ params pa.inspect params.inspect
|
749
|
-
Rabbrev AR:: ActionRecord AR::Base ActiveRecord::Base
|
750
|
-
Rabbrev :a :action\ =>\ render :a<Tab> render :action =>
|
751
|
-
|
752
|
-
In short, ( expands on (, :: expands on . and :, and [ expands on . and [.
|
753
|
-
These trailing punctuation marks are NOT part of the final abbreviation, and
|
754
|
-
you cannot have two mappings that differ only by punctuation.
|
755
|
-
|
756
|
-
You must escape spaces in your expansion, either as "\ " or as "<Space>". For
|
757
|
-
an abbreviation ending with "(", you may define where to insert the
|
758
|
-
parenthesis by splitting the expansion into two parts (divided by an unescaped
|
759
|
-
space).
|
760
|
-
|
761
|
-
Many abbreviations are provided by default: use :Rabbrev to list them. They
|
762
|
-
vary depending on the type of file (models have different abbreviations than
|
763
|
-
controllers). There is one "smart" abbreviation, :c, which expands to
|
764
|
-
":controller => ", ":collection => ", or ":conditions => " depending on
|
765
|
-
context.
|
766
|
-
|
767
|
-
SYNTAX HIGHLIGHTING *rails-syntax*
|
768
|
-
|
769
|
-
Syntax highlighting is by and large a transparent process. For the full
|
770
|
-
effect, however, you need a colorscheme which accentuates rails.vim
|
771
|
-
extensions. One such colorscheme is vividchalk, available from vim.org.
|
772
|
-
|
773
|
-
The following is a summary of the changes made by rails.vim to the standard
|
774
|
-
syntax highlighting.
|
775
|
-
|
776
|
-
*rails-syntax-keywords*
|
777
|
-
Rails specific keywords are highlighted in a filetype specific manner. For
|
778
|
-
example, in a model, has_many is highlighted, whereas in a controller,
|
779
|
-
before_filter is highlighted. A wide variety of syntax groups are used but
|
780
|
-
they all link by default to railsMethod.
|
781
|
-
|
782
|
-
If you feel a method has been wrongfully omitted, submit it to the
|
783
|
-
|rails-plugin-author|.
|
784
|
-
|
785
|
-
*rails-syntax-classes*
|
786
|
-
Models, helpers, and controllers are given special highlighting. Depending on
|
787
|
-
the version of Vim installed, you may need a rails.vim aware colorscheme in
|
788
|
-
order to see this. Said colorscheme needs to provide highlighting for the
|
789
|
-
railsUserClass syntax group.
|
790
|
-
|
791
|
-
The class names are determined by camelizing filenames from certain
|
792
|
-
directories of your application. If app/models/line_item.rb exists, the class
|
793
|
-
"LineItem" will be highlighted.
|
794
|
-
|
795
|
-
The list of classes is refreshed automatically after certain commands like
|
796
|
-
|:Rgenerate|. Use |:Rrefresh| to trigger the process manually.
|
797
|
-
|
798
|
-
*rails-syntax-assertions*
|
799
|
-
If you define custom assertions in test_helper.rb, these will be highlighted
|
800
|
-
in your tests. These are found by scanning test_helper.rb for lines of the
|
801
|
-
form " def assert_..." and extracting the method name. The railsUserMethod
|
802
|
-
syntax group is used. The list of assertions can be refreshed with
|
803
|
-
|:Rrefresh|.
|
804
|
-
|
805
|
-
*rails-syntax-strings*
|
806
|
-
In the following line of code, the "?" in the conditions clause and the "ASC"
|
807
|
-
in the order clause will be highlighted: >
|
808
|
-
Post.find(:all, :conditions => ["body like ?","%e%"], :order => "title ASC")
|
809
|
-
<
|
810
|
-
A string literal using %Q<> or %<> delimiters will have its contents
|
811
|
-
highlighted as HTML. This is sometimes useful when writing helpers. >
|
812
|
-
link = %<<a href="http://www.vim.org">Vim</a>>
|
813
|
-
<
|
814
|
-
*rails-syntax-yaml*
|
815
|
-
YAML syntax highlighting has been extended to highlight eRuby, which can be
|
816
|
-
used in most Rails YAML files (including database.yml and fixtures).
|
817
|
-
|
818
|
-
MANAGED VIM OPTIONS *rails-options*
|
819
|
-
|
820
|
-
The following options are set local to buffers where the plugin is active.
|
821
|
-
|
822
|
-
*rails-'shiftwidth'* *rails-'sw'*
|
823
|
-
*rails-'softtabstop'* *rails-'sts'*
|
824
|
-
*rails-'expandtab'* *rails-'et'*
|
825
|
-
A value of 2 is used for 'shiftwidth' (and 'softtabstop'), and 'expandtab' is
|
826
|
-
enabled. This is a strong convention in Rails, so the conventional wisdom
|
827
|
-
that this is a user preference has been ignored.
|
828
|
-
|
829
|
-
*rails-'path'* *rails-'pa'*
|
830
|
-
All the relevant directories from your application are added to your 'path'.
|
831
|
-
This makes it easy to access a buried file: >
|
832
|
-
:find blog_controller.rb
|
833
|
-
<
|
834
|
-
*rails-'suffixesadd'* *rails-'sua'*
|
835
|
-
This is filetype dependent, but typically includes .rb, .rake, and several
|
836
|
-
others. This allows shortening the above example: >
|
837
|
-
:find blog_controller
|
838
|
-
<
|
839
|
-
*rails-'includeexpr'* *rails-'inex'*
|
840
|
-
The 'includeexpr' option is set to enable the magic described in |rails-gf|.
|
841
|
-
|
842
|
-
*rails-'filetype'* *rails-'ft'*
|
843
|
-
The 'filetype' is sometimes adjusted for Rails files. Most notably, *.rxml
|
844
|
-
and *.rjs are treated as Ruby files, and files that have been falsely
|
845
|
-
identified as Mason sources are changed back to eRuby files (but only when
|
846
|
-
they are part of a Rails application).
|
847
|
-
|
848
|
-
*rails-'completefunc'* *rails-'cfu'*
|
849
|
-
A 'completefunc' is provided (if not already set). It is very simple, as it
|
850
|
-
uses syntax highlighting to make its guess. See |i_CTRL-X_CTRL-U|.
|
851
|
-
|
852
|
-
CONFIGURATION *rails-configuration*
|
853
|
-
|
854
|
-
Very little configuration is actually required; this plugin automatically
|
855
|
-
detects your Rails application and adjusts Vim sensibly.
|
856
|
-
|
857
|
-
*rails-:autocmd* *rails-autocommands*
|
858
|
-
If you would like to set your own custom Vim settings whenever a Rails file is
|
859
|
-
loaded, you can use an autocommand like the following in your vimrc: >
|
860
|
-
autocmd User Rails silent! Rlcd
|
861
|
-
autocmd User Rails map <buffer> <F9> :Rake<CR>
|
862
|
-
You can also have autocommands that only apply to certain types of files.
|
863
|
-
These are based off the information shown when running the |:Rails!|
|
864
|
-
command, with hyphens changed to periods. A few examples: >
|
865
|
-
autocmd User Rails.controller* iabbr <buffer> wsn wsdl_service_name
|
866
|
-
autocmd User Rails.model.arb* iabbr <buffer> vfo validates_format_of
|
867
|
-
autocmd User Rails.view.erb* imap <buffer> <C-Z> <%= %><C-O>3h
|
868
|
-
End all such Rails autocommands with asterisks, even if you have an exact
|
869
|
-
specification, to allow for more specific subtypes to be added in the future.
|
870
|
-
There is also a filename matching syntax: >
|
871
|
-
autocmd User Rails/config/environment.rb Rabbrev c config
|
872
|
-
autocmd User Rails/**/foo_bar.rb Rabbrev FB:: FooBar
|
873
|
-
Use the filetype based syntax whenever possible, reserving the filename based
|
874
|
-
syntax for more advanced cases.
|
875
|
-
|
876
|
-
*macros/rails.vim*
|
877
|
-
If you have several commands to run on initialization for all file types, they
|
878
|
-
can be placed in a "macros/rails.vim" file in the 'runtimepath' (for example,
|
879
|
-
"~/.vim/macros/rails.vim"). This file is sourced by rails.vim each time a
|
880
|
-
Rails file is loaded.
|
881
|
-
|
882
|
-
*config/rails.vim*
|
883
|
-
If you have settings particular to a specific project, they can be put in a
|
884
|
-
config/rails.vim file in the root directory of the application. The file is
|
885
|
-
sourced in the |sandbox| for security reasons.
|
886
|
-
|
887
|
-
*rails-:Rset*
|
888
|
-
:Rset {option}[={value}]
|
889
|
-
Query or set a local option. This command may be
|
890
|
-
called directly, from an autocommand, or from
|
891
|
-
config/rails.vim.
|
892
|
-
|
893
|
-
Options may be set in one of four scopes, which may be indicated by an
|
894
|
-
optional prefix. These scopes determine how broadly an option will apply.
|
895
|
-
Generally, the default scope is sufficient.
|
896
|
-
|
897
|
-
Scope Description ~
|
898
|
-
a: All files in one Rails application
|
899
|
-
b: Buffer (file) specific
|
900
|
-
g: Global to all applications
|
901
|
-
l: Local to method (same as b: in non-Ruby files)
|
902
|
-
|
903
|
-
Options are shown below with their default scope, which should be omitted.
|
904
|
-
While you may override the scope with a prefix, this is rarely necessary and
|
905
|
-
oftentimes useless. (For example, setting g:task is useless because the
|
906
|
-
default rake task will apply before considering this option.)
|
907
|
-
|
908
|
-
Option Meaning ~
|
909
|
-
b:alternate Custom alternate file for :A, relative to the Rails root
|
910
|
-
b:controller Default controller for certain commands (e.g., :Rhelper)
|
911
|
-
b:model Default model for certain commands (e.g., :Rfixtures)
|
912
|
-
l:related Custom related file for :R, relative to the Rails root
|
913
|
-
a:root_url Root URL for commands like :Rpreview
|
914
|
-
|
915
|
-
Examples: >
|
916
|
-
:Rset root_url=http://localhost:12345
|
917
|
-
:Rset related=app/views/blog/edit.html.erb
|
918
|
-
<
|
919
|
-
*rails-modelines*
|
920
|
-
If |g:rails_modelines| is enabled, these options can also be set from
|
921
|
-
modelines near the beginning or end of the file. These modelines will always
|
922
|
-
set buffer-local options; scope should never be specified. Examples: >
|
923
|
-
# Rset task=db:schema:load
|
924
|
-
<%# Rset alternate=app/views/layouts/application.html.erb %>
|
925
|
-
Modelines can also be local to a method. Example: >
|
926
|
-
def test_comment
|
927
|
-
# rset alternate=app/models/comment.rb
|
928
|
-
These two forms differ only in case.
|
929
|
-
|
930
|
-
Modelines are deprecated.
|
931
|
-
|
932
|
-
GLOBAL SETTINGS *rails-global-settings*
|
933
|
-
|
934
|
-
A few global variables control the behavior of this plugin. In general, they
|
935
|
-
can be enabled by setting them to 1 in your vimrc, and disabled by setting
|
936
|
-
them to 0. >
|
937
|
-
let g:rails_some_option=1
|
938
|
-
let g:rails_some_option=0
|
939
|
-
Most of these seldom need to be used. So seldom, in fact, that you should
|
940
|
-
notify the |rails-plugin-author| if you find any of them useful, as nearly all
|
941
|
-
are being considered for removal.
|
942
|
-
|
943
|
-
*g:loaded_rails* >
|
944
|
-
let g:loaded_rails=1
|
945
|
-
Set this include guard to prevent the plugin from being loaded.
|
946
|
-
|
947
|
-
*g:rails_abbreviations*
|
948
|
-
Enable Rails abbreviations. See |rails-abbreviations|. Enabled by default.
|
949
|
-
|
950
|
-
*g:rails_ctags_arguments* >
|
951
|
-
let g:rails_ctags_arguments='--languages=-javascript'
|
952
|
-
Additional arguments to pass to ctags from |:Rtags|. Defaults to ignoring
|
953
|
-
JavaScript files, since ctags has a tendency to choke on those.
|
954
|
-
|
955
|
-
*g:rails_default_file* >
|
956
|
-
let g:rails_default_file='config/database.yml'
|
957
|
-
File to load when a new Rails application is created, or when loading an
|
958
|
-
existing project from the menu. Defaults to the README.
|
959
|
-
|
960
|
-
*rails-screen* *g:rails_gnu_screen* >
|
961
|
-
let g:rails_gnu_screen=1
|
962
|
-
Use GNU Screen or Tmux (if it is running) to launch |:Rscript| console and
|
963
|
-
|:Rserver| in the background. Enabled by default.
|
964
|
-
|
965
|
-
*g:rails_history_size* >
|
966
|
-
let g:rails_history_size=5
|
967
|
-
Number of projects to remember. Set to 0 to disable. See |rails-menu| for
|
968
|
-
information on retaining these projects across a restart.
|
969
|
-
|
970
|
-
*g:rails_mappings* >
|
971
|
-
let g:rails_mappings=1
|
972
|
-
Enables a few mappings (mostly for |rails-navigation|). Enabled by default.
|
973
|
-
|
974
|
-
*g:rails_modelines* >
|
975
|
-
let g:rails_modelines=1
|
976
|
-
Enable modelines like the following: >
|
977
|
-
# Rset task=db:schema:load
|
978
|
-
Modelines set buffer-local options using the :Rset command.
|
979
|
-
Also enables method specific modelines (note the case difference): >
|
980
|
-
def show
|
981
|
-
# rset preview=blog/show/1
|
982
|
-
Modelines are deprecated and disabled by default.
|
983
|
-
|
984
|
-
*g:rails_menu* >
|
985
|
-
let g:rails_menu=1
|
986
|
-
When 2, a Rails menu is created. When 1, this menu is a submenu under the
|
987
|
-
Plugin menu. The default is 1 except on MacVim, where reports of weird
|
988
|
-
terminal output have led to it being disabled by default.
|
989
|
-
|
990
|
-
*g:rails_url* >
|
991
|
-
let g:rails_url='http://localhost:3000/'
|
992
|
-
Used for the |:Rpreview| command. Default is as shown above. Overridden by
|
993
|
-
b:rails_url.
|
994
|
-
|
995
|
-
*g:rails_syntax* >
|
996
|
-
let g:rails_syntax=1
|
997
|
-
When enabled, this tweaks the syntax highlighting to be more Rails friendly.
|
998
|
-
Enabled by default. See |rails-syntax|.
|
999
|
-
|
1000
|
-
*rails-tabs* *g:rails_tabstop* >
|
1001
|
-
let g:rails_tabstop=4
|
1002
|
-
This option now requires the plugin railstab.vim from vim.org:
|
1003
|
-
http://www.vim.org/scripts/script.php?script_id=2253
|
1004
|
-
|
1005
|
-
If your goal is simply just override this plugin's settings and use your own
|
1006
|
-
custom 'shiftwidth', adjust things manually in an autocommand: >
|
1007
|
-
autocmd User Rails set sw=4 sts=4 noet
|
1008
|
-
This is highly discouraged: don't fight Rails.
|
1009
|
-
|
1010
|
-
ABOUT *rails-about* *rails-plugin-author*
|
1011
|
-
|
1012
|
-
This plugin was written by Tim Pope. Email all comments, complaints, and compliments to him at vim at tpope. org.
|
1013
|
-
|
1014
|
-
The latest stable version can be found at
|
1015
|
-
http://www.vim.org/scripts/script.php?script_id=1567
|
1016
|
-
|
1017
|
-
Bugs can be reported and the very latest development version can be retrieved
|
1018
|
-
from GitHub:
|
1019
|
-
https://github.com/tpope/vim-rails
|
1020
|
-
git clone git://github.com/tpope/vim-rails.git
|
1021
|
-
|
1022
|
-
vim:tw=78:ts=8:ft=help:norl:
|