Skip to content

Commit d865c39

Browse files
committed
Rearrange help
1 parent e567014 commit d865c39

File tree

1 file changed

+137
-144
lines changed

1 file changed

+137
-144
lines changed

doc/rails.txt

Lines changed: 137 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
Author: Tim Pope <http://tpo.pe/>
44

55
|rails-introduction| Introduction and Feature Summary
6-
|rails-commands| General Commands
76
|rails-navigation| Navigation
87
|rails-gf| File Under Cursor - gf
98
|rails-alternate-related| Alternate and Related Files
109
|rails-type-navigation| File Type Commands
10+
|rails-exec| Executable Wrappers
1111
|rails-rake| Rake
12-
|rails-scripts| Script Wrappers
1312
|rails-refactoring| Refactoring Helpers
1413
|rails-partials| Partial Extraction
1514
|rails-migrations| Migration Inversion
15+
|rails-misc| Miscellaneous Commands
1616
|rails-integration| Integration
1717
|rails-vim-integration| Integration with the Vim Universe
1818
|rails-rails-integration| Integration with the Rails Universe
@@ -25,10 +25,6 @@ Author: Tim Pope <http://tpo.pe/>
2525
|rails-about| About rails.vim
2626
|rails-license| License
2727

28-
This plugin is only available if 'compatible' is not set.
29-
30-
{Vi does not have any of this}
31-
3228
INTRODUCTION *rails-introduction* *rails*
3329

3430
Whenever you edit a file in a Rails application, this plugin will be
@@ -38,76 +34,12 @@ buffer-specific commands.
3834
If you are in a hurry to get started, with a minimal amount of reading, you
3935
are encouraged to at least skim through the headings and command names in this
4036
file, to get a better idea of what is offered. If you only read one thing,
41-
make sure it is the navigation section: |rails-navigation|.
42-
43-
GENERAL COMMANDS *rails-commands*
44-
45-
All commands are buffer local, unless otherwise stated. This means you must
46-
actually edit a file from a Rails application.
47-
48-
*rails-:Rails-new*
49-
:Rails new {directory} The only global command. Invokes "rails new
50-
{directory}" and loads the generated files into the
51-
quickfix list.
52-
53-
*rails-:Clogfile*
54-
:Clogfile [environment] Load the log file for the given environment using
55-
|:cgetfile|, open the quickfix window, and jump to the
56-
last line. |R| is remapped to reload the list, and
57-
|G| remapped to do the same before it's usual behavior
58-
of jumping to the last line. If the delay in loading
59-
is too long, you might consider :Rake log:clear.
60-
61-
*rails-:Rlog*
62-
:Rlog [environment] Open the log file in the preview window using
63-
|:pedit|. Deprecated in favor if |rails-:Clog|.
64-
65-
*rails-:Preview* *rails-:Rpreview*
66-
:Preview [path] Open the given path for the current app in a browser.
67-
The host and port are determined by applying some
68-
netstat/lsof trickery to the current server pid. If
69-
no server is running, Pow is consulted, and if all
70-
else fails, a default of localhost:3000 is used. If
71-
no path is given, a default is used based on the
72-
current file and the application's routes. The
73-
default is overridden by comments like the following
74-
that are either before the current method call or at
75-
the top of the file: >
76-
77-
# GET /users
78-
# PUT /users/1
79-
<
80-
If it's not using the right browser, define an OpenURL
81-
command:
82-
>
83-
:command -bar -nargs=1 OpenURL :!open <args>
84-
<
85-
*rails-:Preview!* *rails-:Rpreview!*
86-
:Preview! [path] Like :Preview, but open the path inside Vim using
87-
|netrw| instead.
88-
89-
*rails-:Rrefresh*
90-
:Rrefresh Refreshes cached settings.
91-
92-
*rails-:Rrefresh!*
93-
:Rrefresh! As above, and also reloads rails.vim.
94-
95-
*rails-:Cd* *rails-:Rcd*
96-
:Cd [{directory}] |:cd| to /path/to/railsapp/{directory}.
97-
98-
*rails-:Lcd* *rails-:Rlcd*
99-
:Lcd [{directory}] |:lcd| to /path/to/railsapp/{directory}.
100-
101-
*rails-:Ctags* *rails-:Rtags*
102-
:Ctags Calls ctags -R on the current application root.
103-
Exuberant ctags must be installed. Additional
104-
arguments can be passed to ctags with
105-
|g:rails_ctags_arguments|.
37+
make sure it is the navigation section.
10638

10739
NAVIGATION *rails-navigation*
10840

109-
Navigation is where the real power of this plugin lies. Efficient use of the
110-
following features will greatly ease navigating the Rails file structure.
41+
Navigating the twisted file hierarchy of Rails projects is what initially
42+
inspired the creation of this plugin.
11143

11244
The standard Rails load path is prepended to 'path', enabling |:find| to work:
11345
>
@@ -352,27 +284,91 @@ Finally, one Vim feature that proves helpful in conjunction with all of the
352284
above is |CTRL-^|. This keystroke edits the previous file, and is helpful to
353285
back out of any of the above commands.
354286

287+
EXECUTABLE WRAPPERS *rails-exec*
288+
289+
The following commands are wrappers around the `rails` executable and
290+
subcommands.
291+
292+
*rails-:Rails*
293+
:Rails {command} [options]
294+
Depending on the Rails version, invoke one of
295+
"bin/rails {command}", "script/rails {command}", or
296+
"script/{command}". Unless the command is "console",
297+
"dbconsole", or "server", the results are loaded into
298+
the quickfix list using the "rails" |:compiler|
299+
included with the plugin. With no command, runs the
300+
default rake task. See |rails-default-task|. Unlike
301+
other commands, :Rails is available globally, for use
302+
with the "new" subcommand.
303+
304+
*rails-:Rscript*
305+
:Rscript {command} [options]
306+
Deprecated alias for |:Rails| {command}. Defaults to
307+
calling |:Console|.
308+
309+
*rails-:Console*
310+
:Console {options} Launch rails console {options}. If dispatch.vim's
311+
:Start is available, that is used. Otherwise,
312+
executes directly in the foreground.
313+
314+
*rails-:Generate* *rails-:Rgenerate*
315+
:Generate {options} Invoke rails generate {options} and loads the
316+
generated files into the quickfix list. Use ! to
317+
surpress jumping to the first file.
318+
319+
*rails-:Destroy* *rails-:Rdestroy*
320+
:Destroy {options} Invoke rails destroy {options} and loads the destroyed
321+
files into the quickfix list.
322+
323+
*rails-:Server* *rails-:Rserver*
324+
:Server {options} Launch rails server {options} in the background. If
325+
dispatch.vim's :Start is available, that is used.
326+
Otherwise, the --daemon option is passed in.
327+
328+
*rails-:Server!* *rails-:Rserver!*
329+
:Server! {options} Kill the pid found in tmp/pids/server.pid and then
330+
invoke |:server|.
331+
332+
*rails-:Runner* *rails-:Rrunner*
333+
:[range]Runner [file] Run the given file or code with rails runner and load
334+
:Runner {code} the results in to the quickfix list, using the error
335+
parser from the "ruby" |:compiler|. If the file looks
336+
like a test, spec, or cucumber feature, the
337+
"rubyunit", "rspec", or "cucumber" |:compiler| will be
338+
used instead. If provided, [range] is passed to the
339+
test runner to restrict execution to a particular
340+
line. With no argument, defaults to running the test
341+
for the current file.
342+
343+
*rails-:Rp*
344+
:[range]Rp {code} Use rails runner to execute "p begin {code} end" and
345+
echo the result.
346+
347+
*rails-:Rpp*
348+
:[range]Rpp {code} Like :Rp, but with pp (pretty print).
349+
355350
RAKE *rails-rake*
356351

357352
Rake integration happens through the :Rake command.
358353

