Thursday, March 31, 2016

Using gx with text-only browser

I usually use nvim at the console and would like to set gx to open a URL
under the cursor with /usr/bin/links. I have tried setting these options:

let netrw_browsex_viewer=``/usr/bin/links''
let netrw_http_cmd=``links''

All that happens, though, is that the console screen blinks while the
lookup silently fails. If anyone could suggest the correct way to do
this I'd appreciate it.

(BTW when I run nvim in an xterm, gx calls up chrome with no problems.)

--
Peter King peter.king@utoronto.ca
Department of Philosophy
170 St. George Street #521
The University of Toronto (416)-978-3311 ofc
Toronto, ON M5R 2M8
CANADA

http://individual.utoronto.ca/pking/

=========================================================================
GPG keyID 0x7587EC42 (2B14 A355 46BC 2A16 D0BC 36F5 1FE6 D32A 7587 EC42)
gpg --keyserver pgp.mit.edu --recv-keys 7587EC42

--
--
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: Using g://w to filter a buffer

Thanks for the answers.

@DrChip: Hey, you know what I want ;-)

--
--
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.

Outlining folding rule

The following foldexpr is giving me headaches because it doesn't work
under all circumstances:


fun! s:outlinerFoldingRule(n)
return getline(a:n) =~ '^\s*:' ?
\ 20 : indent(a:n) < indent(a:n+1) ?
\ ('>'.(1+indent(a:n)/&l:tabstop)) : (indent(a:n)/&l:tabstop)
endf

fun! Outliner()
setlocal autoindent
setlocal formatoptions=tcqrn1jo
setlocal comments=fb:*,fb:-,b::
setlocal textwidth=80
setlocal foldmethod=expr
setlocal foldexpr=s:outlinerFoldingRule(v:lnum)
setlocal foldlevel=2
let &l:tabstop=4
let &l:shiftwidth=4
let &l:softtabstop=4
endf

Sample text (copy and paste in a new buffer):

1 Title
1.1
: Note 1
: Some note
1.1.1
1.1.1.1
: Note 2
: Some note
1.1.1.2
1.1.2
1.1.2.1


After :call Outliner(), za folds/unfolds all sections, except for notes.
If I give zR then everything folds/unfolds as expected. But then, if I add
a section (say, 1.1.3) then things go nuts: for example, za on 1.1.2 folds
1.1 instead of 1.1.2. In other cases, I get "No fold found" errors.
Call Outliner() again and press zR, and everything is fine again (until
the next modification). What's wrong with the code above?

Nicola





--
--
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: Find white spaces

On Thursday, March 31, 2016 at 3:08:12 PM UTC-5, ratheesh kannoth wrote:
> Hi list,
>
> I would like search to spaces which is not tab or 1 white space.
>
>
> int main()
> {
> int fox; /* This is a fox */
> }
>
> I need a regex which can find the space between "fox;" and the comment above

In other words, you need to match "two or more spaces"?

Any of these should work:

/ \+
/ \{2,}
/ *

--
--
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: [Bulk] Using g://w to filter a buffer

Am 31.03.2016 um 17:40 schrieb Axel Bender:
> Given the following description in the docs
>
> "The global commands work by first scanning through the [range] lines and
> marking each line where a match occurs (for a multi-line pattern, only the
> start of the match matters).
> In a second scan the [cmd] is executed for each marked line with its line
> number prepended."
>
> shouldn't this filter a buffer
>
> "g/some pattern/w! >> some_file.txt"
>
> to a new file, considering that
>
> ".w! >> some_file.txt"
>
> works?

The docs lie, the line number is not prepended.

--
Andy

--
--
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: Using g://w to filter a buffer

Axel Bender wrote:
> Given the following description in the docs
>
> "The global commands work by first scanning through the [range] lines and
> marking each line where a match occurs (for a multi-line pattern, only the
> start of the match matters).
> In a second scan the [cmd] is executed for each marked line with its line
> number prepended."
>
> shouldn't this filter a buffer
>
> "g/some pattern/w! >> some_file.txt"
>
> to a new file, considering that
>
> ".w! >> some_file.txt"
>
> works?
>
What's not working? Here's an explanation:

g/some pattern/ For every line in the file that matches the pattern
w! >> some_file.txt write the entire file to some_file.txt

Assuming you've got more than one match, you'll get more than one copy
of the entire buffer in the file, appended to whatever happened to be
there before the command.
Perhaps you wanted to use :g/some pattern/.w! >> some_file.txt ?

Regards,
Chip

--
--
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.

Using g://w to filter a buffer

Given the following description in the docs

"The global commands work by first scanning through the [range] lines and
marking each line where a match occurs (for a multi-line pattern, only the
start of the match matters).
In a second scan the [cmd] is executed for each marked line with its line
number prepended."

shouldn't this filter a buffer

"g/some pattern/w! >> some_file.txt"

to a new file, considering that

".w! >> some_file.txt"

works?

--
--
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.

Find white spaces

Hi list,

I would like search to spaces which is not tab or 1 white space.


int main()
{
int fox; /* This is a fox */
}

I need a regex which can find the space between "fox;" and the comment above

--
--
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, March 30, 2016

Re: junk characters printed when I type ESC

Am 2016-03-30 22:51, schrieb Sergei G:
> I attached screenshot of the kind of junk characters printed on the
> 1st line at the beginning of the line.
>
> Step to reproduce: press ESC in Insert mode.
>
> These characters are display only. If I get VIM to refresh (Ctrl-Z to
> background and back to foreground) characters will be gone.
>
>
> My configuration:
>
> Debian 8.2
> VIM 7.4, included patches 1-488, 576.
>
> I narrowed down the issue to the following part of vimrc
> configuration. While the issue is fixed I have a few questions.
>
> I use ssh a lot and I can be using a different terminal application.
> Every terminal app pretends to be xterm, but every terminal is
> slightly different. For example we have putty, Tera Term, Gnome's
> Terminal, cygwin, xterm itself. What's a better way to tweak vim
> configuration to a specific terminal. I created MYHOST variable that
> points to cygwin in cygwin case.
>
> Shall I tell each terminal to report its name (TERM variable) at a
> risk of having a lot of other software totally confused?

It looks like this setting is causing this:
> let &t_EI.="\e[1 q"

