Re: Terminating search in function

2006-10-26 Thread Charles E Campbell Jr

Meino Christian Cramer wrote:


I wrote this snippet:


fun! Ffunchdr()
   let date = strftime( %F )
   
put='/*-*/'
   put='/**'
   put=' * desc'
   put=' *'
   put=' *'
   put=' *'
   put=' * Created: ' . date . '
   put=' *'
   put=' * parameter:
   put=' * parameter:
   put=' * parameter:
   put=' * parameter:
   put=' * parameter:
   put=' *'
   put=' * result 0 - Success, -1 - Failure'
   put=' *'
   put=' */'
   ?desc
endfun
command! Funchdr :call Ffunchdr()



This should give nme the header comment for function definitions in C.
My problem seems to be the ?desc command at the end.
It /should/ move the cursor onto the desc keyword right in the
beginning of the comment block.
 


(snip)

I suggest using the search() function:

call search(desc,bW)

Regards,
Chip Campbell



Re: Terminating search in function

2006-10-22 Thread A.J.Mechelynck

Meino Christian Cramer wrote:

Hi,

 I wrote this snippet:


fun! Ffunchdr()
let date = strftime( %F )

put='/*-*/'
put='/**'
put=' * desc'
put=' *'
put=' *'
put=' *'
put=' * Created: ' . date . '
put=' *'
put=' * parameter:
put=' * parameter:
put=' * parameter:
put=' * parameter:
put=' * parameter:
put=' *'
put=' * result 0 - Success, -1 - Failure'
put=' *'
put=' */'
?desc
endfun
command! Funchdr :call Ffunchdr()



This should give nme the header comment for function definitions in C.
My problem seems to be the ?desc command at the end.
It /should/ move the cursor onto the desc keyword right in the
beginning of the comment block.

But it move the cursor to here:

  * desc 
  ^

  |
  cursor position

My analysis (a too big word...) of the problem is: ? is still
waiting for input. I tried


?descCR

instead, but now ? tries to find descCR literally and did not
find it.

There seem to be an exception of the type the commands as you would
do normally-rule here...but what is the rule to recognize that the
current situation is an exception and what is the solution?

Thank you very much in advance for any help ! :)

Have a nice weekend!
mcc




What you're using is a searching range (as in :?desc from the keyboard). 
It positions the cursor on the first nonblank in the matched line.


To use a search command (as in ?desc from the keyboard) in an Ex-command 
line, use :normal:


normal ?desc

see
:help :range
:help :normal


Best regards,
Tony.


Re: Terminating search in function

2006-10-22 Thread Meino Christian Cramer
From: A.J.Mechelynck [EMAIL PROTECTED]
Subject: Re: Terminating search in function
Date: Sun, 22 Oct 2006 09:33:01 +0200

 Meino Christian Cramer wrote:
  Hi,
  
   I wrote this snippet:
  
  
  fun! Ffunchdr()
  let date = strftime( %F )
  
  put='/*-*/'
  put='/**'
  put=' * desc'
  put=' *'
  put=' *'
  put=' *'
  put=' * Created: ' . date . '
  put=' *'
  put=' * parameter:
  put=' * parameter:
  put=' * parameter:
  put=' * parameter:
  put=' * parameter:
  put=' *'
  put=' * result 0 - Success, -1 - Failure'
  put=' *'
  put=' */'
  ?desc
  endfun
  command! Funchdr :call Ffunchdr()
  
  
  
  This should give nme the header comment for function definitions in C.
  My problem seems to be the ?desc command at the end.
  It /should/ move the cursor onto the desc keyword right in the
  beginning of the comment block.
  
  But it move the cursor to here:
  
* desc 
^
|
cursor position
  
  My analysis (a too big word...) of the problem is: ? is still
  waiting for input. I tried
  
  
  ?descCR
  
  instead, but now ? tries to find descCR literally and did not
  find it.
  
  There seem to be an exception of the type the commands as you would
  do normally-rule here...but what is the rule to recognize that the
  current situation is an exception and what is the solution?
  
  Thank you very much in advance for any help ! :)
  
  Have a nice weekend!
  mcc
  
  
 
 What you're using is a searching range (as in :?desc from the keyboard). 
 It positions the cursor on the first nonblank in the matched line.
 
 To use a search command (as in ?desc from the keyboard) in an Ex-command 
 line, use :normal:
 
   normal ?desc
 
 see
   :help :range
   :help :normal
 
 
 Best regards,
 Tony.
 