359354
*rails-:Rake*
360355
:[range]Rake {targets} Calls |:make!| {targets} (with 'makeprg' being rake)
361356
and opens the quickfix window if there were any
362-
errors. An argument of "-" reruns the last task. If
363-
{targets} are omitted, :Rake defaults to something
364-
sensible as described below. Giving a line number
365-
argument may affect that default.
357+
errors. If dispatch.vim's |:Make| is available that
358+
is used instead. An argument of "-" reruns the last
359+
task. If {targets} are omitted, :Rake defaults to
360+
something sensible as described below.
366361

367362
*rails-:Rake!*
368363
:[range]Rake! {targets} Called with a bang, :Rake will forgo opening the
369364
quickfix window.
370365

371-
*rails-rake-defaults*
366+
*rails-default-task*
372367

373-
Generally, the default task is one that runs the test you'd expect. For
374-
example, if you're in a view in an RSpec application, the view spec is run,
375-
but if it's a Test::Unit application, the functional test for the
368+
Invoking |rails-:Rails| or |rails-:Rake| with no arguments runs a default
369+
task. Generally, the default task is one that runs the test you'd expect.
370+
For example, if you're in a view in an RSpec application, the view spec is
371+
run, but if it's a Test::Unit application, the functional test for the
376372
corresponding controller is run. The following table lists the most
377373
interesting mappings:
378374

@@ -393,8 +389,8 @@ db/schema.rb db:migrate:status
393389
db/seeds.rb db:seed
394390
README about
395391

396-
Additionally, when :Rake is given a line number (e.g., :.Rake), the following
397-
additional tasks can be invoked:
392+
Additionally, when :Rails or :Rake is given a line number (e.g., :.Rake), the
393+
following additional tasks can be invoked:
398394

399395
File Task ~
400396
unit test test:units TEST=... TESTOPTS=-n...
@@ -411,65 +407,6 @@ task ... (try to guess currently edited declaration)
411407
Finally, you can override the default task with a comment like "# rake ..."
412408
before the method pointed to by [range] or at the top of the file.
413409

414-
SCRIPT WRAPPERS *rails-scripts*
415-
416-
The following commands are wrappers around the scripts in the script directory
417-
of the Rails application. Most have extra features beyond calling the script.
418-
A limited amount of completion with <Tab> is supported.
419-
420-
421-
*rails-:Rails*
422-
:Rails {command} [options]
423-
Depending on the Rails version, invoke one of
424-
"bin/rails {command}", "script/rails {command}", or
425-
"script/{command}".
426-
427-
*rails-:Rscript*
428-
:Rscript {command} [options]
429-
Deprecated alias for |:Rails| {command}. Defaults to
430-
calling |:Console|.
431-
432-
*rails-:Console*
433-
:Console {options} Launch rails console {options}. If dispatch.vim's
434-
:Start is available, that is used. Otherwise,
435-
executes directly in the foreground.
436-
437-
*rails-:Runner* *rails-:Rrunner*
438-
:[range]Runner [file] Run the given file or code with rails runner and load
439-
:Runner {code} the results in to the quickfix list, using the error
440-
parser from the "ruby" |:compiler|. If the file looks
441-
like a test, spec, or cucumber feature, the
442-
"rubyunit", "rspec", or "cucumber" |:compiler| will be
443-
used instead. If provided, [range] is passed to the
444-
test runner to restrict execution to a particular
445-
line. With no argument, defaults to running the test
446-
for the current file.
447-
448-
*rails-:Rp*
449-
:[range]Rp {code} Use rails runner to execute "p begin {code} end" and
450-
echo the result.
451-
452-
*rails-:Rpp*
453-
:[range]Rpp {code} Like :Rp, but with pp (pretty print).
454-
455-
*rails-:Generate* *rails-:Rgenerate*
456-
:Generate {options} Invoke rails generate {options} and loads the
457-
generated files into the quickfix list. Use ! to
458-
surpress jumping to the first file.
459-
460-
*rails-:Destroy* *rails-:Rdestroy*
461-
:Destroy {options} Invoke rails destroy {options} and loads the destroyed
462-
files into the quickfix list.
463-
464-
*rails-:Server* *rails-:Rserver*
465-
:Server {options} Launch rails server {options} in the background. If
466-
dispatch.vim's :Start is available, that is used.
467-
Otherwise, the --daemon option is passed in.
468-
469-
*rails-:Server!* *rails-:Rserver!*
470-
:Server! {options} Kill the pid found in tmp/pids/server.pid and then
471-
invoke |:Rserver|.
472-
473410
REFACTORING HELPERS *rails-refactoring*
474411