Why do you append to the existing t_EI setting? And if you comment out
this
section, does it still happen?

Best,
Christian

--
--
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: Packages and plugin's subdirectories

Nicola wrote:

> On 2016-03-30 04:43:56 +0000, Nicola said:
> >
> > If that is the intended behaviour, maybe it should be noted more explicitly
> > in the help files. In `:h packages`, it is written that Vim:
>
> Also note this difference: if pack/foo/opt/neocomplete is loaded during a
> session with `:packadd neocomplete`, only one file is sourced, because only
> the package mechanism kicks in. But `packadd! neocomplete` is put in .vimrc,
> then all files are sourced, because that adds the path to runtimepath before
> the plugin loading phase kicks in.

Good point, we don't want this to work differently.

--
If Apple would build a car...
... it would be powered by the sun, be reliable, five times
as fast and twice as easy to drive; but would only run on
five percent of the roads.

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.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.

junk characters printed when I type ESC

I attached screenshot of the kind of junk characters printed on the 1st line at the beginning of the line.

Step to reproduce: press ESC in Insert mode.

These characters are display only. If I get VIM to refresh (Ctrl-Z to background and back to foreground) characters will be gone.


My configuration:

Debian 8.2
VIM 7.4, included patches 1-488, 576.

I narrowed down the issue to the following part of vimrc configuration. While the issue is fixed I have a few questions.

I use ssh a lot and I can be using a different terminal application. Every terminal app pretends to be xterm, but every terminal is slightly different. For example we have putty, Tera Term, Gnome's Terminal, cygwin, xterm itself. What's a better way to tweak vim configuration to a specific terminal. I created MYHOST variable that points to cygwin in cygwin case.

Shall I tell each terminal to report its name (TERM variable) at a risk of having a lot of other software totally confused?

" check if in tera term (the code used to check for xterm)
if &term =~ "teraterm"
" In Gnome 3's Terminal pressing ESC prints junk characters
" instead of changing cursor.
" Thus, I have disabled the code that's known to work in Tera Term and
" Cygwin

" Tera Term scenario as documented in
" http://www.teraterm.org/manual/en/usage/tips/vim.html
"
" In insert mode: Blink vertical line
let &t_SI.="\e[5 q"
" In normal mode: Blink block
let &t_EI.="\e[1 q"
" delay to wait for cursor to change from Insert to Normal mode
" temoutlen solution appears to be the least complicated and it works
set timeoutlen=160

" For details about
" - Speed up vsplit scrolling
" - Auto indent can be disabled on pasting from clipboard
" See:
" http://www.teraterm.org/manual/en/usage/tips/vim.html

" Allow title retrival and storage
" Thus default phraze "thanks for flying vim" is not displayed
let &t_ti .= "\e[22;0t"
let &t_te .= "\e[23;0t"
endif

--
--
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, March 29, 2016

Load all opt plugins in a package at once?

(Sorry for yet another post, but I have embraced packages and I really like
them!)

To load all the optional plugins of a package a :packadd command must be issued
once for each plugin.

What do you think about adding a command that loads all the plugins in an opt
directory at once? Something like:

:packaddall[!] {name} Search for a package directory in 'packpath' and source
all the plugin files found inside each optional plugin
directory in that package. The directory must match:
pack/{name}
For each directory pack/{name}/opt/foobar, a
`:packadd[!] foobar` command is issued.

A command like the above might not be necessary in a (future) world where each
plugin takes care of loading its own dependencies from the same package. But
I can imagine a situation in which a user may build its own package by putting
together loosely coupled plugins. Or a package that provides some optional
extensions, which are independent of each other. In those cases, a command like
the above might be convenient.

Nicola



--
--
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: Packages and plugin's subdirectories

On 2016-03-30 04:43:56 +0000, Nicola said:
>
> If that is the intended behaviour, maybe it should be noted more explicitly
> in the help files. In `:h packages`, it is written that Vim:

Also note this difference: if pack/foo/opt/neocomplete is loaded during a
session with `:packadd neocomplete`, only one file is sourced, because only
the package mechanism kicks in. But `packadd! neocomplete` is put in .vimrc,
then all files are sourced, because that adds the path to runtimepath before
the plugin loading phase kicks in.

Nicola


--
--
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: Packages and plugin's subdirectories

On 2016-03-29 19:53:07 +0000, Bram Moolenaar said:

> Nicola wrote:
>
>> Neocomplete's plugin folder is organized as follows:
>>
>> plugin/
>> neocomplete.vim
>> neocomplete/
>> buffer.vim
>> dictionary.vim
>> tag.vim
>>
>> No matter whether neocomplete is in pack/*/start/ or in pack/*/opt/,
>> only plugin/neocomplete.vim is loaded (at startup or with :packadd,
>> respectively). Is that a bug?
>>
>> Using Vim 7.4.1655.
>
> The reason neocomplete does it this way, AFAIK, is to avoid having too
> many files in the top plugin directory. It's shared with all other
> plugins.
>
> For a package this problem does not exist. You can simply put all files
> in the plugin directory:
> pack/start/neo/plugin/
> neocomplete.vim
> buffer.vim
> dictionary.vim
> tag.vim
>
> It saves a bit of time searching directories.
>
> If someone sees a good reason to also search in subdirectories, let's
> hear it.

If that is the intended behaviour, maybe it should be noted more explicitly
in the help files. In `:h packages`, it is written that Vim:

[...] scans all directories in 'packpath' for plugins [...] and loads them.
The directory is added to 'runtimepath'. In the example Vim will find [...]
and adds "~/.vim/pack/foo/start/foobar to 'runtimepath'.

And in `:h packadd`:

If the "{name}/plugin" directory contains more than one file they are all
sourced.

One is brought to think that things works as if having put the paths in
runtimepath to begin with (at least, that is what I thought).

Nicola


--
--
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: Packages and plugin's subdirectories

