On Thu, Jun 01, 2006 at 01:43:48PM +0200, Johannes Schwarz wrote: > Hello, > > I'm trying to write my first vim-plugin, but I got stucked. > > I managed to execute an external command, which gives me back a list of > filenames. > One filename per line. > > For each of the filenames I want to execute another command. > I tried it with code: > > let line=getline(".") > while (strlen(line)!=0) > "do sth. here -- construct the external command and so on > j > let line=getline(".") > endwhile
Remember that a vim script (including a plugin) is a list of commands in Command-Line (Ex) mode, not Normal mode. So that j means :j[oin], not "move the cursor down one line." If you change "j" to "+" it will be a step in the right direction. > When I execute the code, it runns into an infinite loop, because the > lines are joined together with each loop > > file: > text1.txt > text2.txt > text3.txt > > after interrupting the loop the looks like > text1.txt text2.txt text3.txt That's right. > it seems j is interpreted as a J (join line) here. > And by the way, I think this is a bad solution anyway. > Can someone give me a hint how to do it in a clean way? Either :g/./<any Command-Line mode command here> or let linenr = 0 while linenr < line("$") let linenr += 1 " The += construction requires vim 7.0 . let line = getline(linenr) " ... endwhile HTH --Benji Fisher