475412
A few features are dedicated to helping you refactor your code.
@@ -503,7 +440,7 @@ If this is your file, in app/views/blog/show.html.erb: >
503440
504441
And you issue this command: >
505442
506-
:2,3Rextract post
443+
:2,3Extract post
507444
508445
Your file will change to this: >
509446
@@ -518,7 +455,7 @@ And app/views/blog/_post.html.erb will now contain: >
518455
<
519456
The easiest way to choose what to extract is to use |linewise-visual| mode.
520457
Then, a simple >
521-
:'<,'>Rextract blog/post
458+
:'<,'>Extract blog/post
522459
will suffice. (Note the use of a controller name in this example.)
523460

524461
Migration Inversion ~
@@ -532,6 +469,62 @@ Migration Inversion ~
532469
support for reversible migration definitions, so this
533470
command is deprecated and no longer maintained.
534471

472+
MISCELLANEOUS COMMANDS *rails-misc*
473+
474+
*rails-:Clogfile*
475+
:Clogfile [environment] Load the log file for the given environment using
476+
|:cgetfile|, open the quickfix window, and jump to the
477+
last line. |R| is remapped to reload the list, and
478+
|G| remapped to do the same before it's usual behavior
479+
of jumping to the last line. If the delay in loading
480+
is too long, you might consider :Rake log:clear.
481+
482+
*rails-:Rlog*
483+
:Rlog [environment] Open the log file in the preview window using
484+
|:pedit|. Deprecated in favor if |rails-:Clog|.
485+
486+
*rails-:Preview* *rails-:Rpreview*
487+
:Preview [path] Open the given path for the current app in a browser.
488+
The host and port are determined by applying some
489+
netstat/lsof trickery to the current server pid. If
490+
no server is running, Pow is consulted, and if all
491+
else fails, a default of localhost:3000 is used. If
492+
no path is given, a default is used based on the
493+
current file and the application's routes. The
494+
default is overridden by comments like the following
495+
that are either before the current method call or at
496+
the top of the file: >
497+
498+
# GET /users
499+
# PUT /users/1
500+
<
501+
If it's not using the right browser, define an OpenURL
502+
command:
503+
>
504+
:command -bar -nargs=1 OpenURL :!open <args>
505+
<
506+
*rails-:Preview!* *rails-:Rpreview!*
507+
:Preview! [path] Like :Preview, but open the path inside Vim using
508+
|netrw| instead.
509+
510+
*rails-:Rrefresh*
511+
:Rrefresh Refreshes cached settings.
512+
513+
*rails-:Rrefresh!*
514+
:Rrefresh! As above, and also reloads rails.vim.
515+
516+
*rails-:Cd* *rails-:Rcd*
517+
:Cd [{directory}] |:cd| to /path/to/railsapp/{directory}.
518+
519+
*rails-:Lcd* *rails-:Rlcd*
520+
:Lcd [{directory}] |:lcd| to /path/to/railsapp/{directory}.
521+
522+
*rails-:Ctags* *rails-:Rtags*
523+
:Ctags Calls ctags -R on the current application root.
524+
Exuberant ctags must be installed. Additional
525+
arguments can be passed to ctags with
526+
|g:rails_ctags_arguments|.
527+
535528
INTEGRATION *rails-integration*
536529

537530
Having one foot in Rails and one in Vim, rails.vim has two worlds with which

0 commit comments

Comments
 (0)