2016-03-29 22:53 GMT+03:00 Bram Moolenaar <Bram@moolenaar.net>:
>
> Nicola wrote:
>
>> Neocomplete's plugin folder is organized as follows:
>>
>> plugin/
>> neocomplete.vim
>> neocomplete/
>> buffer.vim
>> dictionary.vim
>> tag.vim
>>
>> No matter whether neocomplete is in pack/*/start/ or in pack/*/opt/,
>> only plugin/neocomplete.vim is loaded (at startup or with :packadd,
>> respectively). Is that a bug?
>>
>> Using Vim 7.4.1655.
>
> The reason neocomplete does it this way, AFAIK, is to avoid having too
> many files in the top plugin directory. It's shared with all other
> plugins.
>
> For a package this problem does not exist. You can simply put all files
> in the plugin directory:
> pack/start/neo/plugin/
> neocomplete.vim
> buffer.vim
> dictionary.vim
> tag.vim
>
> It saves a bit of time searching directories.
>
> If someone sees a good reason to also search in subdirectories, let's
> hear it.

This variant is not usable for the following reasons:

1. Keeping compatibility with Vim versions that do not have packages.
No, creating distributions is not an option here: users want to just
`git clone` to a right location.
2. Force loading using :runtime of files that have "generic" names
does not work well.
3. This destroys the hierarchy. Initial variant has clear "main" file
neocomplete.vim and "secondary" files buffer.vim, etc. They do not
depend on each other, but their total contents is really just enough
for one file, not four.
4. Keeping compatibility with *package managers* (not Vim-specific
plugin managers, I talk about systems ones) which are rather
conservative and would not thank you if you will force to rewrite
build scripts because new plugin distribution expects to be installed
*only* as a package (and nobody wants to maintain multiple
distributions).

One can, of course, use neocomplete_buffer.vim, etc, but this is a
hack with necessity emerged out of thin air, nobody likes this. Also
do not forget that "just git clone" also applies to plugins that are
no longer maintained.

>
> --
> You're as much use as a condom machine at the Vatican.
> -- Rimmer to Holly in Red Dwarf 'Queeg'
>
> /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
> /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
> \\\ an exciting new programming language -- http://www.Zimbu.org ///
> \\\ help me help AIDS victims -- http://ICCF-Holland.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.

--
--
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: Packages and plugin's subdirectories

Nicola wrote:

> Neocomplete's plugin folder is organized as follows:
>
> plugin/
> neocomplete.vim
> neocomplete/
> buffer.vim
> dictionary.vim
> tag.vim
>
> No matter whether neocomplete is in pack/*/start/ or in pack/*/opt/,
> only plugin/neocomplete.vim is loaded (at startup or with :packadd,
> respectively). Is that a bug?
>
> Using Vim 7.4.1655.

The reason neocomplete does it this way, AFAIK, is to avoid having too
many files in the top plugin directory. It's shared with all other
plugins.

For a package this problem does not exist. You can simply put all files
in the plugin directory:
pack/start/neo/plugin/
neocomplete.vim
buffer.vim
dictionary.vim
tag.vim

It saves a bit of time searching directories.

If someone sees a good reason to also search in subdirectories, let's
hear it.

--
You're as much use as a condom machine at the Vatican.
-- Rimmer to Holly in Red Dwarf 'Queeg'

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.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.

Re: Does vimscript have a "stat()" command?

