Tuesday, June 30, 2015

Re: syntax region end when either pattern occurs?

Le mardi 30 juin 2015 à 15:43, Nikolay Pavlov a écrit:
> 2015-06-30 9:09 GMT+03:00 Paul Isambert <zappathustra@free.fr>:
> >
> > You can move "{3}" outside the group:
> >
> > end=/\v^%(\.|\-){3}$/
> >
> > and since chances are pretty low that you'll have lines mixing "-" and
> > ".", you can use the more relaxed:
> >
> > end=/\v^[.-]{3}$/
>
> These are not different. I did not move `{3}` out of the group because
> it will *in both cases you presented* match something like `.-.`.

Oups, yeah, my bad.
Paul

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: syntax region end when either pattern occurs?

2015-06-30 9:09 GMT+03:00 Paul Isambert <zappathustra@free.fr>:
> Le lundi 29 juin 2015 à 19:05, Nikolay Pavlov a écrit:
>>
>>
>> 2015-06-29 18:52 GMT+03:00 Rick Dooling <rpdooling@gmail.com>:
>> > I am trying to syntax highlight yaml blocks in Markdown files.
>> >
>> > Right now, I can get it so it handles either blocks that look like this:
>> >
>> > ---
>> > author: me
>> > document: Help
>> > ---
>> >
>> > or
>> >
>> > ---
>> > author: me
>> > document: Help
>> > ...
>> >
>> > But not both. Is there a way to do both?
>> >
>> > I tried end=\(/^---$/\|/^\.\.\.$\) but that didn't work
>>
>> end=\(/^---$/\|/^\.\.\.$\)
>>
>> Syntax for such items is end={separator}{regex}{separator}[offsets].
>> In your example separator is `\` which really results in something
>> weird because `\` is *always* an escape character. This has no chances
>> to work, you need to use `end=/\v^%(\.{3}|\-{3})$/`.
>
> You can move "{3}" outside the group:
>
> end=/\v^%(\.|\-){3}$/
>
> and since chances are pretty low that you'll have lines mixing "-" and
> ".", you can use the more relaxed:
>
> end=/\v^[.-]{3}$/

These are not different. I did not move `{3}` out of the group because
it will *in both cases you presented* match something like `.-.`.

>
> Best,
> Paul
>
> --
> --
> 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+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Monday, June 29, 2015

Re: syntax region end when either pattern occurs?

Le lundi 29 juin 2015 à 19:05, Nikolay Pavlov a écrit:
>
>
> 2015-06-29 18:52 GMT+03:00 Rick Dooling <rpdooling@gmail.com>:
> > I am trying to syntax highlight yaml blocks in Markdown files.
> >
> > Right now, I can get it so it handles either blocks that look like this:
> >
> > ---
> > author: me
> > document: Help
> > ---
> >
> > or
> >
> > ---
> > author: me
> > document: Help
> > ...
> >
> > But not both. Is there a way to do both?
> >
> > I tried end=\(/^---$/\|/^\.\.\.$\) but that didn't work
>
> end=\(/^---$/\|/^\.\.\.$\)
>
> Syntax for such items is end={separator}{regex}{separator}[offsets].
> In your example separator is `\` which really results in something
> weird because `\` is *always* an escape character. This has no chances
> to work, you need to use `end=/\v^%(\.{3}|\-{3})$/`.

You can move "{3}" outside the group:

end=/\v^%(\.|\-){3}$/

and since chances are pretty low that you'll have lines mixing "-" and
".", you can use the more relaxed:

end=/\v^[.-]{3}$/

Best,
Paul

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: syntax region end when either pattern occurs?

On Monday, June 29, 2015 at 10:52:25 AM UTC-5, Rick Dooling wrote:
> I am trying to syntax highlight yaml blocks in Markdown files.
>
> Right now, I can get it so it handles either blocks that look like this:
>
> ---
> author: me
> document: Help
> ---
>
> or
>
> ---
> author: me
> document: Help
> ...
>
> But not both. Is there a way to do both?
>
> I tried end=\(/^---$/\|/^\.\.\.$\) but that didn't work
>
> unlet b:current_syntax
>
> " Bring in YAML syntax for front matter
> syntax include @Yaml syntax/yaml.vim
>
> syntax region yamlFrontmatter start=/\%^---$/ end=/^---$/ keepend contains=@Yaml
> syntax region yamlFrontmatter start=/\%^---$/ end=/^\.\.\.$/ keepend contains=@Yaml
>
> let b:current_syntax='markdown'

Thank you so much. It works perfectly. In way over my head but I'll read until I understand how you did it. Many thanks.

Rick

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: syntax region end when either pattern occurs?

2015-06-29 18:52 GMT+03:00 Rick Dooling <rpdooling@gmail.com>:
> I am trying to syntax highlight yaml blocks in Markdown files.
>
> Right now, I can get it so it handles either blocks that look like this:
>
> ---
> author: me
> document: Help
> ---
>
> or
>
> ---
> author: me
> document: Help
> ...
>
> But not both. Is there a way to do both?
>
> I tried end=\(/^---$/\|/^\.\.\.$\) but that didn't work

end=\(/^---$/\|/^\.\.\.$\)

Syntax for such items is end={separator}{regex}{separator}[offsets].
In your example separator is `\` which really results in something
weird because `\` is *always* an escape character. This has no chances
to work, you need to use `end=/\v^%(\.{3}|\-{3})$/`. (Note: in
very-magic mode (:h /\v) you *must* escape HYPHEN-MINUS because it is
an ASCII character that is not guaranteed not to have special meaning
according to help even though it currently means itself.)

>
> unlet b:current_syntax
>
> " Bring in YAML syntax for front matter
> syntax include @Yaml syntax/yaml.vim
>
> syntax region yamlFrontmatter start=/\%^---$/ end=/^---$/ keepend contains=@Yaml
> syntax region yamlFrontmatter start=/\%^---$/ end=/^\.\.\.$/ keepend contains=@Yaml

This variant has no chances to work AFAIK because which exactly region
is started is determined when `start` regexp is encountered from
whatever rule *first* happened to match. No global "backtracking" and
trying another region to see whether it fits better.

>
> let b:current_syntax='markdown'
>
> --
> --
> 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+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Catching "swap file exists" and dealing with it in code



On Mon, Jun 29, 2015 at 10:45 AM, Tim Chase <vim@tim.thechases.com> wrote:
On 2015-06-29 10:25, David Fishburn wrote:
> What I want to be able to do is catch this message and deal with it
> in my own code and show a message.

Sounds like you want to do things on the SwapExists event:


Yes sir, just what the Dr. ordered.

Thank you. 

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

syntax region end when either pattern occurs?

I am trying to syntax highlight yaml blocks in Markdown files.

Right now, I can get it so it handles either blocks that look like this:

---
author: me
document: Help
---

or

---
author: me
document: Help
...

But not both. Is there a way to do both?

I tried end=\(/^---$/\|/^\.\.\.$\) but that didn't work

unlet b:current_syntax

" Bring in YAML syntax for front matter
syntax include @Yaml syntax/yaml.vim

syntax region yamlFrontmatter start=/\%^---$/ end=/^---$/ keepend contains=@Yaml
syntax region yamlFrontmatter start=/\%^---$/ end=/^\.\.\.$/ keepend contains=@Yaml

let b:current_syntax='markdown'

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Catching "swap file exists" and dealing with it in code

On 2015-06-29 10:25, David Fishburn wrote:
> What I want to be able to do is catch this message and deal with it
> in my own code and show a message.

Sounds like you want to do things on the SwapExists event:

:help SwapExists

I'm not positive about the ordering if you are doing a diff with
another file, so whether a buffer gets 'diff' set before the
SwapExists fires, or if SwapExists before you have a buffer to check
for 'diff' being set. But that's where I'd start :-)

-tim


--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Catching "swap file exists" and dealing with it in code

Windows 32bit Vim 7.4.1-729

My work flow is this.

Have gVim open, editing a file.
Flip over to my revision system (Perforce) and do a diff on the file to have a look at the changes I have made with what is currently in the repository.

P4 just launches gvim -O -d %1 %2.

I am writing my own plugin to do something different like this instead:
gvim --servername gDiff +"RemoteDiffFiles '%1', '%2'"

If the file I choose to diff, so happens to be open in my usual editing Vim instance then Vim rightly displays the popup, indicating the .swp file exists and what I would like to do ... Open Read-Only, Delete it, Quit,...


What I want to be able to do is catch this message and deal with it in my own code and show a message.  

Greping through the vim74 directory, "Open Read-Only" seems to be part of the Vim binary itself.  

I know I can wrap my :edit / :view command in a try catch, but assuming I manage to catch this condition, is there a Vim command I can use in VimScript to make one of those choices?  My Googling around didn't get me what I needed.

TIA,
David


--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Changing buffer changes display area

I have two buffers open on two different files. In buffer 1, I go to the bottom with G, and zz to put the cursor into the middle, and see the ~'s in the bottom half of the window. I swap to buffer 2 with :bn. I swap back with :bp. Vim has 'optimised' the display area by moving the bottom line of the file to the bottom of the window. I would like it to keep it in the middle, or wherever I had put it. Is it possible?

When I search for this online, I see only results for moving the cursor position with startofline, nothing about keeping the displayed area as it was.

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sunday, June 28, 2015

Re: Auto-commenting

Hi Meino.Cramer!

On So, 28 Jun 2015, Meino.Cramer@gmx.de wrote:

> Hi,
>
> when using vim for editing Perl sources, vim proceeds
> the next line with an comment sign '#', if the previous
> one was a comment line using <RET> in insert mode.
>
> To not to miss even one of the wonderful feature of vim ;) :
>
> Suppose the situation is as follows (inser mode)
>
> # this is a comment in perl _
>
> and "_" is, where my coursor is, Now I want to start
> coding in the next line. <RET> gives me a new line, but
> with a "#" in front of it, which I need to delete.
>
> Another way to get "commentless" to the next line would
> be <ESC>o

I usually do not bother and press enter followed by <Ctrl-U> or <Ctrl-W>
If you are really lazy, you could map this to some other key however.

Best,
Christian
--
Der Weise sagt niemals, was er tut - aber er tut niemals etwas, was
er nicht sagen könnte.
-- Jean-Paul Sartre

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Auto-commenting

Hi Meino.Cramer!

On So, 28 Jun 2015, Meino.Cramer@gmx.de wrote:

> I looked into my .vimrc and found
>
> set formatoptions-=o
>
> so, no "r" ist set. I dont want to switch of this feature completly.
> My search was for a short and handy/elegant way to get into
> the first code line from the last comment line.

This could be set by the ftplugin. The best way to check from where this
comes, is in the buffer that has this behaviour issuing:
:verbose set fo?

For me this echoes:
formatoptions=crqol
Zuletzt gesetzt von ~/local/share/vim/vim74/ftplugin/perl.vim

Best,
Christian

--
Was sagt ein Mercedes-Fahrer, wenn sein Auto auf dem Dach liegt?
A: Aaaaaa - Klasse.

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Saturday, June 27, 2015

Re: Auto-commenting

Jack Stratton <jack@phroa.net> [15-06-28 07:08]:
> Hi,
>
> On 2015-06-27 21:00, Meino.Cramer@gmx.de wrote:
> >Hi,
> >when using vim for editing Perl sources, vim proceeds
> >the next line with an comment sign '#', if the previous
> >one was a comment line using <RET> in insert mode.
> >To not to miss even one of the wonderful feature of vim ;) :
> >Suppose the situation is as follows (inser mode)
> > # this is a comment in perl _
> >and "_" is, where my coursor is, Now I want to start
> >coding in the next line. <RET> gives me a new line, but
> >with a "#" in front of it, which I need to delete.
> >Another way to get "commentless" to the next line would
> >be <ESC>o
> >Is there any other more elegant and/or shorter way to accomplish this?
> >Thanks a lot for any help in advance!
> >Best regards,
> >Meino
>
> I believe disabling the 'r' formatoption is what you want.
> See ":h formatoptions" for how to change them (and what they are), or
> ":h fo-table" to see all the available options.
>
> Here's an online copy:
> http://vimhelp.appspot.com/change.txt.html#fo-table
>
> 'r' is not set by default in vi(m), so I imagine your .vimrc has the
> option
> set and you simply forgot it was there ;)
>
> HTH,
> --
> Jack
>
> --
> --
> 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+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

Hi Jack,

thanks for reply and yout help! :)

I looked into my .vimrc and found

set formatoptions-=o

so, no "r" ist set. I dont want to switch of this feature completly.
My search was for a short and handy/elegant way to get into
the first code line from the last comment line.

Best regards,
Meino


--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Auto-commenting

On Sun, Jun 28, 2015, Meino.Cramer@gmx.de wrote:
> Hi,
>
> when using vim for editing Perl sources, vim proceeds
> the next line with an comment sign '#', if the previous
> one was a comment line using <RET> in insert mode.
>
> To not to miss even one of the wonderful feature of vim ;) :
>
> Suppose the situation is as follows (inser mode)
>
> # this is a comment in perl _
>
> and "_" is, where my coursor is, Now I want to start
> coding in the next line. <RET> gives me a new line, but
> with a "#" in front of it, which I need to delete.
>
> Another way to get "commentless" to the next line would
> be <ESC>o
>
> Is there any other more elegant and/or shorter way to accomplish this?
>
> Thanks a lot for any help in advance!
> Best regards,
> Meino

I use these two mappings, Alt+Enter and Shift+Enter. I've found that
different Vim UIs have issues with one or the other of these, so I map
both.

inoremap <silent> <A-CR> <C-o>:let b:fo=&fo<Bar>set fo-=r<CR><CR>x<Backspace><C-o>:let &fo=b:fo<Bar>normal! gi<CR>
inoremap <silent> <S-CR> <C-o>:let b:fo=&fo<Bar>set fo-=r<CR><CR>x<Backspace><C-o>:let &fo=b:fo<Bar>normal gi<CR>

I believe Raimondi on FreeNode did most of the work on creating these.
fo is formatoptions (:h formatoptions).

--
Eric Christopherson

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Auto-commenting

Hi,

On 2015-06-27 21:00, Meino.Cramer@gmx.de wrote:
> Hi,
>
> when using vim for editing Perl sources, vim proceeds
> the next line with an comment sign '#', if the previous
> one was a comment line using <RET> in insert mode.
>
> To not to miss even one of the wonderful feature of vim ;) :
>
> Suppose the situation is as follows (inser mode)
>
> # this is a comment in perl _
>
> and "_" is, where my coursor is, Now I want to start
> coding in the next line. <RET> gives me a new line, but
> with a "#" in front of it, which I need to delete.
>
> Another way to get "commentless" to the next line would
> be <ESC>o
>
> Is there any other more elegant and/or shorter way to accomplish this?
>
> Thanks a lot for any help in advance!
> Best regards,
> Meino

I believe disabling the 'r' formatoption is what you want.
See ":h formatoptions" for how to change them (and what they are), or
":h fo-table" to see all the available options.

Here's an online copy:
http://vimhelp.appspot.com/change.txt.html#fo-table

'r' is not set by default in vi(m), so I imagine your .vimrc has the
option
set and you simply forgot it was there ;)

HTH,
--
Jack

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Auto-commenting

Hi,

when using vim for editing Perl sources, vim proceeds
the next line with an comment sign '#', if the previous
one was a comment line using <RET> in insert mode.

To not to miss even one of the wonderful feature of vim ;) :

Suppose the situation is as follows (inser mode)

# this is a comment in perl _

and "_" is, where my coursor is, Now I want to start
coding in the next line. <RET> gives me a new line, but
with a "#" in front of it, which I need to delete.

Another way to get "commentless" to the next line would
be <ESC>o

Is there any other more elegant and/or shorter way to accomplish this?

Thanks a lot for any help in advance!
Best regards,
Meino


"I dont know all these editor wars. There is only one editor." ;)


--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Execute a command from cursor position to the end of the line - SOLVED

Tim,


On 2015-06-28 05:47, Philip Rhoades wrote:
> Tim,
>
>
> On 2015-06-27 23:37, Tim Chase wrote:
>> On 2015-06-27 05:53, Philip Rhoades wrote:
>>>>>>> nnoremap <F8> :Execute<CR>
>>>>>>
>>>>>> Could you provide the content of your Execute() function? It
>>>>>> would help to replicate the behavior you want on an extract of
>>>>>> the line.
>> [snip stuff that isn't the definition of Execute]
>>>> I think Tim wanted the definition of the Execute command.
>>>
>>> ? I don't know what you mean - as far as I know using
>>> ":Execute . ." as I showed above in my .vimrc file is a built-in
>>> Vim thing?
>>
>> As you write it, it's a function/command brought in by some external
>> plugin as demonstrated by starting vim without any startup files:
>>
>> vim -u NONE
>> :Execute
>> E492: Not an editor command: Execute
>>
>> With your regular (started up without the "-u NONE") vim, you can
>> execute
>>
>> :verbose function
>> :verbose command
>>
>> to see where various items were defined. You want to see where the
>> "Execute" function/command was created. Based on your invocation
>> description, it *sounds* like it's a custom command rather than a
>> function, so you can minimize the noise by issuing
>>
>> :verbose command Execute
>
>
> Right - all is clear now . . that gives:
>
> :verbose command Execute
> Name Args Address Complete Definition
> Execute 0 . silent <line1>,<line2>yank z | let @z =
> substitute(@z, '\n\s*\\', '', 'g') | @z
> Last set from ~/.vimrc
>
>
>> which should give you just the info needed to track down where
>> "Execute" is defined.
>
>
> Which now I realise has been put into .vimrc - which I don't remember
> doing (it must have been a long time ago) but I should have found it
> before . . sorry . .:
>
> command! -bar -range Execute silent <line1>,<line2>yank z | let @z =
> substitute(@z, '\n\s*\\', '', 'g') | @z
>
>
>>>> Anyway, you can get the content of a line from the cursor to its
>>>> end with:
>>>>
>>>> getline(".")[col(".")-1:]
>>>>
>>>> You can pass that to whatever does you execution in you original
>>>> command.
>>>
>>> I still don't get what you are saying - how can I use the F8 key
>>> (that executes the command on the line in the text file - like I
>>> described above) with that getline command?
>>
>> Without the definition of the Execute function it's hard to tell how
>> to integrate Paul's "remainder of the line" snippet with the Execute
>> function.
>
>
> So I am guessing I can replace "<line1>,<line2>yank" with
> "getline(".")[col(".")-1:] z" ?


I eventually found that this worked for my needs:

command! -bar -range Execute silent <line1>,<line2>yank z | let @z =
substitute(@z, '^#', '', 'g') | @z

Phil.
--
Philip Rhoades

PO Box 896
Cowra NSW 2794
Australia
E-mail: phil@pricom.com.au

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Execute a command from cursor position to the end of the line

Tim,


On 2015-06-27 23:37, Tim Chase wrote:
> On 2015-06-27 05:53, Philip Rhoades wrote:
>>>>>> nnoremap <F8> :Execute<CR>
>>>>>
>>>>> Could you provide the content of your Execute() function? It
>>>>> would help to replicate the behavior you want on an extract of
>>>>> the line.
> [snip stuff that isn't the definition of Execute]
>>> I think Tim wanted the definition of the Execute command.
>>
>> ? I don't know what you mean - as far as I know using
>> ":Execute . ." as I showed above in my .vimrc file is a built-in
>> Vim thing?
>
> As you write it, it's a function/command brought in by some external
> plugin as demonstrated by starting vim without any startup files:
>
> vim -u NONE
> :Execute
> E492: Not an editor command: Execute
>
> With your regular (started up without the "-u NONE") vim, you can
> execute
>
> :verbose function
> :verbose command
>
> to see where various items were defined. You want to see where the
> "Execute" function/command was created. Based on your invocation
> description, it *sounds* like it's a custom command rather than a
> function, so you can minimize the noise by issuing
>
> :verbose command Execute


Right - all is clear now . . that gives:

:verbose command Execute
Name Args Address Complete Definition
Execute 0 . silent <line1>,<line2>yank z | let @z =
substitute(@z, '\n\s*\\', '', 'g') | @z
Last set from ~/.vimrc


> which should give you just the info needed to track down where
> "Execute" is defined.


Which now I realise has been put into .vimrc - which I don't remember
doing (it must have been a long time ago) but I should have found it
before . . sorry . .:

command! -bar -range Execute silent <line1>,<line2>yank z | let @z =
substitute(@z, '\n\s*\\', '', 'g') | @z


>>> Anyway, you can get the content of a line from the cursor to its
>>> end with:
>>>
>>> getline(".")[col(".")-1:]
>>>
>>> You can pass that to whatever does you execution in you original
>>> command.
>>
>> I still don't get what you are saying - how can I use the F8 key
>> (that executes the command on the line in the text file - like I
>> described above) with that getline command?
>
> Without the definition of the Execute function it's hard to tell how
> to integrate Paul's "remainder of the line" snippet with the Execute
> function.


So I am guessing I can replace "<line1>,<line2>yank" with
"getline(".")[col(".")-1:] z" ?

Thanks,

Phil.
--
Philip Rhoades

PO Box 896
Cowra NSW 2794
Australia
E-mail: phil@pricom.com.au

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Execute a command from cursor position to the end of the line

On 2015-06-27 05:53, Philip Rhoades wrote:
>>>>> nnoremap <F8> :Execute<CR>
>>>>
>>>>Could you provide the content of your Execute() function? It
>>>>would help to replicate the behavior you want on an extract of
>>>>the line.
[snip stuff that isn't the definition of Execute]
>> I think Tim wanted the definition of the Execute command.
>
> ? I don't know what you mean - as far as I know using
> ":Execute . ." as I showed above in my .vimrc file is a built-in
> Vim thing?

As you write it, it's a function/command brought in by some external
plugin as demonstrated by starting vim without any startup files:

vim -u NONE
:Execute
E492: Not an editor command: Execute

With your regular (started up without the "-u NONE") vim, you can
execute

:verbose function
:verbose command

to see where various items were defined. You want to see where the
"Execute" function/command was created. Based on your invocation
description, it *sounds* like it's a custom command rather than a
function, so you can minimize the noise by issuing

:verbose command Execute

which should give you just the info needed to track down where
"Execute" is defined.

>> Anyway, you can get the content of a line from the cursor to its
>> end with:
>>
>> getline(".")[col(".")-1:]
>>
>> You can pass that to whatever does you execution in you original
>> command.
>
> I still don't get what you are saying - how can I use the F8 key
> (that executes the command on the line in the text file - like I
> described above) with that getline command?

Without the definition of the Execute function it's hard to tell how
to integrate Paul's "remainder of the line" snippet with the Execute
function.

-tim



--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Execute a command from cursor position to the end of the line

Paul,


On Saturday, 20 June 2015 15:30:47 UTC+10, Paul Isambert wrote:


So it is clear, the next line is in my .vimrc file:


> > >> nnoremap <F8> :Execute<CR>
> > >
> > >Could you provide the content of your Execute() function? It would
> > >help to replicate the behavior you want on an extract of the line.
> >
> >
> > The ones I currently have are:
> >
> > # :Voom
> > # :se foldmethod=marker
> > # :.,$VoomSort
>
> I think Tim wanted the definition of the Execute command.


? I don't know what you mean - as far as I know using ":Execute . ." as I showed above in my .vimrc file is a built-in Vim thing?


> Anyway, you can get the content of a line from the cursor to its end
> with:
>
> getline(".")[col(".")-1:]
>
> You can pass that to whatever does you execution in you original
> command.


I still don't get what you are saying - how can I use the F8 key (that executes the command on the line in the text file - like I described above) with that getline command?

Thanks,

Phil.

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Friday, June 26, 2015

Re: How get a list of substrings matching a pattern?

2015-06-26 18:33 GMT+03:00 BPJ <bpj@melroch.se>:
> I have succeded in writing a function which splits the contents of a visual
> selection on a pattern, reverses the resulting list, joins it together on a
> separator and puts the result back into the visual selection (Yes that's
> kind of basic, right?):
>
> fun! RevList(...)
> let reg_save=@@
> let pattern=!exists('a:1') ? '\s*,\s*' : a:1
> let sep=!exists('a:2') ? ', ' : a:2
> normal gvy
> let @@=join(reverse(split(@@,pattern)),sep)
> normal gvp
> let @@=reg_save
> endfun
>
> What I want to do is to make this smart enough to not split on commas (or
> whatever) which are inside quotes, so how do I extract all substrings which
> match a pattern rather than split on a pattern, the equivalent of `my @list
> = $string =~ m/($pattern)/g` in Perl? (Hopefully a pattern like
> '\v%(%(\s*\,\s*)@!.)+' will match the non-quoted parts...)

You can use a hack with substitute(, , '\='):

let matches = []
call substitute(str, pattern, '\=add(matches, submatch(0))[-1]', 'g')

---

Some notes about your code:

1. !exists('a:n') may be written as a:0 < n. The whole expression can
be written using get(a:000, n, default).
2. You should not ever use :normal in scripts. You can't know whether
`normal gvy` will restore the selection and yank because user may have
remapped something. You need to use :normal!.
3. Using :let and @reg does not allow you neither to correctly save
nor restore the register. You need to use

let reg_save = [getreg('"', 1, 1), getregtype('"')]

call setreg('"', reg_save[0], reg_save[1])

. In the current state your code spoils

1. Any NUL which happens to appear in the register. (This is why I
have second argument to getreg().)
2. Register restored with :let @ will *never* be blockwise.

4. Yank operation does alter registers besides the unnamed register:
at least, the zero register, possibly also system clipboard. If you
care about restoring registers it is better to avoid yank operation,
though code will be much more complex (I would be using code based on
`getpos()` (using positions of < and > marks) and `visualmode()`).
Warning: you cannot possibly restore system clipboard from Vim because
Vim can only put text there.

>
> --
> --
> 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+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: How get a list of substrings matching a pattern?

On Fri, Jun 26, 2015 at 11:33 AM, BPJ <bpj@melroch.se> wrote:
I have succeeded in writing a function which splits the contents of a visual selection on a pattern, reverses the resulting list, joins it together on a separator and puts the result back into the visual selection (Yes that's kind of basic, right?):

    fun! RevList(...)
        let reg_save=@@
        let pattern=!exists('a:1') ? '\s*,\s*' : a:1
        let sep=!exists('a:2') ? ', ' : a:2
        normal gvy
        let @@=join(reverse(split(@@,pattern)),sep)
        normal gvp
        let @@=reg_save
    endfun

What I want to do is to make this smart enough to not split on commas (or whatever) which are inside quotes, so how do I extract all substrings which match a pattern rather than split on a pattern, the equivalent of `my @list = $string =~ m/($pattern)/g` in Perl? (Hopefully a pattern like '\v%(%(\s*\,\s*)@!.)+' will match the non-quoted parts...)

     I think you want to split on any comma that is not preceded by unbalanced quotation marks.   If you have to deal correctly with single and double quotation marks, then I am not sure it can be done with regular expressions.  As a starting point, see the notslash variable in matchit.vim:  https://github.com/benjifisher/matchit.zip/blob/master/plugin/matchit.vim#L85 .  What you want is a lot more complicated.  I assume that escaped quotes, like '\"', inside other quotes, do not count.

     Maybe you can work with something like this (after removing the spaces, assuming \v):

( [^,] | " ( [^"] | notslash \\")* " | ' ( [^'] | notslash \\')* ' ){-} \zs \s*,\s*

-- 
HTH
Benji Fisher


--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: netrw hide files beginning with "." while using the long liststyle

On Fri, Jun 26, 2015 at 5:29 AM, Rick Dooling <rpdooling@gmail.com> wrote:
> Thank you, Chip. I think I have the latest snapshot of MacVim 76? And it uses version 153 of netrw, so as soon as they update I will report.


You can also install netrw as a plugin that tracks the updates more
close. I use:

https://github.com/eiginn/netrw

c
--
Chris Lott <chris@chrislott.org>

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

How get a list of substrings matching a pattern?

I have succeded in writing a function which splits the contents of
a visual selection on a pattern, reverses the resulting list,
joins it together on a separator and puts the result back into the
visual selection (Yes that's kind of basic, right?):

fun! RevList(...)
let reg_save=@@
let pattern=!exists('a:1') ? '\s*,\s*' : a:1
let sep=!exists('a:2') ? ', ' : a:2
normal gvy
let @@=join(reverse(split(@@,pattern)),sep)
normal gvp
let @@=reg_save
endfun

What I want to do is to make this smart enough to not split on
commas (or whatever) which are inside quotes, so how do I extract
all substrings which match a pattern rather than split on a
pattern, the equivalent of `my @list = $string =~ m/($pattern)/g`
in Perl? (Hopefully a pattern like '\v%(%(\s*\,\s*)@!.)+' will
match the non-quoted parts...)

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: netrw hide files beginning with "." while using the long liststyle

On Thursday, June 25, 2015 at 3:27:20 PM UTC-5, Charles Campbell wrote:
> Rick Dooling wrote:
> > On Monday, March 9, 2015 at 7:53:06 PM UTC-5, DrChip wrote:
> >> Rick Dooling wrote:
> >>> I saw another thread herein where the conversation touched on this but without a conclusive answer.
> >>>
> >>> I like the long list style in netrw, and I also like sorting by time reversed (showing newest files at the top). However, when I switch to this view all of the dot-files and dot-directories become visible and the 'gh' command does not work to hide them.
> >>>
> >>> I am on MacVim, latest snapshop 74, but I think the same behavior happens in Vim.
> >>>
> >> Hello!
> >>
> >> I see the problem; unfortunately, I won't be able to look at it for a
> >> couple of weeks. Its on my to-do list, though.
> >>
> >> Chip Campbell
> > No rush at all. It's a very minor issue.
> >
> > I'm used to just opening files from iTerm2 on Mac, but over the last few weeks I've seen the netrw light. Excellent plugin.
> >
> Hello!
>
> I'm not sure if I responded to this earlier -- so please try netrw v154d
> (http://www.drchip.org/astronaut/vim/index.html#NETRW). It appears to
> address this issue.
>
> Regards,
> Chip Campbell

Thank you, Chip. I think I have the latest snapshot of MacVim 76? And it uses version 153 of netrw, so as soon as they update I will report.

Thanks again.

Rick

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thursday, June 25, 2015

Re: netrw hide files beginning with "." while using the long liststyle

Rick Dooling wrote:
> On Monday, March 9, 2015 at 7:53:06 PM UTC-5, DrChip wrote:
>> Rick Dooling wrote:
>>> I saw another thread herein where the conversation touched on this but without a conclusive answer.
>>>
>>> I like the long list style in netrw, and I also like sorting by time reversed (showing newest files at the top). However, when I switch to this view all of the dot-files and dot-directories become visible and the 'gh' command does not work to hide them.
>>>
>>> I am on MacVim, latest snapshop 74, but I think the same behavior happens in Vim.
>>>
>> Hello!
>>
>> I see the problem; unfortunately, I won't be able to look at it for a
>> couple of weeks. Its on my to-do list, though.
>>
>> Chip Campbell
> No rush at all. It's a very minor issue.
>
> I'm used to just opening files from iTerm2 on Mac, but over the last few weeks I've seen the netrw light. Excellent plugin.
>
Hello!

I'm not sure if I responded to this earlier -- so please try netrw v154d
(http://www.drchip.org/astronaut/vim/index.html#NETRW). It appears to
address this issue.

Regards,
Chip Campbell

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: gvim colorscheme is run before global variables restored

On Thursday, June 25, 2015 at 11:00:31 AM UTC-4, Ben Fritz wrote:
>On Wednesday, June 24, 2015 at 11:21:02 PM UTC-5, Paul wrote:
>> The vimrc is run in phase/step#3, while buffers are loaded in
>> step#11. And the -S file that capture the past session are run
>> *after* the first file is loaded. I'm assuming that this means
>> after the 1st buffer is loaded. If that's the case, then it's
>> clear why g:Lapscreen is not set when colorscheme is run -- globals
>> are restored in step#11.
>>
>> Oh well. I guess it's not too much trouble to type ":color mine".
>> Thanks.
>
>You may be interested in the "SessionLoadPost" autocmd event. :-)

Wow. You are allowing me to indulge in the height of laziness. :)

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: gvim colorscheme is run before global variables restored

On Wednesday, June 24, 2015 at 11:21:02 PM UTC-5, Paul wrote:
>
> Huh. The initialization help page is indeed very informative.
>
> The vimrc is run in phase/step#3, while buffers are loaded in step#11.
> And the -S file that capture the past session are run *after* the
> first file is loaded. I'm assuming that this means after the 1st
> buffer is loaded. If that's the case, then it's clear why g:Lapscreen
> is not set when colorscheme is run -- globals are restored in step#11.
>
> Oh well. I guess it's not too much trouble to type ":color mine".
> Thanks.

You may be interested in the "SessionLoadPost" autocmd event. :-)

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Wednesday, June 24, 2015

Re: vim replace a string when a change occurred in another place

On Tuesday, June 23, 2015 at 6:52:54 PM UTC+8, Rudra Banerjee wrote:
> Hi,
>
> Say, I have a file:
> Program foo
> <program text>
> End Program foo
>
> Is it possible that if I change the word "foo" in the first line to "bar" (which may not be the first line of the file), the last line's "foo" will also be changed to "bar" automatically?

You can check out the multiple-cursors plug-in.
https://github.com/terryma/vim-multiple-cursors

Regards,
KF

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: gvim colorscheme is run before global variables restored

On Wed, Jun 24, 2015 at 6:45 PM, Nikolay Pavlov <zyx.vim_AT_gmail.com>
wrote:
> 2015-06-25 1:24 GMT+03:00 Paul <paul.domaskis_AT_gmail.com>:
>> My color scheme checks for the existence of a global variable
>> g:Lapscreen and modified colours accordingly. The colorscheme is
>> invoked from my vimrc. I have sessionoption set to include globals
>> so that the colorscheme does the right thing when my session is
>> restored -- or rather, that's what I'm aiming to accomplish.
>>
>> When I restore a session, however, the my colorscheme is invoked as
>> if g:Lapscreen doesn't exist. Would I be correct in assuming that
>> the globals are restored *after* the colorscheme is invoked? I
>> examined my session file and found no invocation of my colorscheme.
>
> Check out :h initialization. It contains all necessary answers
> (note: it is not explicitly mentioned *there* (it is in :h -S), but
> -S and -c are processed in the same loop in the same initialization
> stage).
>
> Note that &sessionoptions setting that allows disabling almost
> everything is a great hint on *why* initialization is being done in
> this order: it is rather explicit that session file assumes that
> most of the initialization is done prior to loading it or omitting
> e.g. options or mappings would not work normally (there are three
> main variants:
>
> 1. Sessions are loaded prior to doing normal initialization: saving
> mappings, options and globals in session files is almost pointless
> because this way vimrc will simply override options from session.
> 2. Sessions are loaded *instead* of regular initialization:
> *omitting* to save mappings, options and globals damages user
> experience, especially given that most plugin managers require user
> to have something in vimrc for plugins to work meaning that more
> things need to be saved to work properly.
> 3. Sessions are loaded after regular initialization: mostly has no
> problems, except cases like yours.

Huh. The initialization help page is indeed very informative.

The vimrc is run in phase/step#3, while buffers are loaded in step#11.
And the -S file that capture the past session are run *after* the
first file is loaded. I'm assuming that this means after the 1st
buffer is loaded. If that's the case, then it's clear why g:Lapscreen
is not set when colorscheme is run -- globals are restored in step#11.

Oh well. I guess it's not too much trouble to type ":color mine".
Thanks.

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: How to let vim immediate update the screen when I type ESC (in TUI mode)?

Hi Peng and Ben,

2015-6-25(Thu) 0:04:59 UTC+9 Ben Fritz:
> On Wednesday, June 24, 2015 at 8:42:01 AM UTC-5, Peng Yu wrote:
> > Hi,
> >
> > For example, starting with normal model, then I type :, then type ESC,
> > it will take some time (maybe a sec) for the ":" at the bottom of the
> > screen to disappear (this is the case in TUI not GUI mode).
> >
> > How to let vim immediate update the screen when I type ESC in TUI mode?
> >
>
> Have you set up 'timeoutlen' and 'ttimeoutlen' appropriately?
>
> Vim in a terminal must parse character sequences beginning with <Esc> to determine when special keys have been pressed, for example the arrow keys, and these options control how long Vim waits before deciding that there is no special key code coming, it really was just an <Esc>. See the help for these options.
>
> Also, note that the command line can be closed with <C-C> as well.


I use the following settings in my .vimrc.
This works fine for me.

set timeout
set timeoutlen=500
set ttimeoutlen=50

--
Best regards,
Hirohito Higashi (a.k.a. h_east)

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: gvim colorscheme is run before global variables restored

2015-06-25 1:24 GMT+03:00 Paul <paul.domaskis@gmail.com>:
> My color scheme checks for the existence of a global variable
> g:Lapscreen and modified colours accordingly. The colorscheme is
> invoked from my vimrc. I have sessionoption set to include globals so
> that the colorscheme does the right thing when my session is restored
> -- or rather, that's what I'm aiming to accomplish.
>
> When I restore a session, however, the my colorscheme is invoked as if
> g:Lapscreen doesn't exist. Would I be correct in assuming that the
> globals are restored *after* the colorscheme is invoked? I examined
> my session file and found no invocation of my colorscheme.

Check out :h initialization. It contains all necessary answers (note:
it is not explicitly mentioned *there* (it is in :h -S), but -S and -c
are processed in the same loop in the same initialization stage).

Note that &sessionoptions setting that allows disabling almost
everything is a great hint on *why* initialization is being done in
this order: it is rather explicit that session file assumes that most
of the initialization is done prior to loading it or omitting e.g.
options or mappings would not work normally (there are three main
variants:

1. Sessions are loaded prior to doing normal initialization: saving
mappings, options and globals in session files is almost pointless
because this way vimrc will simply override options from session.
2. Sessions are loaded *instead* of regular initialization: *omitting*
to save mappings, options and globals damages user experience,
especially given that most plugin managers require user to have
something in vimrc for plugins to work meaning that more things need
to be saved to work properly.
3. Sessions are loaded after regular initialization: mostly has no
problems, except cases like yours.
)

>
> --
> --
> 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+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

gvim colorscheme is run before global variables restored

My color scheme checks for the existence of a global variable
g:Lapscreen and modified colours accordingly. The colorscheme is
invoked from my vimrc. I have sessionoption set to include globals so
that the colorscheme does the right thing when my session is restored
-- or rather, that's what I'm aiming to accomplish.

When I restore a session, however, the my colorscheme is invoked as if
g:Lapscreen doesn't exist. Would I be correct in assuming that the
globals are restored *after* the colorscheme is invoked? I examined
my session file and found no invocation of my colorscheme.

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: make existing subwindow as preview window

2015/6/11(Thu) 10:25:34 UTC+9 Paul:
> Is there a way to make the current window into the preview window?
> In another window running netrw, I would then want to be able to
> press "p" on a file and have it show in the window that I designate
> for preview.

On Thursday, June 11, 2015 at 12:29:55 AM UTC-4, h_east wrote:
> Set 'previewwindow' option.
>
> :set previewwindow

On Thursday, June 11, 2015 at 12:24:35 PM UTC-4, DrChip wrote:
> You may also find :help g:netrw_chgwin and :help
> netrw-:Lexplore of interest. If your version of netrw doesn't
> support :Lexplore, then you can upgrade it by getting it from
> http://www.drchip.org/astronaut/vim/index.html#NETRW .

h_east, DrChip,

Thank you! The previewwindow option is exactly what I sought.

My netrw is the cygwin stock for Vim 7.4, patches 1-729. Lexplore
doesn't isn't on it, but I'm OK with just previewwindow for now (need
something quick).

Sorry for the long delay in replying. For some reason, I thought I
already did.

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: How to let vim immediate update the screen when I type ESC (in TUI mode)?

On Wednesday, June 24, 2015 at 8:42:01 AM UTC-5, Peng Yu wrote:
> Hi,
>
> For example, starting with normal model, then I type :, then type ESC,
> it will take some time (maybe a sec) for the ":" at the bottom of the
> screen to disappear (this is the case in TUI not GUI mode).
>
> How to let vim immediate update the screen when I type ESC in TUI mode?
>

Have you set up 'timeoutlen' and 'ttimeoutlen' appropriately?

Vim in a terminal must parse character sequences beginning with <Esc> to determine when special keys have been pressed, for example the arrow keys, and these options control how long Vim waits before deciding that there is no special key code coming, it really was just an <Esc>. See the help for these options.

Also, note that the command line can be closed with <C-C> as well.

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Problem with netrw and buftype

Christian Brabandt wrote:
> Hi wednesday!
>
> On Mi, 24 Jun 2015, wednesday wrote:
>
>> On Wed, Jun 24, 2015 at 02:25:03AM +0100, wednesday wrote:
>>> When I open up the explorer to put a new file into a split, once
>>> that new file is there the old one becomes unwritable due to buftype
>>> being set to nofile. This has been pretty frustrating and I have yet
>>> to find the answer. If this helps I'm using version 7.2.273 of Vim.
>> Pretty stupid of me, I think I just found the issue was having set
>> autochdir in my vimrc.
> Perhaps consider upgrading to a new Vim version (which should also
> contain an updated netrw), since 7.2.273 is 5.5 years old.
>
I'd suggest that you try the latest netrw
(http://www.drchip.org/astronaut/vim/index.html#NETRW) but with such an
old vim (vim is up to 7.4 with 752 patches) it won't work (latest netrw
requires 7.4 with patches 1-213 and will benefit from having patch#656).

Regards,
Chip Campbell

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

How to let vim immediate update the screen when I type ESC (in TUI mode)?

Hi,

For example, starting with normal model, then I type :, then type ESC,
it will take some time (maybe a sec) for the ":" at the bottom of the
screen to disappear (this is the case in TUI not GUI mode).

How to let vim immediate update the screen when I type ESC in TUI mode?

--
Regards,
Peng

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Problem with netrw and buftype

Hi wednesday!

On Mi, 24 Jun 2015, wednesday wrote:

> On Wed, Jun 24, 2015 at 02:25:03AM +0100, wednesday wrote:
> > When I open up the explorer to put a new file into a split, once
> > that new file is there the old one becomes unwritable due to buftype
> > being set to nofile. This has been pretty frustrating and I have yet
> > to find the answer. If this helps I'm using version 7.2.273 of Vim.
> Pretty stupid of me, I think I just found the issue was having set
> autochdir in my vimrc.

Perhaps consider upgrading to a new Vim version (which should also
contain an updated netrw), since 7.2.273 is 5.5 years old.

Best,
Christian
--
Nicht überall, wo Wasser ist, sind Frösche; aber wo man Frösche
hört, ist Wasser.
-- Goethe, Maximen und Reflektionen, Nr. 236

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: vim replace a string when a change occurred in another place

On 23.06.15 23:56, Rudra Banerjee wrote:
> Erik,
> Thanks for you comment....but it is solved. Now, another important
> thing....how to invoke it! Is it possible to have something like this:
>
> if (getline(".")) startswith "Program" au CursorMovedI call EdName()
>
> i.e. calling a autocmd conditionally possible?

One way is to add an extension to "Program" filenames, and then just use
the standard method described at ":h au". If you find that depressingly
M$-ish, then I'm forced to agree. The alternative of placing all the
files in one or a few directories, for detection by the pattern, may be
preferable.

Sadly, maddeningly, Vim's modelines only allow "set" commands, AFAICT.
That would otherwise be a delightfully elegant solution. (Though
doubtless not without security concerns, admittedly.)

Erik

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

errorformat Rhino js

let &makeprg='java -jar "rhino.jar" -strict -fatal-warnings "%:p"'
let &errorformat='%Ajs: "%f"\, line %l: %m,%Zjs: %p^,%C%.%#'

https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tuesday, June 23, 2015

Re: vim replace a string when a change occurred in another place

Erik,
Thanks for you comment....but it is solved. Now, another important thing....how to invoke it! Is it possible to have something like this:

if (getline(".")) startswith "Program"
au CursorMovedI call EdName()

i.e. calling a autocmd conditionally possible?

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: vim replace a string when a change occurred in another place

On 23.06.15 08:00, Rudra Banerjee wrote:
> function! Edname()
> python<<EOF
> import vim
> import fileinput
> with open("i.f90") as inp:
> for line in inp:
> if line.startswith("Program"):
> var = line.rsplit(' ', 1)[-1].strip()
> if line.startswith("End Program"):
> v2 = line.strip()
> print v2
> inp.close()
> STR="End Program "+var
> print STR
> for line in fileinput.input("i.f90", inplace=True):
> print line.replace(v2, STR).strip()
> EOF
> endfunction
>
> Now it is not working. It is printing the v2 and STR properly, but the
> file is NOT getting updated. Any clue?

Caveat: Yours is the first python program I've ever seen.
IIRC, it is the weird language which uses indentation
in place of brackets.

Tentative thoughts:
You have two file-reading loops, one of which appears to detect the
initial "foo", then print it. The second seems intended to make a single
replacement. If "inplace=True" ought to empower python to implicitly modify
the input file, then hopefully it is also implicitly printing the lines
you do not modify, or they must surely be lost? (Based solely on your
expectation that the input file should be modified, despite no explicit
mechanism to do that.)

Possible causes of failure:
Does the "i." indicate that file "f90" is opened for input? If so, then
how can you write to it? (Does python hide writing to a temp file, with
subsequent overwriting of the input file?) Is some form of
output.close() needed instead when closing for write? If python still
permits printing to stdout while "inplace=True", then you would need to
print to "f90", I expect, to modify the file instead. Are you relying
on the "endfunction" to implicitly invoke an ???.close() and that the
file will then be written?

I'm afraid that there's too much that is implicit in python for more
detailed guessing than that.

Erik

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Problem with netrw and buftype

On Wed, Jun 24, 2015 at 02:25:03AM +0100, wednesday wrote:
> When I open up the explorer to put a new file into a split, once that new file
> is there the old one becomes unwritable due to buftype being set to nofile.
> This has been pretty frustrating and I have yet to find the answer. If this
> helps I'm using version 7.2.273 of Vim.
Pretty stupid of me, I think I just found the issue was having set autochdir in
my vimrc.

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Search for character that doesn't have a combining character?

On Tuesday, June 23, 2015 at 4:20:32 PM UTC-5, ZyX wrote:
> 2015-06-24 0:02 GMT+03:00 Ben Fritz <fritzophrenic@gmail.com>:
> > On Tuesday, June 23, 2015 at 3:35:50 PM UTC-5, Ben Fritz wrote:
> >> I'm working on a custom command to add strikethrough to text, using the Unicode COMBINING LONG STROKE OVERLAY, 0x0336.
> >>
> >> In this command, I want to apply a strikethrough to a character, only if it is not already present.
> >>
> >> This pattern fails because it doesn't match *anything* with regexpengine set to 2, it does not match an unadorned character immediately before a struck-through base character, and it *does* match the last combining character in a word for some reason:
> >>
> >> [^\u0336]\%u0336\@!
> >>
> >> This pattern also fails, because it matches already struck-through base characters for some reason (although it does the same thing in both engines):
> >>
> >> [^\u0336][^\u0336]\@=
> >>
> >> What is the correct way to do this?
> >>
> >> Full command (attempted):
> >>
> >> '<,'>s;\%#=1\%V[^\u0336]\%u0336\@!;\=submatch(0)."\u0336";g
> >>
> >> Note, how I'm also limiting to a visual selection; so I'm trying to use the :s command for simplicity.
> >
> > My next attempt is to do two passes, first to remove the combining character from everywhere in the visual selection, and then to add it to the entire visual selection.
> >
> > But, my patterns for this task either don't match at all, or they remove the base character along with the combining character! Even this doesn't work, it removes the base character:
> >
> > echo join(split(getline('.'), "\u0336"),"")
>
> Though there is always one hack to get exactly one unicode codepoint
> from *valid* UTF-8 string:
>
> echo nr2char(char2nr(string[position :]))
>
> . You can use `len(nr2char(…))` to get the length of the first
> character and thus get to the second. I think this will allow you to
> construct needed \= expression, but the result would most likely be a
> definition of a new function due to its complexity.
>

Thanks! I agree this needs to be better supported in Vim's regex and tr() function. For my purposes I can pretty much always assume any combining characters are the strikethrough characters, making the replacement function trivial to implement with a nr2char(char2nr(submatch(0))) hack, but obviously this is not a good general solution as it will strip off all other combining characters when adding or removing the one character I'm actually interested in. I guess I could loop through the input string as you suggest if I'm interested in making a general solution at some point.

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Search for character that doesn't have a combining character?

2015-06-24 0:02 GMT+03:00 Ben Fritz <fritzophrenic@gmail.com>:
> On Tuesday, June 23, 2015 at 3:35:50 PM UTC-5, Ben Fritz wrote:
>> I'm working on a custom command to add strikethrough to text, using the Unicode COMBINING LONG STROKE OVERLAY, 0x0336.
>>
>> In this command, I want to apply a strikethrough to a character, only if it is not already present.
>>
>> This pattern fails because it doesn't match *anything* with regexpengine set to 2, it does not match an unadorned character immediately before a struck-through base character, and it *does* match the last combining character in a word for some reason:
>>
>> [^\u0336]\%u0336\@!
>>
>> This pattern also fails, because it matches already struck-through base characters for some reason (although it does the same thing in both engines):
>>
>> [^\u0336][^\u0336]\@=
>>
>> What is the correct way to do this?
>>
>> Full command (attempted):
>>
>> '<,'>s;\%#=1\%V[^\u0336]\%u0336\@!;\=submatch(0)."\u0336";g
>>
>> Note, how I'm also limiting to a visual selection; so I'm trying to use the :s command for simplicity.
>
> My next attempt is to do two passes, first to remove the combining character from everywhere in the visual selection, and then to add it to the entire visual selection.
>
> But, my patterns for this task either don't match at all, or they remove the base character along with the combining character! Even this doesn't work, it removes the base character:
>
> echo join(split(getline('.'), "\u0336"),"")

Though there is always one hack to get exactly one unicode codepoint
from *valid* UTF-8 string:

echo nr2char(char2nr(string[position :]))

. You can use `len(nr2char(…))` to get the length of the first
character and thus get to the second. I think this will allow you to
construct needed \= expression, but the result would most likely be a
definition of a new function due to its complexity.

>
> --
> --
> 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+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Search for character that doesn't have a combining character?

2015-06-24 0:02 GMT+03:00 Ben Fritz <fritzophrenic@gmail.com>:
> On Tuesday, June 23, 2015 at 3:35:50 PM UTC-5, Ben Fritz wrote:
>> I'm working on a custom command to add strikethrough to text, using the Unicode COMBINING LONG STROKE OVERLAY, 0x0336.
>>
>> In this command, I want to apply a strikethrough to a character, only if it is not already present.
>>
>> This pattern fails because it doesn't match *anything* with regexpengine set to 2, it does not match an unadorned character immediately before a struck-through base character, and it *does* match the last combining character in a word for some reason:
>>
>> [^\u0336]\%u0336\@!
>>
>> This pattern also fails, because it matches already struck-through base characters for some reason (although it does the same thing in both engines):
>>
>> [^\u0336][^\u0336]\@=
>>
>> What is the correct way to do this?
>>
>> Full command (attempted):
>>
>> '<,'>s;\%#=1\%V[^\u0336]\%u0336\@!;\=submatch(0)."\u0336";g
>>
>> Note, how I'm also limiting to a visual selection; so I'm trying to use the :s command for simplicity.
>
> My next attempt is to do two passes, first to remove the combining character from everywhere in the visual selection, and then to add it to the entire visual selection.
>
> But, my patterns for this task either don't match at all, or they remove the base character along with the combining character! Even this doesn't work, it removes the base character:
>
> echo join(split(getline('.'), "\u0336"),"")

I was about to suggest to use tr(), but:

echo tr("o\u0336", "o", "t") is# "o\u0336"
echo tr("o\u0336", "\u0336", "t") is# "o\u0336"
echo tr("o\u0336", "o\u0336", "t") is# "t"

apparently tr() thinks that character is a unicode codepoint *with*
all of the following combining characters.

I would say here that

1. Regexp engines need proper `\p` support from Perl/PCRE. Or, at
least, the opposite of \Z which tells RE engine to treat all unicode
codepoints in the same way.
2. tr() must *always* use "one character is one unicode codepoint"
when &encoding is unicode. It is too low-level tool to care about
character classes, and especially to join codepoints together.

>
> --
> --
> 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+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.