match() to get the offsets of all matches of a pattern in a string

2015-07-28 Thread BPJ

I have a string of rows of dashes alternating with spaces,
where the number of dashes/spaces is variable

-   --- ---  

I want to get a List of the offsets of all the space sequences,
kind of a match() with /g (that's the best I can do to describe
it...) In the case above (ignoring the indent, I would get
[6, 16, 20].

It's the usual problem: I don't know the right :help keyword

/bpj

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups "vim_use" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: match() to get the offsets of all matches of a pattern in a string

2015-07-28 Thread BPJ

Den 2015-07-28 18:02, BPJ skrev:

I have a string of rows of dashes alternating with spaces,
where the number of dashes/spaces is variable

 -   --- ---  

I want to get a List of the offsets of all the space sequences,
kind of a match() with /g (that's the best I can do to describe
it...) In the case above (ignoring the indent, I would get
[6, 16, 20].

It's the usual problem: I don't know the right :help keyword

/bpj



Sorry for the noise.  I gave up and did it the traditional way:

let colpos_l = []
let colpos = 0
let str_len = strlen(line)
while colpos < str_len
let colpos = matchend(sepline, '-\+\ze\s', colpos)
if colpos < 0
break
elseif colpos > 0
" call add(colpos_l, colpos)
call add(colpos_l, colpos)
endif
endwhile

I will make a 'plugin' of a generalized version of this though...

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups "vim_use" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Persistent undo and force quit

2015-07-28 Thread David Besen
Here's a first draft of getting it to work:

"save undo if we qa!
function! MyWundoQuit()
silent! later 9
earlier 1f
let undof = escape(undofile(expand('%')),'% ')
exec "wundo " . undof
endfunction

autocmd BufWinLeave * call MyWundoQuit()


I don't see a way to undo back to when the file was written last other than
going later, and then earlier 1f.  That doesn't work in the case that the
file hasn't been changed at all, so it's not ideal.  But, it seems to work
in practice pretty well.

- Dave

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Persistent undo and force quit

2015-07-28 Thread David Besen
Second draft, seems to work a little better:

"save undo if we qa!
function! MyWundoQuit()
let undoseq = undotree().seq_cur
earlier 1f
let undof = escape(undofile(expand('%')),'% ')
exec "wundo " . undof
silent! exec "u " . undoseq
endfunction

autocmd BufWinLeave * call MyWundoQuit()

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: I cannot realise a :map why ??

2015-07-28 Thread aubertin.sylvain
Le mardi 21 juillet 2015 10:02:15 UTC+2, aubertin.sylvain a écrit :
> For instance I should like to make F9 stand for   papa
> Following VIM Manual (by Moolenaar) I type :
> :map  ipapa (5 characters for  and 4 characters for  )
> But it doesn't work. Instead of « papa «  , it returns 
> Something is wrong, but where ??  Thanks for your reply.

AT  LAST  I USED  F9 WITH SUCCESS
1.  I load my shell   with « vim shellname »
2 I see my shell. At the bottom (on the left side ) I find the name of my shelL 
Please What is the name of this mode ?On my text I can delete usimg x 
or dd. But  F9 gives me  nothing.
3 I go to another mode whose name I ignore again.  It is in two parts.  Above I 
have the text of my shell and below I have a list which contains ancient 
commands 
4 I find my map command and enable it with a CR. List disappears.
5 I go back to my shell. THIS TIME WHEREVER I AM IT INSERT.S « papa » WITH 
SUCCESS  
I repeat I do that outside insert mode.
 So  map works if it is freshly enabled.  I think it is impossible to have a 
permanent   :map

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.