Re: Folding in vim

2005-07-06 Thread Renato Ramonda
Terry Hancock ha scritto:

 
 Yep, this is what I just set up in my .vimrc.  Works beautifully.

And (you probably already know, but it could be of use to others) you 
can bind the activation of some or all of those commands to au 
(autocommand) depending on the file extension.

That way you can have 8 spaces real tabs in C files, for examples, 
without touching your conf.

-- 
Renato

Usi Fedora? Fai un salto da noi:
http://www.fedoraitalia.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Folding in vim

2005-07-06 Thread Bill Mill
On 7/6/05, Terry Hancock [EMAIL PROTECTED] wrote:
 On Tuesday 05 July 2005 03:53 pm, Renato Ramonda wrote:
  Why not use just spaces? Vim simplifies this immensely:
 
  set tabstop=4
  set shiftwidth=4
  set expandtab
  set smarttab
  set autoindent
 
  AFAICT this gives me all spaces, 4 spaces indent, tab inserts spaces and
  backspace over a block of 4 spaces deletes all of them (just like
  deleting a tab).
 
 Yep, this is what I just set up in my .vimrc.  Works beautifully.
 

I don't use any of the fancy indenters; instead, I just add

set foldmethod=indent

to my .vimrc (_vimrc on windows), along with most of the
aforementioned options (I don't like smarttab); it works nearly
perfectly. Then zo opens the fold under the cursor one level, zO opens
it recursively, zc and zC close it non- and recursively. zr opens all
folds one level, zR opens them all recursively, zm closes them all one
level, and zM closes them all recursively.

It's pretty sweet. Maybe we should have a big Vim-python tip-a-thon thread?

Peace
Bill Mill
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Folding in vim

2005-07-05 Thread Terry Hancock
On Monday 04 July 2005 12:41 am, Ron Adam wrote:
  Actually, I think this one is doing what I want now. It seems
  to be that it isn't robust against files with lots of mixed tabs
  and spaces.  I also got space_hi.vim which highlights tabs
  and trailing spaces, which made it a lot easier to fix the 
  problem.
 
 I edited my syntax coloring file to do the same thing.  Not to mention 
 adding a few key words that were missing.  :-)

This script:
http://www.vim.org/scripts/script.php?script_id=790
python.vim (but in ~/.vim/syntax) by Dmitry Vasiliev

adds a few dozen Python-specific syntax keywords, I used these
and edited my usual color scheme to give them more refined
syntax coloring, which is nice.  It is quite useful to have Unicode
strings and Raw strings display differently, for example, since
it's easy to forget which you're using (unless you're right next
to the mark).

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Folding in vim

2005-07-05 Thread Terry Hancock
On Monday 04 July 2005 01:12 am, Andrea Griffini wrote:
 - never ever use tabs; tabs were nice when they had
 - stick to 4-space indent

Nice ideals to which I ascribe.  But if your editor isn't 
configured to support you on this, spacing over to, say
column 24 gets pretty dull.  Mine wasn't configured to
do anything special, so I was leaving tabs in the file
and etc.

So I wasn't really living up to my ideals. ;-)

Bad habits, I agree.  I now have things working so that
tab actually uses spaces in the file.  The problems
arose because I was still working with my old tainted
files.

All better now. :-)

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Folding in vim

2005-07-05 Thread Sybren Stuvel
Andrea Griffini enlightened us with:
 - never ever use tabs

I always use one tab for indents, and set my editor to display it as
four spaces. I like being able to unindent a line by deleting a single
character. I don't see a reason why _not_ to use tabs, really. As long
as the use is consistent - I hate those files with an 8-space tab and
4-space indent, where they replace two indents with a single tab. For
me, one indent = one tab. No matter the tab setting, it'll look good.

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
 Frank Zappa
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Folding in vim

2005-07-05 Thread Mike Meyer
Sybren Stuvel [EMAIL PROTECTED] writes:

 Andrea Griffini enlightened us with:
 - never ever use tabs

 I always use one tab for indents, and set my editor to display it as
 four spaces. I like being able to unindent a line by deleting a single
 character. I don't see a reason why _not_ to use tabs, really. As long
 as the use is consistent - I hate those files with an 8-space tab and
 4-space indent, where they replace two indents with a single tab. For
 me, one indent = one tab. No matter the tab setting, it'll look good.

