LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-08-2006, 09:11 PM   #1
fudam
Member
 
Registered: Feb 2006
Distribution: FC
Posts: 86

Rep: Reputation: 15
Running a function mutiple times in vim


Hey,

I've written a function in vim and it works great. I execute it as follows:
Code:
:call Myfunc()
My question is, what if I want to run Myfunc() 7 times in a row? Or 11, or whatever. Does anyone know how to do this? typing in :5 Myfunc() did not work (instead it takes you to line 5 and executes Myfunc).

TIA for any help, this is starting to hurt my head...

-fudamn
 
Old 10-09-2006, 12:04 AM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
Check out the vimbook, page 356. It has an example of how to use a while loop in command mode to repeat some action multiple times. I suppose calling a function that way would work.
 
Old 10-09-2006, 02:31 AM   #3
muha
Member
 
Registered: Nov 2005
Distribution: xubuntu, grml
Posts: 451

Rep: Reputation: 38
Look at this dot ~> .
Seriously In vi (i don't know about vim) you can run a command, like p(aste) and use the . (dot) to run the previous command again.
Usually in vi the syntax format is like: :<number of times><command>
So to repeat a paste three times do:
yy first yank a line
p paste it once
. repeat the paste
3. repeat the paste three times
So I think you can use:
:call Myfunc()
:3.
Let me know if it works, ok?
 
Old 10-09-2006, 08:34 PM   #4
fudam
Member
 
Registered: Feb 2006
Distribution: FC
Posts: 86

Original Poster
Rep: Reputation: 15
Thanks for reply fellas,

muha: Sorry the dot doesn't work on function calls. Good try though.

bigrigdriver: Are you referring to the manual? Or the vim PDF book on their website? It's a bit late and I'm off to bed, but I'll check out your reference tomorrow. Thanks!

-fudamn
 
Old 10-10-2006, 02:30 PM   #5
muha
Member
 
Registered: Nov 2005
Distribution: xubuntu, grml
Posts: 451

Rep: Reputation: 38
that's a shame indeed :P
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Running a program at specific times only i666an SUSE / openSUSE 4 04-02-2006 07:49 AM
times(2) function zWaR Programming 3 04-15-2005 08:42 AM
running wget multiple times quickk Linux - Newbie 1 09-16-2004 06:53 AM
Using istream::get() & istream::getline() mutiple times kamransoomro84 Programming 0 06-14-2004 07:11 PM
TOP: says kdeinit is running 7 times, WHY ? qwijibow Linux - Software 1 12-01-2003 04:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration