Re: how to avoid deleting the auto-indent in a new empty line when i press Esc

2007-04-16 Thread Tom Whittock

 What I need is to always keep the auto-indented spaces.  So next time
 I can start to insert from the spaced cursor.


Alternatively use cc to edit the ostensibly blank line. This will open
the line using the correct auto indent. Get into this habit and it
doesn't matter what state the line was in before - you always get the
right indentation.

Cheers.


Re: Python crash

2007-04-05 Thread Tom Whittock

sys.path.append(c:\\python23\\lib)


What's the result of

:py import sys
:py print sys.version

?

If it's not 2.3.something then there is no way you should be doing that.


Re: Can you create file dependend fold markers

2007-03-27 Thread Tom Whittock

:g/^process\s\+\w\+/,/^end process/fold
Is process a special word?

process (CLK)


process is not a special word - regular expressions do not look like
regular programming languages. I would recommend reading up on vim
regular expressions. the reason why this particular match fails is
because of the parenthesis around the word. Adding (after \s\+ and an
extra ) after the end of the \w\+ should get a match is this
particular case, since the full text is matched, and \w only matches
'word' characters, not punctuation.


Re: Deleting some lines from a log file

2007-03-27 Thread Tom Whittock

:g/^MPRINT/d
:g/^\d\+/d

should do more or less what you want.

Cheers.

On 27/03/07, Eddine [EMAIL PROTECTED] wrote:

Hi

I have to clean up a log file.
I want to exclude/delete lines that start with a number or MPRINT :


ENTRY

184
185  
**;
186  *   PGMs Complexes   1 : enable - O : disable
   *;
187  
**;123

188
189   %include pgm.MainComplex.sas; ** Macro principale
Base et Queries **;
NOTE: %INCLUDE (level 1) file E:\IFM
  2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas
is file E:\IFM
  2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas.

269 
+**;
MPRINT(MAINCOMPLEX):
**;



RESULT :

NOTE: %INCLUDE (level 1) file E:\IFM
  2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas
is file E:\IFM
  2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas.

**;