Hi Tony,

 :O) thank you,Tony !:O)

  
 execute normal ?desc\CR
 
 will do the job and it seems, that a final

 execute normal cw on the found desc cannot be done correctly,
 since the command is not finished (which it should eb according to
 the :help normal text).

 Have a nice weekend!
 mcc
  


 


Re: Terminating search in function

2006-10-22 Thread A.J.Mechelynck

Meino Christian Cramer wrote:

From: A.J.Mechelynck [EMAIL PROTECTED]
Subject: Re: Terminating search in function
Date: Sun, 22 Oct 2006 09:33:01 +0200


Meino Christian Cramer wrote:

Hi,

 I wrote this snippet:


fun! Ffunchdr()
let date = strftime( %F )

put='/*-*/'
put='/**'
put=' * desc'
put=' *'
put=' *'
put=' *'
put=' * Created: ' . date . '
put=' *'
put=' * parameter:
put=' * parameter:
put=' * parameter:
put=' * parameter:
put=' * parameter:
put=' *'
put=' * result 0 - Success, -1 - Failure'
put=' *'
put=' */'
?desc
endfun
command! Funchdr :call Ffunchdr()



This should give nme the header comment for function definitions in C.
My problem seems to be the ?desc command at the end.
It /should/ move the cursor onto the desc keyword right in the
beginning of the comment block.

But it move the cursor to here:

  * desc 
  ^

  |
  cursor position

My analysis (a too big word...) of the problem is: ? is still
waiting for input. I tried


?descCR

instead, but now ? tries to find descCR literally and did not
find it.

There seem to be an exception of the type the commands as you would
do normally-rule here...but what is the rule to recognize that the
current situation is an exception and what is the solution?

Thank you very much in advance for any help ! :)

Have a nice weekend!
mcc


What you're using is a searching range (as in :?desc from the keyboard). 
It positions the cursor on the first nonblank in the matched line.


To use a search command (as in ?desc from the keyboard) in an Ex-command 
line, use :normal:


normal ?desc

see
:help :range
:help :normal


Best regards,
Tony.



Hi Tony,

 :O) thank you,Tony !:O)

  
 execute normal ?desc\CR
 
 will do the job and it seems, that a final


 execute normal cw on the found desc cannot be done correctly,
 since the command is not finished (which it should eb according to
 the :help normal text).

 Have a nice weekend!
 mcc
  



 



normal cw is not finished since the c (change) commands needs to be told 
_to_ what you want to change the replaced word. What you can do instead (IIUC) 
is normal diw (delete inner word) followed by startinsert!. Note that 
startinsert[!] only makes sense as the last statement of the script (because 
insert-mode will be delayed until then).


Have a nice weekend too.


Best regards,
Tony.


Re: Terminating search in function

2006-10-22 Thread A.J.Mechelynck

Meino Christian Cramer wrote:

From: A.J.Mechelynck [EMAIL PROTECTED]
Subject: Re: Terminating search in function
Date: Sun, 22 Oct 2006 11:00:14 +0200


Meino Christian Cramer wrote:

From: A.J.Mechelynck [EMAIL PROTECTED]
Subject: Re: Terminating search in function
Date: Sun, 22 Oct 2006 09:33:01 +0200


Meino Christian Cramer wrote:

Hi,

 I wrote this snippet:


fun! Ffunchdr()
let date = strftime( %F )

put='/*-*/'
put='/**'
put=' * desc'
put=' *'
put=' *'
put=' *'
put=' * Created: ' . date . '
put=' *'
put=' * parameter:
put=' * parameter:
put=' * parameter:
put=' * parameter:
put=' * parameter:
put=' *'
put=' * result 0 - Success, -1 - Failure'
put=' *'
put=' */'
?desc
endfun
command! Funchdr :call Ffunchdr()



This should give nme the header comment for function definitions in C.
My problem seems to be the ?desc command at the end.
It /should/ move the cursor onto the desc keyword right in the
beginning of the comment block.

But it move the cursor to here:

  * desc 
  ^

  |
  cursor position

My analysis (a too big word...) of the problem is: ? is still
waiting for input. I tried


