I'm writing a Ruby script and I'm too lazy to type
the indentations and linefeeds correctly.
The Zeus for Windows IDE will do auto-indenting.
It also does things like Ruby syntax highlighting, code
folding etc, it also has a code templates feature which
makes it possible to semi-automate things like for/while
coding constructs:
I use vim a lot, but have never asked it to indent my code for me. And
judging by the results that I just got, I won't do so again any time soon.
At least on my machine, with what is, admittedly, probably old and outdated
Ruby support, the results are awful.
Kirk Haines
···
On Sunday 09 October 2005 11:05 am, Jacob Quinn Shenker wrote:
Ok! Just pop it open, then type 'G=gg'. See more Vim indenting tricks at tips : vim online
Vim's Ruby indentation has actually worked very well for me, although
the syntax coloring gets confused at times. And yes, Vim detects the
.rb and indented accordingly.
Jacob
···
On 10/9/05, Phlip <phlipcpp@yahoo.com> wrote:
Martin DeMello wrote:
> gg=G
Thanks. That did... something. Now I clean the tabs up with MSDev.exe, and
search-and-replace whatever stereotypical attrocities gg=G did.
I assume Vim detected Ruby from the file extension?
I use vim a lot, but have never asked it to indent my code for me. And
judging by the results that I just got, I won't do so again any time soon.
At least on my machine, with what is, admittedly, probably old and outdated
Ruby support, the results are awful.
With a modern setup, bad results are an exception rather than a rule.
Not so hard really, if you add 3 lines to your init file ( I seem to
recall xemacs giving Ruby support out of the box for me when recently
moving to a different platform), you can automatic Ruby support. Then
you can use arrows, menu entries to drive w/o needing to know all the
various keystrokes (though they really pay off). I find the general
emacs indenting options pretty handy and flexible.
You can indent any single line by simply moving the cursor to the line
and hitting tab, but you can change this to indent the line if at the
beginning of the line, and insert a tab character
Hitting control-j (LF for you old timers) at the end of the line will
automatically insert a return and indent the next line. Very handy.
YOu can select a region and type m-x indent-region, to indent a
region, easier to remember than the key stroke.
Vim's Ruby indentation has actually worked very well for me, although
the syntax coloring gets confused at times. And yes, Vim detects the
.rb and indented accordingly.
It seems to have identified SH scripts. It broke everything up at bizarre
intervals, screwed up the regular expressions, and turned => into = >.
(Fresh Fedora with the vim-common rpm installed, and Ruby installed from its
tar.gz file...)
Just fyi, to update your vim-ruby stuff, do:
$ gem install vim-ruby
$ vim-ruby-install.rb (point it at your vim install path if you didn't set $VIM)
···
On 10/9/05, Gavin Sinclair <gsinclair@gmail.com> wrote:
Kirk Haines wrote:
> I use vim a lot, but have never asked it to indent my code for me. And
> judging by the results that I just got, I won't do so again any time soon.
> At least on my machine, with what is, admittedly, probably old and outdated
> Ruby support, the results are awful.
With a modern setup, bad results are an exception rather than a rule.
The machine(s) are hardly ancient. One is a Gentoo box that has not had any
vim related stuff updated for about 6 months, and the other is an RHEL3 box.
Hardly non-modern. Just not cutting edge. The results are worse than bad
when I ask vim to indent the same code on either.
Kirk Haines
···
On Sunday 09 October 2005 7:01 pm, Gavin Sinclair wrote:
With a modern setup, bad results are an exception rather than a rule.
to install, and then make sure your .vimrc is setup to make use of what you
just installed.
The last bit is important. Otherwise, you get really nasty looking
indentation.
After having followed those steps, the indentation looks pretty good. I've
tested it on half a dozen files of varying lengths and code complexities, and
it seems to do what it should.
Kirk Haines
···
On Sunday 09 October 2005 7:01 pm, Gavin Sinclair wrote:
Kirk Haines wrote:
> I use vim a lot, but have never asked it to indent my code for me. And
> judging by the results that I just got, I won't do so again any time
> soon. At least on my machine, with what is, admittedly, probably old and
> outdated Ruby support, the results are awful.
With a modern setup, bad results are an exception rather than a rule.
Hack up three lines of Emacs Lisp to get the Emacs ruby-mode to do the indentation for you? I usually get good results with XEmacs indenting my code for me, although I don't have a quick and dirty way to do it via the command line at hand.
There's something wrong with your Vim install, because it does work
well for me. Get the latest Vim-Ruby stuff at http://vim-ruby.rubyforge.org/ . Oh, and the prepackaged vimrc files
almost never work very well...
Jacob
···
On 10/9/05, Phlip <phlipcpp@yahoo.com> wrote:
Jacob Quinn Shenker wrote:
> Vim's Ruby indentation has actually worked very well for me, although
> the syntax coloring gets confused at times. And yes, Vim detects the
> .rb and indented accordingly.
It seems to have identified SH scripts. It broke everything up at bizarre
intervals, screwed up the regular expressions, and turned => into = >.
(Fresh Fedora with the vim-common rpm installed, and Ruby installed from its
tar.gz file...)