114868Unable to catch specific error [was: Re: delete lines from while loop]
- Jun 2, 2010On Ma, 01 iun 10, 21:32:01, Tom Link wrote:
> > for linenum in range(a:firstline, a:lastline)Tried that, but couldn't find the right incantation, this is my first
> You might want to delete the lines in reverse order, i.e. from the
> bottom to the top.
try at vimscript ;)
> I also wonder if you could make use of the :gThanks a lot, :global is perfect! I'm hitting another issue now, with a
part of code not included so far (hence the subject change). Now I have:
fu! <SID>RemoveFuzzy() range
for linenum in range(a:firstline, a:lastline)
let line = getline(linenum)
if line =~ '^#,\(.*,\)\=\s*fuzzy'
call setline(linenum, substitute(line, ',\s*fuzzy', '', ""))
I tried (no pun intended) to replace the 'for' loop with:
catch /^Vim\%((\a\+)\)\=:E486/ " based on example from :help catch
but I still get:
E486: Pattern not found: ^#,\(.*,\)\=\s*fuzzy
I can work around it by reversing the order, let the substitute global
do its work and then remove any '^#$' lines left behind in the deleting
global, but according to :help it should work.
- << Previous post in topic Next post in topic >>