?descCR

instead, but now ? tries to find descCR literally and did not
find it.

There seem to be an exception of the type the commands as you would
do normally-rule here...but what is the rule to recognize that the
current situation is an exception and what is the solution?

Thank you very much in advance for any help ! :)

Have a nice weekend!
mcc


What you're using is a searching range (as in :?desc from the keyboard). 
It positions the cursor on the first nonblank in the matched line.


To use a search command (as in ?desc from the keyboard) in an Ex-command 
line, use :normal:


normal ?desc

see
:help :range
:help :normal


Best regards,
Tony.


Hi Tony,

 :O) thank you,Tony !:O)

  
 execute normal ?desc\CR
 
 will do the job and it seems, that a final


 execute normal cw on the found desc cannot be done correctly,
 since the command is not finished (which it should eb according to
 the :help normal text).

 Have a nice weekend!
 mcc
  



 

normal cw is not finished since the c (change) commands needs to be told 
_to_ what you want to change the replaced word. What you can do instead (IIUC) 
is normal diw (delete inner word) followed by startinsert!. Note that 
startinsert[!] only makes sense as the last statement of the script (because 
insert-mode will be delayed until then).


Have a nice weekend too.


Best regards,
Tony.



Hi Tony,

 ...the normal diw+startinsert!-trick works nice !
 Thanks a lot -- such little helpers like the now
 finally working Function-header-function() are the
 _real_ stuff helping one to speed up the daily work --
 and of course the helping hands, which make the helper-function 
 work ... :O)


 Happy VIMming!
 mcc




 



BTW, instead of all those put statements, wouldn't it be simpler to have 
your template as a separate file, and use :r filename to insert it after the 
cursor?



Best regards,
Tonoy.


Re: Terminating search in function

2006-10-22 Thread Yakov Lerner

Meino Christian Cramer wrote:
execute normal ?desc\CR


Yes. There is also :call search('pattern', 'b'). It is a bit less
painful substitute to exe normal ?pattern\cr.

Yakov


Re: Terminating search in function

2006-10-22 Thread Meino Christian Cramer
From: A.J.Mechelynck [EMAIL PROTECTED]
Subject: Re: Terminating search in function
Date: Sun, 22 Oct 2006 12:29:36 +0200

 Meino Christian Cramer wrote:
  From: A.J.Mechelynck [EMAIL PROTECTED]
  Subject: Re: Terminating search in function
  Date: Sun, 22 Oct 2006 11:00:14 +0200
  
  Meino Christian Cramer wrote:
  From: A.J.Mechelynck [EMAIL PROTECTED]
  Subject: Re: Terminating search in function
  Date: Sun, 22 Oct 2006 09:33:01 +0200
 
  Meino Christian Cramer wrote:
  Hi,
 
   I wrote this snippet:
 
  
  fun! Ffunchdr()
  let date = strftime( %F )
  
  put='/*-*/'
  put='/**'
  put=' * desc'
  put=' *'
  put=' *'
  put=' *'
  put=' * Created: ' . date . '
  put=' *'
  put=' * parameter:
  put=' * parameter:
  put=' * parameter:
  put=' * parameter:
  put=' * parameter:
  put=' *'
  put=' * result 0 - Success, -1 - Failure'
  put=' *'
  put=' */'
  ?desc
  endfun
  command! Funchdr :call Ffunchdr()
 
 
 
  This should give nme the header comment for function definitions in C.
  My problem seems to be the ?desc command at the end.
  It /should/ move the cursor onto the desc keyword right in the
  beginning of the comment block.
 
  But it move the cursor to here:
 