And so if you're working with someone who uses a different tab stop -
say the traditional 8-space tabs - they'll get code that may well be
unreadable.

If you're the only one dealing with your code, you can keep the use
consistent. As soon as theirs more than one person editing the code,
that pretty much goes out the window. You either mandate a standard -
which is hard for a large group - or you mandate that you don't use
tabs.

mike
-- 
Mike Meyer [EMAIL PROTECTED]  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Folding in vim

2005-07-05 Thread Benji York
Sybren Stuvel wrote:
 I always use one tab for indents, and set my editor to display it as
 four spaces. I like being able to unindent a line by deleting a single
 character.

Your editor probably supports a backspace unindents option.  If using 
Vim it would be something like set softtabstop=4.
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Folding in vim

2005-07-05 Thread Sybren Stuvel
Benji York enlightened us with:
 Your editor probably supports a backspace unindents option.

Yes, it does. I'm using vim.

 If using Vim it would be something like set softtabstop=4.

This gives you a mixture of tabs and spaces, which I don't like. I'd
rather use real tabs for indenting. If you then use another tab width,
you only see a wider indent, but the rest of the code is okay.

When using a tab/space mixture, with eight spaces being one tab, and
an indent of four spaces, things go wrong when the tab size is
anything but eight spaces.

My solution works for all tab sizes, the other solution only works for
tabs of eight spaces. This is why in my opinion it's better to just
use tabs.

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
 Frank Zappa
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Folding in vim

2005-07-04 Thread Ron Adam
Terry Hancock wrote:

 On Saturday 02 July 2005 10:35 pm, Terry Hancock wrote:
 
I tried to load a couple of different scripts to 
automatically fold Python code in vim, but none of them
seems to do a good job.

I've tried:
python_fold.vim by Jorrit Wiersma
http://www.vim.org/scripts/script.php?script_id=515
 
 
 Actually, I think this one is doing what I want now. It seems
 to be that it isn't robust against files with lots of mixed tabs
 and spaces.  I also got space_hi.vim which highlights tabs
 and trailing spaces, which made it a lot easier to fix the 
 problem.

I edited my syntax coloring file to do the same thing.  Not to mention 
adding a few key words that were missing.  :-)

 After fixing my source files, python_fold seems to be able
 to handle them just fine.
 
 I must also recommend C. Herzog's python_box.vim
 which is fantastic -- especially the automatic Table of
 Contents generation for Python source, and pydoc.vim
 which puts access to pydoc into the editor.

Sounds good. I'll give it a try!  :-)


 Nice.  Now that I have a very sharp saw, I'm going to
 have to go cut some stuff for a bit. ;-)
 
 --
 Terry Hancock ( hancock at anansispaceworks.com )
 Anansi Spaceworks  http://www.anansispaceworks.com
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Folding in vim

2005-07-04 Thread Andrea Griffini
On Sun, 3 Jul 2005 22:42:17 -0500, Terry Hancock
[EMAIL PROTECTED] wrote:

It seems to be that it isn't robust against files
with lots of mixed tabs and spaces.

My suggestion is:

- never ever use tabs; tabs were nice when they had
  a de-facto meaning (tabbing to next 8-space boundary)
  nowdays they're just noise as the meaning depends
  on the phase of the moon.
  Making tabs meaning anything had the pretty obvious
  implication of making tabs meaning nothing.

- stick to 4-space indent

I've even run in the past in editors that damaged
my python sources because they were indented with
two spaces (I'm used to an indent size of 2 when
working in C/C++). With python IMO 4 spaces is
perfectly adequate anyway; onced I tried it I never
had the temptation of looking back.

Andrea
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Folding in vim

2005-07-04 Thread Terry Hancock
On Monday 04 July 2005 07:42 am, Ivan Van Laningham wrote:
 Terry Hancock wrote:
   I also got space_hi.vim which highlights tabs
  and trailing spaces, which made it a lot easier to fix the
  problem.
 
 Is that really the name?  I tried searching for it  got no hits.

Sorry, no underscore, it's spacehi.vim:

http://www.vim.org/scripts/script.php?script_id=443


--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Folding in vim

