> I just started to use Vim (actually, MacVim) and I really love it. :)

Welcome aboard!

> I would like to ask you how to re-indent old files I edited in
> TextMate. They use spaces instead of tabs, set to two spaces.
> Now I have some rows rightly indented to the Vim default and some
> stick to two spaces like in TextMate.
> Which is the command to reformat them?

The settings are controlled by various correlated settings:

   :set ts=2 sw=2 et

which you can learn about at

   :help 'tabstop'
   :help 'shiftwidth'
   :help 'expandtab'
   :help :retab

Setting the 'tabstop' to 2 changes your tab-stops to 
2-visual-spaces-per-tab.  I like to keep my 'shiftwidth' in sync 
with my 'tabstop' setting just so things like the ">"/"<" 
operators and ^D/^T work as expected in insert-mode.

If Vim is inserting real tabs instead of expanding spaces, the 
'expandtab' setting will change future insertions.  To change 
past insertions of real-tabs, once you have the above ":set" 
command, you can then use ":retab" to force vim to change 
existing tabs to the spaces you defined.

> And, which are the settings to add to my .vimrc file?

You should be able to just add the above "set" (minus the colon) 
to your vimrc to get this behavior by default.  Alternatively, if 
you allow modelines, you can include a modeline in your files 
that specifies these settings:

   :help modeline
   :help 'modeline'

which would allow you to put something like

   /* vim: set tw=2 sw=2 et */

at the top or bottom of your file, and vim will set them on a 
per-file basis.

Hope this helps,

-tim




--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to