I first tyred to identify all numbers at a beginning of a line, but
for instance when doing a substitution I cannot find the good regex
(for a try :%s/^[0-9]*/TEST/ didn't work).

Can you tell me how I have to do to delete those lines beginning by
numbers or MPRINT from my file ?

Many thanks.

Eddine.



Re: Can you create file dependend fold markers

2007-03-26 Thread Tom Whittock

   :g/^component\s\+\w+/,/^end component/fold

The use of regexps can give you more flexibility for nailing them down.[snip]

Yes please explain, as I get the message:
E486: Pattern not found ^component\s\+\w+


This is missing a \ before the final +, so unless your identifier is a
word character and a + character, the expression won't match. Try

:g/^component\s\+\w\+/,/^end component/fold

And I would highly recommend using this sort of regular expression for
your custom folds - you can easily end up with some very strange folds
in odd circumstances otherwise.

Cheers.


Re: replace command

2007-03-20 Thread Tom Whittock

/123\(45\)[EMAIL PROTECTED]

add \w* to the end of the pattern to include 46 and 57 in the search
result, to match to the end of the word, and add \ to the beginning
of the pattern to match for 123 only at the beginning of a word.

Cheers.

On 20/03/07, Bin Chen [EMAIL PROTECTED] wrote:

I want to know a command for this:

a word start with 123 but NOT followed by 45, such as

12346
12357

are match,
only 12345 not match.

Thanks.
abai



Re: help with \z

2007-03-20 Thread Tom Whittock

\zs means begin the match here

so you can put it into a search term, and the term before \zs is used
to position the match, but is not included within it.

the other end can be done, as well - anchoring the match at the end using \ze

HTH
Tom.

On 20/03/07, Brian McKee [EMAIL PROTECTED] wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi All,

Tim's recent post got me looking at \z
I've read :h :syn-ext-match but it's gibberish to me at the moment

Can someone break down how this suggestion works?
 If you want to delete everything after the 2nd comma, you can use
   :%s/,[^,]*,\zs.*/

I get the 'search the whole document for a comma followed by a not-
comma followed by whatever then a comma'
then ???

Comments appreciated

Brian
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (Darwin)
Comment: Verify this email or encrypt your email for free - see gnupg.org

iD8DBQFF//HvGnOmb9xIQHQRAol2AKCRY7vY1tt/ZG8JvwkImqmBZR6XEgCeNIdI
AdPSndCUCyha4bwhS0OpRZA=
=VdFU
-END PGP SIGNATURE-



Re: replace upper-case with lower-case

2007-03-09 Thread Tom Whittock

 This does not seem to be a good way, consider if we want to change:
 START - STOP
 Start - Stop
 start - stop
 STart - STop
 sTART - sTOP


I'm only personally concerned by the first three of those. This is the
solution from my rc file. It moves the cursor, which I find annoying.
Anyone know why it would do that? Hope this helps the OP.

I use camel case, so I use the mixed case version of the string as the
initial argument, so for example, given:

HelloThere
HELLOTHERE
hellothere

typing:
:%Sub HelloThere HiThere

results in:
 HiThere
 HITHERE
 hithere

the code from my vimrc:

 Case-matching substitution
function! CaseMatchSubstitute(find, repl) range
As-you-typed-it substitution.
   sil exe a:firstline.','.a:lastline.'s/\C'.a:find.'/'.a:repl.'/ge'

All-lowercase substitution
   let casefind = tolower(a:find)
   let caserepl = tolower(a:repl)
   sil exe a:firstline.','.a:lastline.'s/\C'.casefind.'/'.caserepl.'/ge'

All-uppercase substitution
   let casefind = toupper(a:find)
   let caserepl = toupper(a:repl)
   sil exe a:firstline.','.a:lastline.'s/\C'.casefind.'/'.caserepl.'/ge'
endfunction

command! -range -nargs=+ Sub :line1,line2 call CaseMatchSubstitute(f-args)


Re: save a file

2007-02-15 Thread Tom Whittock

exe normal! :%j\r


Hello Michael.

vim script can be thought of as a series of ex commands (colon
commands), therefore the first line of your script could be rewritten:

%j

which should give a clue as to how you might want to *write* your file.

also, you probably don't need the exe command all the way through your
script - exe allows an arbitrary expression to be executed, so you can
include variables in the command.

You might think that your firefox command would need to use exe, since
you are including the expand() call to find the path, but the
following would work just as well:

!firefox %:p

HTH


Re: editing function argument lists

2007-02-09 Thread Tom Whittock

Hi Marc.

The EasyHtml idea is an interesting one, I could take over an entire
buffer (window) and put the list editing commands in there, but I am
used to dealing with registers and motions in the standard vim sense;
I'm not sure how well I would adapt to a new layout. I think I would
also have to add list modification maps in the main buffer anyway, in
order to keep the edit efficient, so the list on the left sort of
becomes redundant...

As you say, it'd take a lot of work to get that running smoothly, so I
don't think I'll go down that route.

Thanks for the suggestion, anyway.
Tom.


editing function argument lists

2007-02-08 Thread Tom Whittock

Hi Vim users.

I have a question: Given a standard function call block of text:

func(arg1, arg2, arg3);

how do people here deal with editing the argument list efficiently?

I'm looking to try to create a custom motion to allow me to move
across and change arguments with a minimum number of keystrokes, as I
find myself doing that a fair bit. This is what I quickly came up with
(it's buggy - I don't deal with many cases here)

/\((\zs.\)\|\(,\zs.\)\|\()\)

which puts search marks here:

func(_arg1,_ arg2,_ arg3_);

I can then use n as a motion to get around the function call (more or
less) and even do things like dnnp to swap an argument with the next
one in the list (sometimes it even finishes up with the correct
syntax!).

Before I spend too much time sorting out the search term to work in
more cases, I was wondering if anyone else had already dealt with
this, or if anyone has other ideas about how to accomplish editing a
list as a list.

Ideally I'd like to be able to mutate the yanked text to fit in with
its new placement within a list (move the comma to the start or end if
putting before or after a parenthesis) and also to create a command
which behaves like ciw for arguments... This seems to be beyond me,
though. I can't even work out how to create a custom motion.

Cheers.
Tom.


Re: replace with a number sequence

2007-01-31 Thread Tom Whittock

but it kept going to the same spot as before.  I will not change the [#].
Where is the match for (?  I can't figure it out.


Using a simple change to Tim Chase' original substitution response, you have:

:','s/\d\+/\=line('.')-line(')

which replaces the *first number* on every line in the visual
selection. look at the difference between the two to see that the
responses have all used opIndex as a marker to know what number is to
be operated on.

this modification doesn't really allow for any fine degree of control
(like selecting which number on a given line to increment), but it
works for the examples you've given.

if you don't want to type it in every time,
:vmap C-I :s/\d\+/\=line('.')-line(')CR
which adds ctrl-i as a key in visual mode to do the job.

the ex (colon) commands are one of the major parts of vim - I would
highly recommend learning them a bit more, if you want to get the most
out of the program. For me, without ex there would be very little
point in using vim at all - I couldn't even write to a file ;)

Cheers.


Re: Editing during compiling

2007-01-31 Thread Tom Whittock

Is there any possibility of editing during compiling like in Visual
Studio, also seeing the errorlist growing during compiling?


Hi Peter.

I'd like this too. I started looking into it, but the partial solution
I have is ugly, and can't find a way around not being able to
programmatically update the quickfix list from inside vim. Hopefully
I'm missing something obvious. This response is to see if anyone else
on the list can turn me around in the right direction.

split test
sil !python test.py  test 
call setbufvar('test', 'autoread', 1)
au CursorMoved,CursorMovedI * checktime test
au CursorHold,CursorHoldI * checktime test

It seems to update the test buffer every 2-3 seconds on my machine,
with heavy cursor movement to keep the autocommands running.

The test python script just prints an integer every second for 5
seconds, flushing stdout regularly.

I just had a thought: we could add:
call setbufvar('test', 'makeprg', 'cat %')
au FileChangedShell test make

But that won't work, because it'll refresh the quick fix list in the
middle of using it, in theory, and it's ugly as sin.

After all that, I'm not sure I want it anymore - too much like real
work, and way too ugly - I don't want to think about the performance
implications of these autocommands. :(


change filenames before vim reads buffer

2007-01-25 Thread Tom Whittock

Hi.

I'm running the vim under cygwin, and have set up my build process to
execute via :make. This is great, but the build process reports
filenames in DOS format, not the cygwin /cygdrive/* way. This means
that when a quickfix command runs, vim will be asked to open
C:\dev\test.cpp, when I already have /cygdrive/c/dev/test.cpp
open, and this causes issues for me.

Is there any way I can insert my own handler in between the quickfix
jump and buffer reading so that I can fix up the filename? Moreso,
could I do this in general so that if I gf to C:\dev\test.cpp, vim
will interpret that in the cygwin manner?

Thanks,
Tom.


Re: change filenames before vim reads buffer

2007-01-25 Thread Tom Whittock

Hi again, and thanks for your quick responses.

I am using the addition of an extra filter on the makeprg, as
suggested. Here's what I use (I'm setting it buffer local, for other
reasons):

let l:makeprg = makeprg . ' $* \| sed -e {
s/\(\w\)\:\\\/\/cygdrive\/\1\//;s/\\\/\//g }'

which converts X:\ to /cygdrive/X/ and all \ to /.

Thanks again,
Tom.


install custom python module?

2007-01-17 Thread Tom Whittock

Hi.

I would like to install an external python module (ctypes) into vim
+python, so I can use that modules functionality from my script, but
am unsure as to how to do that. Is this a reasonable thing to want to
do? Is it possible? There doesn't seem to be a python_path equivalent
that I can see...

Any help appreciated,
Cheers,
Tom.