2005-07-03 Thread Terry Hancock
On Saturday 02 July 2005 10:35 pm, Terry Hancock wrote:
 I tried to load a couple of different scripts to 
 automatically fold Python code in vim, but none of them
 seems to do a good job.
 
 I've tried:
 python_fold.vim by Jorrit Wiersma
 http://www.vim.org/scripts/script.php?script_id=515

Actually, I think this one is doing what I want now. It seems
to be that it isn't robust against files with lots of mixed tabs
and spaces.  I also got space_hi.vim which highlights tabs
and trailing spaces, which made it a lot easier to fix the 
problem.

After fixing my source files, python_fold seems to be able
to handle them just fine.

I must also recommend C. Herzog's python_box.vim
which is fantastic -- especially the automatic Table of
Contents generation for Python source, and pydoc.vim
which puts access to pydoc into the editor.

Nice.  Now that I have a very sharp saw, I'm going to
have to go cut some stuff for a bit. ;-)

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

-- 
http://mail.python.org/mailman/listinfo/python-list


Folding in vim

2005-07-02 Thread Terry Hancock
My general attitude towards IDEs and editors has been 
extremely conservative, but today I decided to see what 
this folding business was all about.

I see that vim (and gvim, which is what I actually use)
has this feature, and it is fairly nice, but at present it's
very manual --- and frankly it's hard for me to see the
point if I have to manually mark folds every time I start
up.

I tried to load a couple of different scripts to 
automatically fold Python code in vim, but none of them
seems to do a good job.

The obvious thing (to me) would be for functions and
classes to be folded at the top level, with each method
folded inside the class folds.  But I can't seem to figure 
out how to make that happen (other than manually,
I mean).  Actually, I usually want to fold the comment
block at the top with the license disclaimer and module
documentation, too, but I can do that manually.

I've tried:
python_fold.vim by Jorrit Wiersma
http://www.vim.org/scripts/script.php?script_id=515
and
AutoFold.vim by Dave Vehrs
http://www.vim.org/scripts/script.php?script_id=925

Does anybody have a better suggestion (or perhaps can
tell me how to make one of these do what I'm wanting)?

I'm assuming that I can set these by using the 
Tools - Folding - Fold Method - Syntax
 (or Expression for python_fold)

but it doesn't seem to work. python_fold seems to just
collapse methods (but not the whole classes they are in),
and I can't seem to make AutoFold do anything at all, so
I must be using it wrong.

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Folding in vim

2005-07-02 Thread Ron Adam
Terry Hancock wrote:

 My general attitude towards IDEs and editors has been 
 extremely conservative, but today I decided to see what 
 this folding business was all about.
 
 I see that vim (and gvim, which is what I actually use)
 has this feature, and it is fairly nice, but at present it's
 very manual --- and frankly it's hard for me to see the
 point if I have to manually mark folds every time I start
 up.

I been trying to learn and use the 'Cream' distribution of Vim.

 http://cream.sourceforge.net/

Playing around with it a bit

If I highlight any block of code... then press F9 it folds it.  Put the 
cursor on the fold and pressing F9 again unfolds it.  It remembers the 
folds, so putting the cursor anywhere in the previous folded area and 
pressing F9 again refolds the fold.  Folds can be inside of folds.

Saving the file exiting and reopening it... the folded folds remained 
folded.  I'm not sure where it keeps the fold info for the file.

The folds don't have anything to do with classes or functions, but are 
arbitrary selected lines, with the first line displayed after the number 
of lines folded.  So a whole file gets reduced to...

   1 # SliderDialog.py
   2
   3 +--- 20 lines:  SIMPLE SLIDER DIALOG -
  23
  24 +-- 24 lines: # Imports--
  48
  49 +-- 13 lines: # Values extracted from win32.com--
  62
  63 +-- 67 lines: class SliderDialog(dialog.Dialog):-
130
131 +--  4 lines: def GetSliderInput( title, text, label, value=0 ):-
135
136 +-- 17 lines: if __name__ == '__main__':-
153

Pretty cool, I'll probably use folding more now that I've played with it 
a bit.

I like Vim-Cream,  but I still haven't gotten the script right for 
executing the current file in the shell.  And a second script for 
executing the current file in the shell and capturing the output in a 
pane.  I think some of it may be windows path conflicts.

Ron

-- 
http://mail.python.org/mailman/listinfo/python-list