* desc 
^
|
cursor position
 
  My analysis (a too big word...) of the problem is: ? is still
  waiting for input. I tried
 
 
  ?descCR
 
  instead, but now ? tries to find descCR literally and did not
  find it.
 
  There seem to be an exception of the type the commands as you would
  do normally-rule here...but what is the rule to recognize that the
  current situation is an exception and what is the solution?
 
  Thank you very much in advance for any help ! :)
 
  Have a nice weekend!
  mcc
 
 
  What you're using is a searching range (as in :?desc from the 
  keyboard). 
  It positions the cursor on the first nonblank in the matched line.
 
  To use a search command (as in ?desc from the keyboard) in an 
  Ex-command 
  line, use :normal:
 
   normal ?desc
 
  see
   :help :range
   :help :normal
 
 
  Best regards,
  Tony.
 
  Hi Tony,
 
   :O) thank you,Tony !:O)
 

   execute normal ?desc\CR
   
   will do the job and it seems, that a final
 
   execute normal cw on the found desc cannot be done correctly,
   since the command is not finished (which it should eb according to
   the :help normal text).
 
   Have a nice weekend!
   mcc

 
 
   
 
  normal cw is not finished since the c (change) commands needs to be told 
  _to_ what you want to change the replaced word. What you can do instead 
  (IIUC) 
  is normal diw (delete inner word) followed by startinsert!. Note that 
  startinsert[!] only makes sense as the last statement of the script 
  (because 
  insert-mode will be delayed until then).
 
  Have a nice weekend too.
 
 
  Best regards,
  Tony.
 
  
  Hi Tony,
  
   ...the normal diw+startinsert!-trick works nice !
   Thanks a lot -- such little helpers like the now
   finally working Function-header-function() are the
   _real_ stuff helping one to speed up the daily work --
   and of course the helping hands, which make the helper-function 
   work ... :O)
  
   Happy VIMming!
   mcc
  
  
  
  
   
  
 
 BTW, instead of all those put statements, wouldn't it be simpler to have 
 your template as a separate file, and use :r filename to insert it after 
 the 
 cursor?
 
 
 Best regards,
 Tonoy.
 

Hi Tony,

 ...hrrr clear answer: yesno! :O)

 Yes: It would be the cleaner and more flexible way to implement this, no doubt!
 No : Currently it is the only thing inserting an header/template or
  such into text. It would just add another file to care of. As
  soon as I have more than a single template to handle, it will
  surely the better way to do it with seperated files.

 By the way: Is there a way to puts more than a single line?
 Something like an HERE-doc? 

 :h permutations of 'here-doc'

 gives me nothing...

 Keep hacking!
 mcc


  


Re: Terminating search in function

2006-10-22 Thread A.J.Mechelynck

Meino Christian Cramer wrote:

From: A.J.Mechelynck [EMAIL PROTECTED]

[...]
BTW, instead of all those put statements, wouldn't it be simpler to have 
your template as a separate file, and use :r filename to insert it after the 
cursor?



Best regards,
Tony.



Hi Tony,

 ...hrrr clear answer: yesno! :O)

 Yes: It would be the cleaner and more flexible way to implement this, no doubt!
 No : Currently it is the only thing inserting an header/template or
  such into text. It would just add another file to care of. As
  soon as I have more than a single template to handle, it will
  surely the better way to do it with seperated files.

 By the way: Is there a way to puts more than a single line?
 Something like an HERE-doc? 


 :h permutations of 'here-doc'

 gives me nothing...

 Keep hacking!
 mcc


See :help :append and :help :insert. I didn't know about them either but I 
knew that perl  EOF (or similar) could start a here-document for any of 
the 5 interpreted languages. :helpgrep  brought (among others) a page 
where :append and :insert were mentioned.



Best regards,
Tony.


Terminating search in function

2006-10-21 Thread Meino Christian Cramer
Hi,

 I wrote this snippet:


fun! Ffunchdr()
let date = strftime( %F )

put='/*-*/'
put='/**'
put=' * desc'
put=' *'
put=' *'
put=' *'
put=' * Created: ' . date . '
put=' *'
put=' * parameter:
put=' * parameter:
put=' * parameter:
put=' * parameter:
put=' * parameter:
put=' *'
put=' * result 0 - Success, -1 - Failure'
put=' *'
put=' */'
?desc
endfun
command! Funchdr :call Ffunchdr()



This should give nme the header comment for function definitions in C.
My problem seems to be the ?desc command at the end.
It /should/ move the cursor onto the desc keyword right in the
beginning of the comment block.

But it move the cursor to here:

  * desc 
  ^
  |
  cursor position

My analysis (a too big word...) of the problem is: ? is still
waiting for input. I tried


?descCR

instead, but now ? tries to find descCR literally and did not
find it.

There seem to be an exception of the type the commands as you would
do normally-rule here...but what is the rule to recognize that the
current situation is an exception and what is the solution?

Thank you very much in advance for any help ! :)

Have a nice weekend!
mcc