Josef Fortier wrote:
>> I can suggest using filewritable()
> Thanks! This works well
> (FWIW I'm using filereadable() followed by filewriteable() to avoid no file conditions).
>
Depending on what you're doing, you also might want to use isdirectory().

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: Does vimscript have a "stat()" command?

> I can suggest using filewritable()

Thanks! This works well
(FWIW I'm using filereadable() followed by filewriteable() to avoid no file conditions).

--
--
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.

Feature Request: i_CTRL-X_iCTRL-P draw from other buffers like i_CTRL-P

I've really come to enjoy the <C-X><C-P> mapping (i've hijacked i_CTRL-J for it). It's more flexible then straight C-P, allowing a form of line completion. But it has one real drawback, it only draws from the current buffer. Is there a fundamental reason it can't draw completion candidates from other open buffers, much like i_CTRL-P does?
Is there a good place to make this suggestion other then here?
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.

Packages and plugin's subdirectories

Neocomplete's plugin folder is organized as follows:

plugin/
neocomplete.vim
neocomplete/
buffer.vim
dictionary.vim
tag.vim

No matter whether neocomplete is in pack/*/start/ or in pack/*/opt/,
only plugin/neocomplete.vim is loaded (at startup or with :packadd,
respectively). Is that a bug?

Using Vim 7.4.1655.

Nicola


--
--
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: Build cexpr from result of python code.

On Thursday, March 24, 2016 at 9:22:37 PM UTC+1, ZyX wrote:
> 2016-03-24 13:26 GMT+03:00 Ni Va <nivaemail@gmail.com>:
> > On Monday, March 21, 2016 at 4:45:45 PM UTC+1, ZyX wrote:
> >> 2016-03-21 17:15 GMT+03:00 Ni Va <nivaemail@gmail.com>:
> >> > Hi,
> >> >
> >> > I am using Execute-selection-in-Python-and-append-master plugin in order to test python code directly through vim. Now the python code is working and return me a list that contains strings typed like "file linenumber linecontent".
> >> >
> >> > I would like not to replace buffer content by result of python code but affect cexpr to the list content in order to navigate through results with quickfix list.
> >>
> >> You can use
> >>
> >> vim.Function('setqflist')([{'filename': file, 'lnum': linenumber,
> >> 'text': linecontent}])
> >>
> >> to set quickfix list from Python code. This assumes that you are doing
> >> parsing yourself.
> >>
> >> Or pyeval() in :cexpr to make Vim do parsing. Just return `output`
> >> directly without doing anything with `r` and your function should be
> >> ready for use in :cexpr assuming correct &errorformat value.
> >>
> >> >
> >> > Can you help me to build that cexpr list ?
> >> >
> >> > By advance Thank you
> >> >
> >> >
> >> > Here it is the code of PyExecReplace that replace content of my buffer (python code) by result of execution code.
> >> >
> >> >
> >> > python << EOL
> >> > import vim, StringIO,sys
> >> >
> >> > def PyExecReplace(line1,line2):
> >> > r = vim.current.buffer.range(int(line1),int(line2))
> >> > redirected = StringIO.StringIO()
> >> > sys.stdout = redirected
> >> > exec('\n'.join(r[:]) + '\n')
> >> > sys.stdout = sys.__stdout__
> >> > output = redirected.getvalue().split('\n')
> >> > r[:] = output[:-1] # the -1 is to remove the final blank line
> >> > # vim.command("echo "+"-".join(("a", "b", "c")))
> >> > redirected.close()
> >> > EOL
> >> > command! -range Pyer python PyExecReplace(<f-line1>,<f-line2>)
> >> > command! -range Pyea python PyExecAppend(<f-line1>,<f-line2>)
> >> >
> >> > --
> >> > --
> >> > 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.
> >
> >
> > Thank you ZyX !
> >
> > I give you the following code if it can help for someone else. Execute-selection-in-Python-and-append-master with a third function that returns only output :
> > python << EOL
> > import vim, StringIO, string, sys
> > def PyExecAppend(line1,line2):
> > r = vim.current.buffer.range(int(line1),int(line2))
> > redirected = StringIO.StringIO()
> > sys.stdout = redirected
> > exec('\n'.join(r[:]) + '\n')
> > sys.stdout = sys.__stdout__
> > output = redirected.getvalue().split('\n')
> > r.append(output[:-1]) # the -1 is to remove the final blank line
> > redirected.close()
> >
> > def PyExecReplace(line1,line2):
> > r = vim.current.buffer.range(int(line1),int(line2))
> > redirected = StringIO.StringIO()
> > sys.stdout = redirected
> > exec('\n'.join(r[:]) + '\n')
> > sys.stdout = sys.__stdout__
> > output = redirected.getvalue().split('\n')
> > r[:] = output[:-1] # the -1 is to remove the final blank line
> > redirected.close()
> >
> > def PyExecOut(line1,line2):
> > r = vim.current.buffer.range(int(line1),int(line2))
> > redirected = StringIO.StringIO()
> > sys.stdout = redirected
> > exec('\n'.join(r[:]) + '\n')
> > sys.stdout = sys.__stdout__
> > output = redirected.getvalue().split('\n')
> > redirected.close()
> > return output
> > EOL
> > command! -range Pyeo python PyExecOut(<f-line1>,<f-line2>)
> > command! -range Pyer python PyExecReplace(<f-line1>,<f-line2>)
> > command! -range Pyea python PyExecAppend(<f-line1>,<f-line2>)
> >
> >
> >
> >
> > Then I have just a last problem, in my main code that build setqflist I have only the last occurence and not all (6 occurences) despite the 'a' option.
> >
> >
> > for filepath in myDict.keys():
> > for line in myDict[filepath]:
> > print filepath + " line " + '{:>5}'.format(str(line[0])) + " : " + line[1]
> > vim.Function('setqflist')([{'filename': filepath, 'lnum': line[0], 'text': line[1]},'a'])
>
> You probably meant `setqflist([{'filename': filepath, 'lnum': line[0],
> 'text': line[1]}], 'a')`, not `'a'` inside an array supplied as a
> first argument.
>
> I would also suggest to save the result of calling
> `vim.Function('setqflist')` into a variable if you call it more then
> once.
>
> >
> > --
> > --
> > 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 ZyX,

Thank you for all, I have applied this code finally :

import os, fnmatch, re, vim

.. some functions

myListOfFiles = findFiles(topdir, fileExtens)
myDict = findPatternInFile(myListOfFiles, r'^[^>]+KEYWORD')


qflist = []
for filepath in myDict.keys():
for line in myDict[filepath]:
print filepath + " line " + '{:>5}'.format(str(line[0])) + " : " + line[1]
qflist.append({'filename': filepath, 'lnum': line[0], 'text': line[1]})

vim.Function('setqflist')(qflist)

-------------

--
--
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: cmdheight

* Elimar Riesebieter <riesebie@lxtec.de> [2016-03-26 16:24 +0100]:

> Hi all,
>
> if I set cmdheight to a value greater than 1 I don't see the output
> of ":echo b:variable" or "let b:variable" anymore. The result pops
> up for a tenth of a sencind or so.

It seems that a misconfigured vim-bufferline caused this problem.
Everything fine now.

Elimar
--
On the keyboard of life you have always
to keep a finger at the escape key;-)

--
--
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, March 28, 2016

Re: Does vimscript have a "stat()" command?

2016-03-28 22:36 GMT+03:00 Josef Fortier <josef.fortier@gmail.com>:
> I'm looking to automatically invoke the (tpope or chrisbra) "SudoEdit" function when the file is root owned. I've set up a call to (unixland) "stat" via systemlist() but it seems like vimscript should be able to find the file owner. I'm likely missing something, but I've not found it yet. Is there a way to test file ownership in vimscript?

I do not know such function, except that you can do this via pyeval()
or py3eval(). I can suggest using filewritable() instead, this will
also enable using sudo to edit other users' files.

>
> --
> --
> 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: Packages: best practices?

Am 26.03.2016 um 21:03 schrieb Gary Johnson:
> On 2016-03-26, Andy Wokula wrote:
>> if has("vim_starting")
>> " init on VimEnter
>> else
>> " init immediately
>> endif
>
> That's a very odd application of has().
>
> The has() function is clearly intended to indicate presence or
> absence of some feature that is compiled in, or in the case of
> "gui_running", available only under certain unchanging conditions.
> I would never think to look among features for a flag indicating the
> startup state. Even Bram did not find it.

Proper linking in the help should be enough?

> It's probably too late to change it, but I think it would make more
> sense to expose that state as a variable such as v:vim_starting or
> v:vim_did_enter or as a function such as vim_starting().
>
> Regards,
> Gary

It has been there for a long time (Vim 5.7 or earlier).

There are other "dynamic" items:
has("multi_byte_encoding")
has("syntax_items")
...

--
Andy

--
--
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.

Does vimscript have a "stat()" command?

I'm looking to automatically invoke the (tpope or chrisbra) "SudoEdit" function when the file is root owned. I've set up a call to (unixland) "stat" via systemlist() but it seems like vimscript should be able to find the file owner. I'm likely missing something, but I've not found it yet. Is there a way to test file ownership in vimscript?

--
--
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, March 26, 2016

Re: Packages: best practices?

Andy Wokula wrote:

> Am 26.03.2016 um 19:31 schrieb Nicola:
> > On 2016-03-26 17:56:34 +0000, Bram Moolenaar said:
>
> >> I suppose there is no easy way to know if VimEnter already fired.
>
> >> Perhaps we need a flag that indicatest this, so you can do:
> >>
> >> if v:vim_did_enter
> >> call s:init()
> >> else
> >> au VimEnter * call s:init()
> >> endif
> >>
> >> Something like that?
> >
> > For YCM, that would work. I don't know what else a plugin can do at startup that
> > would not do if loaded at a later time (other types of autocmds?).
> >
> > Nicola
>
> if has("vim_starting")
> " init on VimEnter
> else
> " init immediately
> endif

Ah, forgot about that one. And couldn't find it, it doesn't have a help
tag (added one).

Turns out it's very close to v:vim_did_enter. Should we revert adding
v:vim_did_enter ?

--
There are three kinds of persons: Those who can count and those who can't.

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.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.

Re: Packages: best practices?

On 2016-03-26, Andy Wokula wrote:
> Am 26.03.2016 um 19:31 schrieb Nicola:
> >On 2016-03-26 17:56:34 +0000, Bram Moolenaar said:
>
> >>I suppose there is no easy way to know if VimEnter already fired.
>
> >>Perhaps we need a flag that indicatest this, so you can do:
> >>
> >> if v:vim_did_enter
> >> call s:init()
> >> else
> >> au VimEnter * call s:init()
> >> endif
> >>
> >>Something like that?
> >
> >For YCM, that would work. I don't know what else a plugin can do at startup that
> >would not do if loaded at a later time (other types of autocmds?).
> >
> >Nicola
>
> if has("vim_starting")
> " init on VimEnter
> else
> " init immediately
> endif

That's a very odd application of has().

The has() function is clearly intended to indicate presence or
absence of some feature that is compiled in, or in the case of
"gui_running", available only under certain unchanging conditions.
I would never think to look among features for a flag indicating the
startup state. Even Bram did not find it.

It's probably too late to change it, but I think it would make more
sense to expose that state as a variable such as v:vim_starting or
v:vim_did_enter or as a function such as vim_starting().

Regards,
Gary

--
--
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: Packages: best practices?

On 2016-03-26 18:53:44 +0000, Andy Wokula said:

> if has("vim_starting")
> " init on VimEnter
> else
> " init immediately
> endif

That works, thanks!

Nicola


--
--
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: Packages: best practices?

Am 26.03.2016 um 19:31 schrieb Nicola:
> On 2016-03-26 17:56:34 +0000, Bram Moolenaar said:

>> I suppose there is no easy way to know if VimEnter already fired.

>> Perhaps we need a flag that indicatest this, so you can do:
>>
>> if v:vim_did_enter
>> call s:init()
>> else
>> au VimEnter * call s:init()
>> endif
>>
>> Something like that?
>
> For YCM, that would work. I don't know what else a plugin can do at startup that
> would not do if loaded at a later time (other types of autocmds?).
>
> Nicola

if has("vim_starting")
" init on VimEnter
else
" init immediately
endif

--
Andy

--
--
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: Packages: best practices?

On 2016-03-26 17:56:34 +0000, Bram Moolenaar said:

> Nicola wrote:
>
>>> Then, everything should work as before, with the exception of YCM, which must
>>> now be loaded manually. To do so, I need
>>>
>>> :packadd youcompleteme
>>>
>>> but also
>>>
>>> :call youcompleteme#Enable()
>>>
>>> because :packadd does not trigger VimEnter.
>>
>> This is a bit a of a pain. How about having `:packadd` trigger an event that
>> plugins may hook to?
>
> I'm not sure what you mean. Doesn't youcompleteme do its initialization
> when it is being loaded?
>
> Hmm, maybe it relies on being sourced early, and has a VimEnter
> autocommand to trigger initialization?

Exactly. See:

https://github.com/Valloric/YouCompleteMe/blob/master/plugin/youcompleteme.vim#L166


It has:

autocmd VimEnter * call youcompleteme#Enable()

> I suppose there is no easy way to know if VimEnter already fired.
> Perhaps we need a flag that indicatest this, so you can do:
>
> if v:vim_did_enter
> call s:init()
> else
> au VimEnter * call s:init()
> endif
>
> Something like that?

For YCM, that would work. I don't know what else a plugin can do at
startup that
would not do if loaded at a later time (other types of autocmds?).

Nicola


--
--
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: Packages: best practices?

Nicola wrote:

> > Then, everything should work as before, with the exception of YCM, which must
> > now be loaded manually. To do so, I need
> >
> > :packadd youcompleteme
> >
> > but also
> >
> > :call youcompleteme#Enable()
> >
> > because :packadd does not trigger VimEnter.
>
> This is a bit a of a pain. How about having `:packadd` trigger an event that
> plugins may hook to?

I'm not sure what you mean. Doesn't youcompleteme do its initialization
when it is being loaded?

Hmm, maybe it relies on being sourced early, and has a VimEnter
autocommand to trigger initialization?

I suppose there is no easy way to know if VimEnter already fired.
Perhaps we need a flag that indicatest this, so you can do:

if v:vim_did_enter
call s:init()
else
au VimEnter * call s:init()
endif

Something like that?

--
All true wisdom is found on T-shirts.

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.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.

Re: Packages: best practices?

On 2016-03-25 19:15:59 +0000, Nicola said:


I would like to start using Vim's new package feature, but first I want to make

sure that I have understood how it is supposed to be used. Is it too early to

ask for tips about that?


First let me summarize what I have understood about packages (please correct

anything wrong):


- every package must be inside a directory called `pack` (`~/.vim/pack`).


- Each package should have (at least one of) two subdirectories: `start` and

  `opt`.


- Plugins and ftplugins that must be available at launch time must go inside

  `start`. What actually happens is that *any* directory under `start` is added

  to `runtimepath` at startup independent of its content (much like Pathogen

  does). Besides, if a directory contains a `plugin/foo.vim` file, that file is

  sourced.


- Plugins and ftplugins that you want to be loaded lazily/manually go inside

  `opt`. These may be loaded with `:packadd`. This is not exactly like loading

  a plugin at startup, though, because if a plugin does something on VimEnter,

  that something must be triggered manually.


- The `colorscheme` command searches both `pack/*/start` and `pack/*/opt/`

  (beside `runtimepath`), so it does not matter where a colorscheme is.


If the above is accurate, I would give the following recommendations:


- Always put filetype plugins (no `plugin/foo.vim`) inside `start`. I see no

  reason why you would want to do otherwise (unless you have a filetype that you

  seldom use and you really want to keep `runtimepath` as small as possible).

  This type of plugin does not cause any file to be loaded at startup, unless

  there is an `ftdetect/xyz.vim` file.


- Always put colorschemes inside `opt`. This avoid cluttering `runtimepath`, and

  they are found anyway.


I have implemented the schema above, using the following directory structure:


pack/

  bundle/

    start/

    opt/

  themes/

    opt/


All seems fine. For colorschemes things are not as simple as I have described

above, because they may contain autoload directories, with (typically) stuff for

Airline/Lightline or for GUI Vim. Since I don't use those, for me it's fine to

have colorschemes inside `opt`, but in general some colorschemes would better go

inside `start`.


Plugins that I had blacklisted in Pathogen are now in bundle/opt. Pathogen lives

in bundle/opt, too: I still use it as a fallback when packages are not available.


A positive note is that the startup time has improved ~25% (now it's ~60ms).


Then, everything should work as before, with the exception of YCM, which must

now be loaded manually. To do so, I need


:packadd youcompleteme


but also


:call youcompleteme#Enable()


because :packadd does not trigger VimEnter.


This is a bit a of a pain. How about having `:packadd` trigger an event that

plugins may hook to?


Nicola


cmdheight

Hi all,

if I set cmdheight to a value greater than 1 I don't see the output
of ":echo b:variable" or "let b:variable" anymore. The result pops
up for a tenth of a sencind or so.

Any help would be appreciated.

Thanks
--
.~.
/V\ L I N U X
/( )\ >Phear the Penguin<
^^-^^

--
--
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, March 25, 2016

Packages: best practices?

I would like to start using Vim's new package feature, but first I want to make
sure that I have understood how it is supposed to be used. Is it too early to
ask for tips about that?

First let me summarize what I have understood about packages (please correct
anything wrong):

- every package must be inside a directory called `pack` (`~/.vim/pack`).

- Each package should have (at least one of) two subdirectories: `start` and
`opt`.

- Plugins and ftplugins that must be available at launch time must go inside
`start`. What actually happens is that *any* directory under `start` is added
to `runtimepath` at startup independent of its content (much like Pathogen
does). Besides, if a directory contains a `plugin/foo.vim` file, that file is
sourced.

- Plugins and ftplugins that you want to be loaded lazily/manually go inside
`opt`. These may be loaded with `:packadd`. This is not exactly like loading
a plugin at startup, though, because if a plugin does something on VimEnter,
that something must be triggered manually.

- The `colorscheme` command searches both `pack/*/start` and `pack/*/opt/`
(beside `runtimepath`), so it does not matter where a colorscheme is.

If the above is accurate, I would give the following recommendations:

- Always put filetype plugins (no `plugin/foo.vim`) inside `start`. I see no
reason why you would want to do otherwise (unless you have a filetype
that you
seldom use and you really want to keep `runtimepath` as small as possible).
This type of plugin does not cause any file to be loaded at startup, unless
there is an `ftdetect/xyz.vim` file.

- Always put colorschemes inside `opt`. This avoid cluttering
`runtimepath`, and
they are found anyway.

For a concrete example of migration, let's say I am using Pathogen and I have
the following:

bundle/surround <-- regular plugin
bundle/youcompleteme <-- regular plugin
bundle/solarized <-- colorscheme
bundle/zenburn <-- colorscheme
bundle/ledger <-- filetype plugin
bundle/pgsql <-- filetype plugin
bundle/swift <-- filetype plugin

I might then move them to:

pack/bundle/start/surround
pack/bundle/start/ledger
pack/bundle/opt/youcompleteme
pack/languages/start/pgsql
pack/languages/start/swift
pack/themes/opt/solarized
pack/themes/opt/zenburn

Then, everything should work as before, with the exception of YCM, which must
now be loaded manually. To do so, I need

:packadd youcompleteme

but also

:call youcompleteme#Enable()

because :packadd does not trigger VimEnter.

Does what I said make sense? Am I missing something?

Nicola


--
--
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, March 24, 2016

Re: My E-mail to the Mailing List Did Not Arrive

On Thursday, March 24, 2016 at 12:16:17 PM UTC-5, Shlomi Fish wrote:
> Hi Christian,
>
> On Tue, 22 Mar 2016 20:10:54 +0100
> Christian Brabandt <cblists@256bit.org> wrote:
>
> > Hi Shlomi!
> >
> > On Mo, 21 Mär 2016, Shlomi Fish wrote:
> >
> > > Hi all,
> > >
> > > my E-mail to the "vim_use" mailing list with the subject " [ANN]
> > > Investigating Vim's escaping/quoting rules for the :! ...<CR>
> > > command." sent two days ago did not arrive to the mailing list , and I
> > > didn't get a bounce, a rejection E-mail, or a moderation E-mail
> > > either.
> > >
> > > Please investigate why it did not arrive yet.
> >
> > As one of the ml moderators I can say, I haven't seen a message from you
> > in the queue. I know you have posted before, so I don't know why this
> > would happen and the fact that this message came through, shows it.
> >
>
> I see.
>
> > Are you sure, your mail was sent with the correct sender email?
>
> Yes, I'm sure.
>
> OK, I've now tried these two things:
>
> 1. Forwarding the sent email to the mailing list. It didn't arrive.
>
> 2. Subscribing to vim_use from my GMail account and posting a message using
> the Google Groups with a single link to a directory inside a GitHub repository
> (which I'm pretty sure is not spam). This message was eaten by the interface
> (though I was told it got sent but I cannot find it anywhere.).
>
> Did Google Groups jump the shark? If so, good luck on trying to get Google to
> remedy that - from my experience their customer service ranges from abysmal to
> non-existent. Perhaps the vim forums should be moved elsewhere.
>

Seems to work fine for everyone else.

I think i just approved your link-only post. Apparently you've not posted from that account before.

--
--
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: Build cexpr from result of python code.

2016-03-24 13:26 GMT+03:00 Ni Va <nivaemail@gmail.com>:
> On Monday, March 21, 2016 at 4:45:45 PM UTC+1, ZyX wrote:
>> 2016-03-21 17:15 GMT+03:00 Ni Va <nivaemail@gmail.com>:
>> > Hi,
>> >
>> > I am using Execute-selection-in-Python-and-append-master plugin in order to test python code directly through vim. Now the python code is working and return me a list that contains strings typed like "file linenumber linecontent".
>> >
>> > I would like not to replace buffer content by result of python code but affect cexpr to the list content in order to navigate through results with quickfix list.
>>
>> You can use
>>
>> vim.Function('setqflist')([{'filename': file, 'lnum': linenumber,
>> 'text': linecontent}])
>>
>> to set quickfix list from Python code. This assumes that you are doing
>> parsing yourself.
>>
>> Or pyeval() in :cexpr to make Vim do parsing. Just return `output`
>> directly without doing anything with `r` and your function should be
>> ready for use in :cexpr assuming correct &errorformat value.
>>
>> >
>> > Can you help me to build that cexpr list ?
>> >
>> > By advance Thank you
>> >
>> >
>> > Here it is the code of PyExecReplace that replace content of my buffer (python code) by result of execution code.
>> >
>> >
>> > python << EOL
>> > import vim, StringIO,sys
>> >
>> > def PyExecReplace(line1,line2):
>> > r = vim.current.buffer.range(int(line1),int(line2))
>> > redirected = StringIO.StringIO()
>> > sys.stdout = redirected
>> > exec('\n'.join(r[:]) + '\n')
>> > sys.stdout = sys.__stdout__
>> > output = redirected.getvalue().split('\n')
>> > r[:] = output[:-1] # the -1 is to remove the final blank line
>> > # vim.command("echo "+"-".join(("a", "b", "c")))
>> > redirected.close()
>> > EOL
>> > command! -range Pyer python PyExecReplace(<f-line1>,<f-line2>)
>> > command! -range Pyea python PyExecAppend(<f-line1>,<f-line2>)
>> >
>> > --
>> > --
>> > 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.
>
>
> Thank you ZyX !
>
> I give you the following code if it can help for someone else. Execute-selection-in-Python-and-append-master with a third function that returns only output :
> python << EOL
> import vim, StringIO, string, sys
> def PyExecAppend(line1,line2):
> r = vim.current.buffer.range(int(line1),int(line2))
> redirected = StringIO.StringIO()
> sys.stdout = redirected
> exec('\n'.join(r[:]) + '\n')
> sys.stdout = sys.__stdout__
> output = redirected.getvalue().split('\n')
> r.append(output[:-1]) # the -1 is to remove the final blank line
> redirected.close()
>
> def PyExecReplace(line1,line2):
> r = vim.current.buffer.range(int(line1),int(line2))
> redirected = StringIO.StringIO()
> sys.stdout = redirected
> exec('\n'.join(r[:]) + '\n')
> sys.stdout = sys.__stdout__
> output = redirected.getvalue().split('\n')
> r[:] = output[:-1] # the -1 is to remove the final blank line
> redirected.close()
>
> def PyExecOut(line1,line2):
> r = vim.current.buffer.range(int(line1),int(line2))
> redirected = StringIO.StringIO()
> sys.stdout = redirected
> exec('\n'.join(r[:]) + '\n')
> sys.stdout = sys.__stdout__
> output = redirected.getvalue().split('\n')
> redirected.close()
> return output
> EOL
> command! -range Pyeo python PyExecOut(<f-line1>,<f-line2>)
> command! -range Pyer python PyExecReplace(<f-line1>,<f-line2>)
> command! -range Pyea python PyExecAppend(<f-line1>,<f-line2>)
>
>
>
>
> Then I have just a last problem, in my main code that build setqflist I have only the last occurence and not all (6 occurences) despite the 'a' option.
>
>
> for filepath in myDict.keys():
> for line in myDict[filepath]:
> print filepath + " line " + '{:>5}'.format(str(line[0])) + " : " + line[1]
> vim.Function('setqflist')([{'filename': filepath, 'lnum': line[0], 'text': line[1]},'a'])

You probably meant `setqflist([{'filename': filepath, 'lnum': line[0],
'text': line[1]}], 'a')`, not `'a'` inside an array supplied as a
first argument.

I would also suggest to save the result of calling
`vim.Function('setqflist')` into a variable if you call it more then
once.

>
> --
> --
> 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: RFE: support POSIX standard and developing RE's

Instead of implementing one or another regex type in core, it might be better to know about and hook into libs for their regex engines. For example, libperl for perl's engine when +perl or libpcre as another option. IDK you can do the same with python, I think you can with ruby and IIRC Lua uses libpcre.

On Mar 24, 2016 8:13 AM, "BPJ" <bpj@melroch.se> wrote:


torsdag 24 mars 2016 skrev Christian Brabandt <cblists@256bit.org>:
On Do, 24 Mär 2016, L. A. Walsh wrote:

> Posix, has 2 official RE's  already, the modern REs( like in
> grep -E, (extended RE's)
> and "obsolete RE's" as found in ed, called "basic REs".
>
> Additionally for the past few years, more gnu utils (like grep -P)
> have started supporting a third type of RE's called
> PCRE [Perl Compatible RE's] that seem to be on their way
> to becoming a 3rd official type of RE.
>
> Would it be possible to add the 3 RE's (w/appropriate flags)
> to invoke those standardized expressions (not as a replacement
> for any of the existing RE's), but w/different flags.
>
> This would allow those who know the posix-compat RE's that
> are becoming more wide spread in usage, and would allow for
> easier, direct usage (cut&paste) of the alternate RE's specifically
> to make it easer to define these expressions in shell-vars and/or
> vim-macros to allow for easier portability and usability between
> vim and other posix & gnu utils?  Note in the past few years,
> the pcreRE's have also added python-specific features to the
> syntax to allow for easier porting of python features.
>
> Probably (or maybe) best of all, as all of these RE's are
> becoming more prevalent in posix, unix and linux environments,
> it would be a great benefit for people to be able to switch
> to alternate RE's based on familiarity and and the greater
> uniformity in these classes.
>
> Seems this would lower the learning curve for RE usage in
> vim where it often, idiosyncratically differs from such,
> requiring much trial and error and wasted time to get
> equivalent vim-compat-RE's that are equivalent to other
> industry standard RE's.
>
> Anyway, thought I'd mention this, since vim already has
> multiple incompatible RE's with existing standards and
> thought that providing a few "new POSIX-compat RE's" would
> only help in making vim easier to use.
>
> Thanks for your time!
> -linda

There is https://github.com/vim/vim/issues/99
You might want to check, if this works for you.

If I'm not mistaken that's "extended" as in /x,  a different sense from "extended" as in ERE.

i would like to have "extended as in /x" FWIW.
 

Best,
Christian
--
Mögest Du leben, solange Du willst - und wollen, solange Du lebst!

--
--
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.

--
--
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: My E-mail to the Mailing List Did Not Arrive

Hi Christian,

On Tue, 22 Mar 2016 20:10:54 +0100
Christian Brabandt <cblists@256bit.org> wrote:

> Hi Shlomi!
>
> On Mo, 21 Mär 2016, Shlomi Fish wrote:
>
> > Hi all,
> >
> > my E-mail to the "vim_use" mailing list with the subject " [ANN]
> > Investigating Vim's escaping/quoting rules for the :! ...<CR>
> > command." sent two days ago did not arrive to the mailing list , and I
> > didn't get a bounce, a rejection E-mail, or a moderation E-mail
> > either.
> >
> > Please investigate why it did not arrive yet.
>
> As one of the ml moderators I can say, I haven't seen a message from you
> in the queue. I know you have posted before, so I don't know why this
> would happen and the fact that this message came through, shows it.
>

I see.

> Are you sure, your mail was sent with the correct sender email?

Yes, I'm sure.

OK, I've now tried these two things:

1. Forwarding the sent email to the mailing list. It didn't arrive.

2. Subscribing to vim_use from my GMail account and posting a message using
the Google Groups with a single link to a directory inside a GitHub repository
(which I'm pretty sure is not spam). This message was eaten by the interface
(though I was told it got sent but I cannot find it anywhere.).

Did Google Groups jump the shark? If so, good luck on trying to get Google to
remedy that - from my experience their customer service ranges from abysmal to
non-existent. Perhaps the vim forums should be moved elsewhere.

Regards,

Shlomi Fish
>
> So I am sorry, if I can't be of any further help.
>
> Best,
> Christian



--

--
--
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.

Investigating Vim's shell-execution/shell-filtering commands (:!) quoting/escaping of special characters.

Hi all!

Since my E-mail did not arrive again (something is wrong with Google Groups), please just see this:

* https://github.com/shlomif/vim-begin/tree/master/understanding-exclamation-mark-shell-exec--escaping-rules

Enjoy!

Regards,

-- Shlomi Fish

--
--
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: Build cexpr from result of python code.

On Monday, March 21, 2016 at 4:45:45 PM UTC+1, ZyX wrote:
> 2016-03-21 17:15 GMT+03:00 Ni Va <nivaemail@gmail.com>:
> > Hi,
> >
> > I am using Execute-selection-in-Python-and-append-master plugin in order to test python code directly through vim. Now the python code is working and return me a list that contains strings typed like "file linenumber linecontent".
> >
> > I would like not to replace buffer content by result of python code but affect cexpr to the list content in order to navigate through results with quickfix list.
>
> You can use
>
> vim.Function('setqflist')([{'filename': file, 'lnum': linenumber,
> 'text': linecontent}])
>
> to set quickfix list from Python code. This assumes that you are doing
> parsing yourself.
>
> Or pyeval() in :cexpr to make Vim do parsing. Just return `output`
> directly without doing anything with `r` and your function should be
> ready for use in :cexpr assuming correct &errorformat value.
>
> >
> > Can you help me to build that cexpr list ?
> >
> > By advance Thank you
> >
> >
> > Here it is the code of PyExecReplace that replace content of my buffer (python code) by result of execution code.
> >
> >
> > python << EOL
> > import vim, StringIO,sys
> >
> > def PyExecReplace(line1,line2):
> > r = vim.current.buffer.range(int(line1),int(line2))
> > redirected = StringIO.StringIO()
> > sys.stdout = redirected
> > exec('\n'.join(r[:]) + '\n')
> > sys.stdout = sys.__stdout__
> > output = redirected.getvalue().split('\n')
> > r[:] = output[:-1] # the -1 is to remove the final blank line
> > # vim.command("echo "+"-".join(("a", "b", "c")))
> > redirected.close()
> > EOL
> > command! -range Pyer python PyExecReplace(<f-line1>,<f-line2>)
> > command! -range Pyea python PyExecAppend(<f-line1>,<f-line2>)
> >
> > --
> > --
> > 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.


Thank you very much !
It is ok I have applied you first solution :

In vimscript pythonExecuteAppendOrReplace.vim:
python << EOL
import vim, StringIO, string, sys
def PyExecAppend(line1,line2):
r = vim.current.buffer.range(int(line1),int(line2))
redirected = StringIO.StringIO()
sys.stdout = redirected
exec('\n'.join(r[:]) + '\n')
sys.stdout = sys.__stdout__
output = redirected.getvalue().split('\n')
r.append(output[:-1]) # the -1 is to remove the final blank line
redirected.close()

def PyExecReplace(line1,line2):
r = vim.current.buffer.range(int(line1),int(line2))
redirected = StringIO.StringIO()
sys.stdout = redirected
exec('\n'.join(r[:]) + '\n')
sys.stdout = sys.__stdout__
output = redirected.getvalue().split('\n')
r[:] = output[:-1] # the -1 is to remove the final blank line
redirected.close()

def PyExecOut(line1,line2):
r = vim.current.buffer.range(int(line1),int(line2))
redirected = StringIO.StringIO()
sys.stdout = redirected
exec('\n'.join(r[:]) + '\n')
sys.stdout = sys.__stdout__
output = redirected.getvalue().split('\n')
redirected.close()
return output
EOL
command! -range Pyeo python PyExecOut(<f-line1>,<f-line2>)
command! -range Pyer python PyExecReplace(<f-line1>,<f-line2>)
command! -range Pyea python PyExecAppend(<f-line1>,<f-line2>)


And then in my python test.py:
import os, fnmatch, re, vim

# assuming myDict contains data lines
myDict = {}

qflist = []
for filepath in myDict.keys():
for line in myDict[filepath]:
print filepath + " line " + '{:>5}'.format(str(line[0])) + " : " + line[1]
qflist.append({'filename': filepath, 'lnum': line[0], 'text': line[1]})

vim.Function('setqflist')(qflist)

--
--
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.