Sunday, May 31, 2020
Re: function definition for only one file, not for other simultaneously opened files
> On 31/05/20 6:18 am, Gary Johnson wrote:
> How are you executing your function and what is it doing to affect
> files or buffers that you don't want it to?
>
> My function executes a bash command to get the current date and time, whenever
> I hit <ENTER> and prepends it to the line.
>
>
> On 31/05/20 2:13 pm, Tony Mechelynck wrote:
>
> - a function can be assigned to a Funcref which is a variable (global,
> script-local, buffer-local, window-local, etc.) of a special type;
> that Funcref can then be used both as a variable (when not followed by
> () ) or as a function (followed by () ).
>
> I have a kind of hunch that there is something for you (Manas) in the
> above but I'm not sure what.
>
> I found this the most optimum. What I did was:
>
> 1. define the function
>
> 2. create a buffer-local function reference pointing to the function:
>
> > let b:Fn = function("PrependTime")
>
> `PrependTime` is my function name.
>
> 3. And now `:echo b:Fn()` in current buffer will prepend the timestamp and in
> other buffers, it will throw error (E117: Unknown function). Now I wanted to
> somehow suppress the error message but I could not find much.
You wrote that you want to have <Enter> insert the date at the start
of the next line, but only in one buffer. Wouldn't making that
mapping buffer-local solve your problem? Something like this?
inoremap <buffer> <CR> <CR><C-R>=PrependTime()<CR>
function! PrependTime()
return strftime("%c")
endfunction
See
:help map-<buffer>
You would just need to execute that mapping only in the one buffer
where you wanted that behavior.
If other buffers are throwing error E117, then you have <Enter>
(a.k.a. <CR>) mapped in buffers where it shouldn't be mapped.
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200601044307.GA10889%40phoenix.
VimScript for Python developers
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAAW7x7%3DRnUq6K459LxwhCvkRzynOj_T4_2ez0Xp3NsWoRDiRYQ%40mail.gmail.com.
Re: function definition for only one file, not for other simultaneously opened files
On 31/05/20 6:18 am, Gary Johnson wrote:
I looked up this. While reading the manual, I realized I wanted a buffer-local function but as it is not available so I think I would just copy that function to my .vimrc and as you suggested, invoke a mapping anytime I want to use that function in some buffer.From ":help local-function": There are only script-local functions, no buffer-local or window-local functions. However, you _can_ control how and when your function is executed. For example, mappings and autocommands can be local to a buffer.
Though, this can be done as I am working with some markdown files for note-taking etc. but I wanted to make the feature less hard coded. As in, I have many markdown files for notes on different topics (viz. current project, academics, reminders, etc.) but I wanted the timestamp feature to only apply in one of those files.You can also have your function look at the current buffer name or some other property of the buffer and decide whether to continue executing or to return immediately.
How are you executing your function and what is it doing to affect files or buffers that you don't want it to?
My function executes a bash command to get the current date and time, whenever I hit <ENTER> and prepends it to the line.
- a function can be assigned to a Funcref which is a variable (global, script-local, buffer-local, window-local, etc.) of a special type; that Funcref can then be used both as a variable (when not followed by () ) or as a function (followed by () ). I have a kind of hunch that there is something for you (Manas) in the above but I'm not sure what.
I found this the most optimum. What I did was:
1. define the function
2. create a buffer-local function reference pointing to the function:
> let b:Fn = function("PrependTime")
`PrependTime` is my function name.
3. And now `:echo b:Fn()` in current buffer will prepend the timestamp and in other buffers, it will throw error (E117: Unknown function). Now I wanted to somehow suppress the error message but I could not find much.
But again it will become hard-coded for that particular file. As I open multiple markdown files simultaneously, so I will need to go with the filename.I believe that as Gary hinted the best bet in this case is to inspect the file extension (".md" I guess) with the help of
if matchstr(bufname(), '\.md$')" do somethingendif
PS: Sorry for delayed response.
Manas
CSAM Undergraduate 2022
Re: function definition for only one file, not for other simultaneously opened files
Better --help|less than helpless
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CADAJKhBisf6v%3D3wDRkkii_KcOTUUt7dym%3D%3DvkOKWYbNo04271A%40mail.gmail.com.
Re: function definition for only one file, not for other simultaneously opened files
>
> On 2020-05-31, Manas wrote:
> > I am struggling to find a way to deal with the following problem.
> >
> > Suppose, I open 3 markdown files at once in separate tabs. Now I want some
> > particular function for one of those files only. Like, I want to add time and
> > date in front of each new line for that file. So I define a function to do so.
> > But, that function is affecting other files too which I don't want.
> >
> > Is there some way to achieve that?
>
> From ":help local-function":
>
> There are only script-local functions, no buffer-local or
> window-local functions.
>
> However, you _can_ control how and when your function is executed.
> For example, mappings and autocommands can be local to a buffer.
> You can also have your function look at the current buffer name or
> some other property of the buffer and decide whether to continue
> executing or to return immediately.
>
> How are you executing your function and what is it doing to affect
> files or buffers that you don't want it to?
>
> Regards,
> Gary
Sidestepping for the moment the question of :def functions which are
still "under development":
- a function can be global (:function foo() ), script-local (:function
s:bar() ) or defined in an autoload-script (:function tiddly#Wink()
defined in e.g. ~/.vim/autoload/tiddly.vim ). Script-local functions
are only visible from the same script, including autocommands defined
there. To invoke them from mappings, replace s: by <SID>
- a function can be assigned to a Funcref which is a variable (global,
script-local, buffer-local, window-local, etc.) of a special type;
that Funcref can then be used both as a variable (when not followed by
() ) or as a function (followed by () ).
- a function can also be invoked from a user-command (defined by the
:command command)
I have a kind of hunch that there is something for you (Manas) in the
above but I'm not sure what.
Best regards,
Tony.
--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAJkCKXu2DCASY0UZUzC75oUM4g0pccw0vu_wH5ApXKMg%2BTLqrQ%40mail.gmail.com.
Saturday, May 30, 2020
Re: function definition for only one file, not for other simultaneously opened files
> I am struggling to find a way to deal with the following problem.
>
> Suppose, I open 3 markdown files at once in separate tabs. Now I want some
> particular function for one of those files only. Like, I want to add time and
> date in front of each new line for that file. So I define a function to do so.
> But, that function is affecting other files too which I don't want.
>
> Is there some way to achieve that?
From ":help local-function":
There are only script-local functions, no buffer-local or
window-local functions.
However, you _can_ control how and when your function is executed.
For example, mappings and autocommands can be local to a buffer.
You can also have your function look at the current buffer name or
some other property of the buffer and decide whether to continue
executing or to return immediately.
How are you executing your function and what is it doing to affect
files or buffers that you don't want it to?
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200531004843.GD15884%40phoenix.
Re: function definition for only one file, not for other simultaneously opened files
I am struggling to find a way to deal with the following problem.
Suppose, I open 3 markdown files at once in separate tabs. Now I want some particular function for one of those files only. Like, I want to add time and date in front of each new line for that file. So I define a function to do so. But, that function is affecting other files too which I don't want.
Is there some way to achieve that?
Manas
CSAM Undergraduate 2022
Wednesday, May 27, 2020
Highlight issues in Swift language
There has been a few months now that I'm struggling to highlight parameters
labels of Swift functions. Labels on Swift functions are awkward. If it is
not defined the parameter name should be used as label. Labels are used when the
function is called and became part of functions signature.
When I define a function like this:
~~~~
func someFunction(first: Int, second: String) -> Void { }
~~~~
I should call it using parameters names as labels:
~~~~
someFunction(first: 0, second: "string")
~~~~
When I define a function with labels, they should be used in function
call. I also can mix labeled parameters with unlabeled ones:
~~~~
func someFunction(firstParameter first: Int, second: String) -> Void { }
~~~~
In this case the function should be called as:
~~~~
someFunction(firstParameter: 0, second: "string")
~~~~
I can also free the caller on type labels by using "_" (underscore character)
as the parameter label in the function declaration:
~~~~
func someFunction(_ first: Int, second: String) -> Void { }
~~~~
Would be called as:
~~~~
someFunction(0, second: "string")
~~~~
What I was pursuing is highlight parameter labels, when they are present.
Otherwise, highlight parameter names. That I did successfully with the
following syntax groups:
~~~~
syn region swiftCall transparent matchgroup=Delimiter start=/(/ end=/)/
syn match swiftArgLabel contained /\<\(\_[,(]\s*\)\@<=\k\+\ze\s*:/ containedin=swiftCall
syn match swiftArgLabel contained /\<\(_\|\k\+\)\ze\(\s\+\k\+:\)/ containedin=swiftCall
~~~~
~~~~
func someFunction(first: Int, theLabel second: String) { }
^^^^^ ^^^^^^^^
These are highlighted successfully.
someFunction(first: 0, theLabel: "text")
^^^^^ ^^^^^^^^
In the function call it also works.
~~~~
The problem arose when the function definition or call spans multiple lines.
~~~~
func someFunctions(first: Int,
^^^^^ <- This is not highlighted.
theLabel second: String)
^^^^^^^^ <- Highlighted while the "close paren" is at the end of the line.
func someFunctions(first: Int,
^^^^^ <- This is not highlighted.
theLabel second: String
^^^^^^^^ <- Not highlighted becouse "close paren" is in the next line.
)
~~~~
There is more, if I have a 'swiftCall' region inside another 'swiftCall', the
highlight works. Like this, in a function call:
~~~~
someFunction(first: getSomeIntNumber(),
^^^^^ <- Now the highlight works.
theLabel: "some string"
^^^^^^^^ <- Astonishing, here works too.
)
~~~~
I wonder if someone can enlighten me on why the highlights doesn't work in all
cases.
Thanks in advance,
Alessandro Antonello
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CA%2BJN8R%2BwNEFhnRVkofCemdWhRtHUHcthOrVHr5rm7yXhzo3a%2BQ%40mail.gmail.com.
Re: Usage of | character in digraphs
>
>
> maybe this page is of help, it uses a different digraph:
>
> https://mullikine.github.io/posts/adding-new-digraphs-to-vim-and-evil/
>
> I did look up this page but I wanted to use pipe character because when I actually write ℕ symbol on paper, I write N first then the horizontal line on it. By using pipe, I would remember easily what the digraph is.
>
> --
> Manas
> CSAM Undergraduate 2022
Instead of the external "unicode" program mentioned there, you could
also use the unicode.vim plugin by Christian Brabandt, available at
vim.org. After installing it,
:echo unicode#FindUnicodeBy('DOUBLE-STRUCK CAPITAL')
would give you a List of Dictionaries, one Dictionary for each letter
whose Unicode name contained that string, with all known properties of
that letter, including full Unicode name, hex and decimal codepoint,
digraph(s) if any, HTML entity/ies, and glyph. Of course, if you
wanted only the double-struck N, then
unicode#FindUnicodeBy('DOUBLE-STRUCK CAPITAL N') would give you just
that.
I use that plugin almost exclusively for its :UnicodeName command
(which gives the same information in a more user-friendly format for
the character under the cursor) but I know that it has other commands
and functions, and its help is in the outstanding Vim tradition.
Best regards,
Tony.
--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAJkCKXucrGL4XMo_uS8%3DGQmZustoSefWAK1GXG1gEMa7N3XYhw%40mail.gmail.com.
Re: Usage of | character in digraphs
>
> Manas <manas18244@iiitd.ac.in> wrote:
> > For example, I want to add ℕ (symbol for natural numbers set) as N| (N
> > : digraphs N| 8469
> > it is throwing E474.
>
> The | character separates commands in ex-mode. You can use it in your
> digraph, but you need to backslash escape it:
>
> : digraphs N\| 8469
Indeed, I tried to see if I could (just as a test) define || as a
digraph for | and it took me several trials. With
:dig || char2nr('|')
I got the same answer as with :dig with no argument (a list of
existing digraphs). Then
:dig \|\| char2nr('|')
gave me E39: Number expected. Finally
:dig \|\| 124
gave me the expected digraph (and a subsequent :dig with no argument
listed it at the very end).
>
> The ex-mode | thing dates back to pre-vim days of real ex and vi. It's not
> used often, and easy to overlook / forget.
I use it quite often, for instance to define an autocommand with a few
commands to be done in succession, or for an if..endif clause as {rhs}
to a mapping.
The fact that :digraph is not listed at :help :| implies that to
include a | in the operands of a :digraph command it must be
backslash-escaped.
>
> Elijah
Best regards,
Tony.
--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAJkCKXt0Dm2NHDVmjL3hLfB9iVDeOtugvqLS6%3D3aA7oHDCxRhA%40mail.gmail.com.
Re: Usage of | character in digraphs
Thanks a lot. That worked.The | character separates commands in ex-mode. You can use it in your digraph, but you need to backslash escape it: : digraphs N\| 8469 The ex-mode | thing dates back to pre-vim days of real ex and vi. It's not used often, and easy to overlook / forget.
Manas
CSAM Undergraduate 2022
Re: Usage of | character in digraphs
maybe this page is of help, it uses a different digraph: https://mullikine.github.io/posts/adding-new-digraphs-to-vim-and-evil/
I did look up this page but I wanted to use pipe character because when I actually write ℕ symbol on paper, I write N first then the horizontal line on it. By using pipe, I would remember easily what the digraph is.
Manas
CSAM Undergraduate 2022
Re: Usage of | character in digraphs
> For example, I want to add ℕ (symbol for natural numbers set) as N| (N
> : digraphs N| 8469
> it is throwing E474.
The | character separates commands in ex-mode. You can use it in your
digraph, but you need to backslash escape it:
: digraphs N\| 8469
The ex-mode | thing dates back to pre-vim days of real ex and vi. It's not
used often, and easy to overlook / forget.
Elijah
--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/49XGgm6btVzfYm%40panix5.panix.com.
Re: Usage of | character in digraphs
> Hi folks, I want to setup a few more digraphs according to my need. But
> while defining those I am running into error.
>
> For example, I want to add (symbol for natural numbers set) as N| (N
> followed by the pipe character) but when defining the digraph as
>
> : digraphs N| 8469
>
> it is throwing E474.
>
> Can I not use the pipe character while defining digraphs?
maybe this page is of help, it uses a different digraph:
https://mullikine.github.io/posts/adding-new-digraphs-to-vim-and-evil/
however, it doesn't answer your question whether a pipe character is
allowed in defining a digraph...
//meine
--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200527162759.GC1915%40trackstand.
Re: Usage of | character in digraphs
Hi folks, I want to setup a few more digraphs according to my need. But while defining those I am running into error.
For example, I want to add ℕ (symbol for natural numbers set) as N| (N followed by the pipe character) but when defining the digraph as
: digraphs N| 8469
it is throwing E474.
Can I not use the pipe character while defining digraphs?
Manas
CSAM Undergraduate 2022
Sunday, May 24, 2020
VimConf 2020 is Canceled
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/ca9e3b7f-8684-4120-8c04-7b64c28e6759%40googlegroups.com.
Friday, May 22, 2020
Re: error list
--Hi,On Fri, May 22, 2020 at 12:18 PM Joseph <kingcanute76@gmail.com> wrote:Is there an easy way to dump the error list to the current vim buffer/window?Actually, is there a general way to do this for other commands too?So - I want to type something like ':clist/m 0' would be greatAre you looking for the following command?:call append(1, split(execute('clist'), "\n"))or in insert mode, type the following:<C-R>=execute('clist')and then hit Enter to insert the quickfix list contents.- Yegappan
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAAW7x7%3Dojr1PsPqOVRkGPVcLCtgcQ9ip56erjfb%2BjBq%3Dza0JiA%40mail.gmail.com.
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAFim3NLrLB-ECu_Lm8EMXtzWbZ75wmATfRdOtLje2mOE%2BOO6oA%40mail.gmail.com.
Re: error list
> Is there an easy way to dump the error list to the current vim
> buffer/window?
>
> Actually, is there a general way to do this for other commands too?
I use this code, which you may adapt to your needs:
" Send the output of a Vim command to a new scratch buffer.
"
" Example: :call lf_run#vim_cmd('digraphs')
fun! lf_run#vim_cmd(cmd)
botright 10new
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap
call append(0, split(execute(a:cmd), "\n"))
endf
" Execute a Vim command and send the output to a new scratch buffer
command! -complete=command -nargs=+ VimCmd call lf_run#vim_cmd(<q-args>)
So, try:
:VimCmd clist
Hope this helps,
Life.
--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/ra998t%24377f%241%40ciao.gmane.io.
Re: error list
>
> Is there an easy way to dump the error list to the current vim buffer/window?
>
> Actually, is there a general way to do this for other commands too?
>
> So - I want to type something like ':clist/m 0' would be great
1. Open the quickfix window
:copen
2. Yank everything
:1,$y
3. Close the quickfix window
:cclose
4. Put, e.g.
:0put
Best regards,
Tony.
--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAJkCKXtqjfHEDV-J_zL8eNENn98GH4befGE-gzhDmUPOB6Vsuw%40mail.gmail.com.
Re: error list
Is there an easy way to dump the error list to the current vim buffer/window?Actually, is there a general way to do this for other commands too?So - I want to type something like ':clist/m 0' would be great
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAAW7x7%3Dojr1PsPqOVRkGPVcLCtgcQ9ip56erjfb%2BjBq%3Dza0JiA%40mail.gmail.com.
error list
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAFim3NK%2Bmm28odQmf3KsDoK1N5-4ay1_wwb3frVtZK%3DSZrW%3Dnw%40mail.gmail.com.
Thursday, May 21, 2020
Re: Why is get(dict,value,default) evaluated eagerly?
> On Thu, May 21, 2020 at 6:05 PM Lifepillar <lifepillar@lifepillar.me> wrote:
>>
>> I have always believed that, in get(X,y,z), z would be evaluated only
>> when dictionary X does not contain key y. Today, to my surprise, I have
>> discovered that it is not the case:
>>
>> fun! Loop()
>> call Loop()
>> endf
>>
>> let H = { 'a': 1 }
>>
>> if has_key(H, 'a') || Loop() " Fine, this is evaluated lazily
>> endif
>>
>> echo (get(H, 'a') != 0) ? "" : Loop() " Fine, lazy
>>
>> " But, endless recursion here:
>> echo get(H, 'a', Loop())
>>
>> What is the rationale for this behaviour?
>>
>> Thanks,
>> Life.
>
> IIUC, any expression in the arguments of a function (other than a
> variable of type List, Dictionary, Funcref or Blob) is passed "by
> value" after having been evaluated by the caller. In get(H, a, Loop())
> the third argument passed is the _value_ of Loop() as evaluated
> immediately before the call.
Ah ok, that makes sense.
Thanks!
Life.
--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/ra6deq%242sfu%242%40ciao.gmane.io.
Re: Why is get(dict,value,default) evaluated eagerly?
>
> I have always believed that, in get(X,y,z), z would be evaluated only
> when dictionary X does not contain key y. Today, to my surprise, I have
> discovered that it is not the case:
>
> fun! Loop()
> call Loop()
> endf
>
> let H = { 'a': 1 }
>
> if has_key(H, 'a') || Loop() " Fine, this is evaluated lazily
> endif
>
> echo (get(H, 'a') != 0) ? "" : Loop() " Fine, lazy
>
> " But, endless recursion here:
> echo get(H, 'a', Loop())
>
> What is the rationale for this behaviour?
>
> Thanks,
> Life.
IIUC, any expression in the arguments of a function (other than a
variable of type List, Dictionary, Funcref or Blob) is passed "by
value" after having been evaluated by the caller. In get(H, a, Loop())
the third argument passed is the _value_ of Loop() as evaluated
immediately before the call.
Best regards,
Tony.
--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAJkCKXvw8NBTSQY3%3D_D4%3DY5HN%2BS5PqD9UKdr_D%2B%3DhtZW184uxg%40mail.gmail.com.
Why is get(dict,value,default) evaluated eagerly?
when dictionary X does not contain key y. Today, to my surprise, I have
discovered that it is not the case:
fun! Loop()
call Loop()
endf
let H = { 'a': 1 }
if has_key(H, 'a') || Loop() " Fine, this is evaluated lazily
endif
echo (get(H, 'a') != 0) ? "" : Loop() " Fine, lazy
" But, endless recursion here:
echo get(H, 'a', Loop())
What is the rationale for this behaviour?
Thanks,
Life.
--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/ra68ro%241f42%241%40ciao.gmane.io.
Wednesday, May 20, 2020
Re: Highlighting c-like for-loops in bash
> Hi,
>
> Thanks for your email.
> Please find attached the small script bash I tested where the
> variables i, j, limit_t, limit_j are unfortunately not highlighted in
> the standard for-loop, in contrast to the label variable in the
> for-each-like loop.
>
> Hakim.
>
> On Wed, May 20, 2020 at 4:47 AM Charles Campbell <campbell@drchip.org
> <mailto:campbell@drchip.org>> wrote:
>
> Hakim Benoudjit wrote:
> >
> > Hi,
> >
> >
> > I wasn't sure if this was a bug or not, so I've updated my Vim
> version
> > to 8.2 on Ubuntu 18.04.
> >
> > And, as you can see below, the variables in the standard for-loop
> > aren't highlighted as they are in the following for loop:
> >
> >
> Hello:
>
> I'm the maintainer of syntax/sh.vim ; would you please send me an
> attachment of the code snippet you're having a problem with?
>
With the script you sent I can use hilinks.vim
(http://www.drchip.org/astronaut/vim/index.html#HILINKS) to see what's
happening.
In the for (( ... )) loop, the items inside are highlighted as shForPP ;
ie. as inside a region. The variables themselves are not individually
identified. The "<=" and other operators are highlighted as shTestOpr
(ie. operators). All is normal.
In the first echo ... the variables are, again, not identified as
variables; instead, they're being shown as
shDo->shDo->shEcho->shDoubleQuote ; ie. regular string highlighting.
In the second outside loop (ie. the one with "label"), label is not
recognized as a variable. Instead, its being recognized as being inside
a for loop (shFor), so its being highlighted correctly for that
situation. Copying the echo "i:..." into the body of the "label" for
loop shows its highlighted the same as in the other place.
Generally, I try not to identify variables because of the potential
problems (is it really an alias? a function? etc); remember, the syntax
highlighter isn't a parser. I do have a shVar; I'll have to see if
including it in the for loops' containment lists causes problems.
So, insofar as the variables are concerned, the highlighting is
performing nominally.
That said, there seems to be some unwanted highlighting associated with
the double quotes, and I'll look into that.
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/8937bba7-1ece-8d2e-31c4-8731e37474fc%40drchip.org.
Highlight issues with Swift language
There has been a few months now that I'm struggling to highlight parameters
labels of Swift functions. Labels on Swift functions are awkward. If it is
not defined the parameter name should be used as label. Labels are used when the
function is called and became part of functions signature.
When I define a function like this:
~~~~
func someFunction(first: Int, second: String) -> Void { }
~~~~
I should call it using parameters names as labels:
~~~~
someFunction(first: 0, second: "string")
~~~~
When I define a function with labels, they should be used in function
call. I also can mix labeled parameters with unlabeled ones:
~~~~
func someFunction(firstParameter first: Int, second: String) -> Void { }
~~~~
In this case the function should be called as:
~~~~
someFunction(firstParameter: 0, second: "string")
~~~~
I can also free the caller on type labels by using "_" (underscore character)
as the parameter label in the function declaration:
~~~~
func someFunction(_ first: Int, second: String) -> Void { }
~~~~
Would be called as:
~~~~
someFunction(0, second: "string")
~~~~
What I was pursuing is highlight parameter labels, when they are present.
Otherwise, highlight parameter names. That I did successfully with the
following syntax groups:
~~~~
syn region swiftCall transparent matchgroup=Delimiter start=/(/ end=/)/
syn match swiftArgLabel contained /\<\(\_[,(]\s*\)\@<=\k\+\ze\s*:/ containedin=swiftCall
syn match swiftArgLabel contained /\<\(_\|\k\+\)\ze\(\s\+\k\+:\)/ containedin=swiftCall
~~~~
~~~~
func someFunction(first: Int, theLabel second: String) { }
^^^^^ ^^^^^^^^
These are highlighted successfully.
someFunction(first: 0, theLabel: "text")
^^^^^ ^^^^^^^^
In the function call it also works.
~~~~
The problem arose when the function definition or call spans multiple lines.
~~~~
func someFunctions(first: Int,
^^^^^ <- This is not highlighted.
theLabel second: String)
^^^^^^^^ <- Highlighted while the "close paren" is at the end of the line.
func someFunctions(first: Int,
^^^^^ <- This is not highlighted.
theLabel second: String
^^^^^^^^ <- Not highlighted becouse "close paren" is in the next line.
)
~~~~
There is more, if I have a 'swiftCall' region inside another 'swiftCall', the
highlight works. Like this, in a function call:
~~~~
someFunction(first: getSomeIntNumber(),
^^^^^ <- Now the highlight works.
theLabel: "some string"
^^^^^^^^ <- Astonishing, here works too.
)
~~~~
I wonder if someone can enlighten me on why the highlights doesn't work in all
cases.
Thanks in advance,
Alessandro Antonello
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CA%2BJN8RLkb4DiwcHBaAy8LVA%3DQk6S4xOYY8Q0ozUcCTteQa9G6Q%40mail.gmail.com.
Re: Can someone please help me set up the environment variables on Windows?
let $PYTHONHOME = 'C:/some_path/python_install_folder'
let $PYTHONLIB = '$PYTHONHOME/Scripts'
I am trying to set up vim on Windows. UltiSnips always notifies me that the Python provider is missing. Python27 and Python3.8 are installed. I have been trying to enter the python paths variables in "Path" and "PYTHONHOME". It does not work and I am really frustrated by now. On Linux I have never had problems like that. I also don't even code in Python. I just want to get rid of this notification...--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/3e3a3e65-3375-470f-af21-eadbcd172fb9%40googlegroups.com.
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CA%2BJN8RLwOkgo8twgCWnLjKRn1ZOVwW_Fbd%2BMS8jL%3DNO3ubPGjw%40mail.gmail.com.
Can someone please help me set up the environment variables on Windows?
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/3e3a3e65-3375-470f-af21-eadbcd172fb9%40googlegroups.com.
Tuesday, May 19, 2020
Re: clipbaord internals ques
2020/5/18 Mon 13:02:44 UTC+9 M Kelly wrote:
Hi,Just curious, what is the mechanism by which vim saves to the clipboard ?
For example if I am on a X11 system but in termnal vim and I have clipboard set to unnamedand I highlight in visual mode some lines and then y(ank) them - does vim use OSC 52 ?
Or does it (even tho its the terminal) use X11 to update the PRIMARY ?I will try to figure this out from the code but just wondered if anyone knew this already.thx as always for all things vim,-m
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/364454a8-3b5b-4c4b-94c2-6e182277eaeb%40googlegroups.com.
Re: issue subtituting new lines
2020/5/20 Wed 6:58:58 UTC+9 Eli the Bearded wrote:
Christian Brabandt <cbl...@256bit.org> wrote:
> On Di, 19 Mai 2020, Eli the Bearded wrote:
>> And that would look like this in vi, nvi, and vim up until recently:
>> :%s/%%/^M/g
>> On the versions that break that, it instead looks like this:
>> :%s/%%/^[[27;5;109~/g
> A feature or a bug i suppose. What you are seeing are the effects of the
> modifyOtherKeys feature of Vim and xterm (see :h modifyOtherKeys).
>
> I am not sure why it happens for you when pressing CTRL-V in command
> line mode, it does work for me as expected, unless you accidentally
> pressed Shift-Ctrl-V instead of Ctrl-V
No, I was quite careful in what I typed. But reading :h modifyOtherKeys
leads me to understand what is going on.
If, when modifyOtherKeys is enabled, instead of:
colon percent s slash percent percent slash ctrl-v ctrl-m slash g enter
I type:
colon percent s slash percent percent slash ctrl-v enter slash g enter
I get the:
:%s/%%/^M/g
output I expect. xterm and vim are trying to represent a <ctrl-m> as
different than <enter> with that setting and I'm seeing the results. But
since <enter> is what I really want, actually using <enter> works.
I'll have to mull over if I consider this an improvement or not.
> To disable it, set the t_TI and t_TE terminal settings to the empty
> string:
>
> let &t_TI=""
> let &t_TE=""
Why that syntax instead of "set t_TI=|set t_TE="? I'm already using
"set t_Co=0" in ~/.vimrc to disable colors. (Specifically it sets
the number of colors available to zero.) In testing, both forms seem
to work in .vimrc, and neither seems to work from the ":" prompt --
even after I ":!ls" as suggested by the help page.
Thanks for finding that.
Elijah
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/de8b0963-143c-4fd8-aecc-87f7e031813f%40googlegroups.com.
Re: issue subtituting new lines
> On Di, 19 Mai 2020, Eli the Bearded wrote:
>> And that would look like this in vi, nvi, and vim up until recently:
>> :%s/%%/^M/g
>> On the versions that break that, it instead looks like this:
>> :%s/%%/^[[27;5;109~/g
> A feature or a bug i suppose. What you are seeing are the effects of the
> modifyOtherKeys feature of Vim and xterm (see :h modifyOtherKeys).
>
> I am not sure why it happens for you when pressing CTRL-V in command
> line mode, it does work for me as expected, unless you accidentally
> pressed Shift-Ctrl-V instead of Ctrl-V
No, I was quite careful in what I typed. But reading :h modifyOtherKeys
leads me to understand what is going on.
If, when modifyOtherKeys is enabled, instead of:
colon percent s slash percent percent slash ctrl-v ctrl-m slash g enter
I type:
colon percent s slash percent percent slash ctrl-v enter slash g enter
I get the:
:%s/%%/^M/g
output I expect. xterm and vim are trying to represent a <ctrl-m> as
different than <enter> with that setting and I'm seeing the results. But
since <enter> is what I really want, actually using <enter> works.
I'll have to mull over if I consider this an improvement or not.
> To disable it, set the t_TI and t_TE terminal settings to the empty
> string:
>
> let &t_TI=""
> let &t_TE=""
Why that syntax instead of "set t_TI=|set t_TE="? I'm already using
"set t_Co=0" in ~/.vimrc to disable colors. (Specifically it sets
the number of colors available to zero.) In testing, both forms seem
to work in .vimrc, and neither seems to work from the ":" prompt --
even after I ":!ls" as suggested by the help page.
Thanks for finding that.
Elijah
--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/49RVBx4fKWzfYt%40panix5.panix.com.
Re: issue subtituting new lines
> I use several versions of vim throughout the day, all inside xterms, and
> some inside tmux running in an xterm. Some versions of vim I have
> noticed break my long standing way of adding newlines in a :s///
> substitute command.
>
> To make all %% sequences turn into a new line, what I'd type is:
>
> colon percent s slash percent percent slash ctrl-v ctrl-m slash g enter
>
> And that would look like this in vi, nvi, and vim up until recently:
>
> :%s/%%/^M/g
>
> On the versions that break that, it instead looks like this:
>
> :%s/%%/^[[27;5;109~/g
>
> Which will not (does not) provide the subtitution I want.
>
> I have found the vim I'm using on NetBSD inside xterms without tmux
> do this, but that same vim on NetBSD inside xterms with tmux does not
> do that.
>
> :version
> VIM - Vi IMproved 8.1 (2018 May 18, compiled Jan 7 2020 09:55:54)
> Included patches: 1-2200
> [...]
>
> :r! uname -sr
> NetBSD 8.1
>
> Inside tmux, $TERM is "screen", outside tmux $TERM is "xterm",
> $XTERM_VERSION is "XTerm(330)". Figuring out the exact differences
> between the screen and xterm terminal definitions is not something I
> want to dive into.
>
> If I use vim.old on that same system, the substitute works inside and
> outside of tmux. On vim.old:
>
> :version
> VIM - Vi IMproved 8.1 (2018 May 18, compiled Jun 11 2019 15:16:00)
> Included patches: 1-1517
>
> Is this a known bug that has been fixed in a patch after 2200? If so,
> I'll request the vim here be updated. If not, can this be fixed? (And
> then I'll request the update.)
A feature or a bug i suppose. What you are seeing are the effects of the
modifyOtherKeys feature of Vim and xterm (see :h modifyOtherKeys).
I am not sure why it happens for you when pressing CTRL-V in command
line mode, it does work for me as expected, unless you accidentally
pressed Shift-Ctrl-V instead of Ctrl-V
To disable it, set the t_TI and t_TE terminal settings to the empty
string:
let &t_TI=""
let &t_TE=""
Best,
Christian
--
Das Beste in einem Menschen ist das, was er selber nicht kennt.
-- Jean 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200519175846.GB16708%40256bit.org.
issue subtituting new lines
some inside tmux running in an xterm. Some versions of vim I have
noticed break my long standing way of adding newlines in a :s///
substitute command.
To make all %% sequences turn into a new line, what I'd type is:
colon percent s slash percent percent slash ctrl-v ctrl-m slash g enter
And that would look like this in vi, nvi, and vim up until recently:
:%s/%%/^M/g
On the versions that break that, it instead looks like this:
:%s/%%/^[[27;5;109~/g
Which will not (does not) provide the subtitution I want.
I have found the vim I'm using on NetBSD inside xterms without tmux
do this, but that same vim on NetBSD inside xterms with tmux does not
do that.
:version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Jan 7 2020 09:55:54)
Included patches: 1-2200
[...]
:r! uname -sr
NetBSD 8.1
Inside tmux, $TERM is "screen", outside tmux $TERM is "xterm",
$XTERM_VERSION is "XTerm(330)". Figuring out the exact differences
between the screen and xterm terminal definitions is not something I
want to dive into.
If I use vim.old on that same system, the substitute works inside and
outside of tmux. On vim.old:
:version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Jun 11 2019 15:16:00)
Included patches: 1-1517
Is this a known bug that has been fixed in a patch after 2200? If so,
I'll request the vim here be updated. If not, can this be fixed? (And
then I'll request the update.)
thanks,
Elijah
--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/49RNSv1Yp1zfYt%40panix5.panix.com.
Sunday, May 17, 2020
clipbaord internals ques
For example if I am on a X11 system but in termnal vim and I have clipboard set to unnamed
Or does it (even tho its the terminal) use X11 to update the PRIMARY ?
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/46477ad4-19f1-4ff3-931e-dc36b93b6411%40googlegroups.com.
Re: Starting Native Windows GVim 8.2 from MinGW Git Bash
On Thu, May 14, 2020 at 03:17:55PM -0400, johanns@nacs.net wrote:
>I finally have a newish Windows 10 64-bit laptop for a course and,
>per instructions, have installed Git Bash that uses MinGW from:
>https://git-scm.com/downloads
>
>I also have a standard native Window build of GVIm 8.2 installed under:
>C:\Program File (x86)\Vim\vim82
>which I believe was the default for the standard installer.
>
>MinGW Git Bash ships with a built-in version of vim 8.2 as MinGW
>program, but does not include GVim.
>
>What I am looking to do is to start the native Windows version of
>GVim from a the Git Bash prompt. Rather than change the path I hoped
>to use a simple bash alias with a full path to start Windows GVim
>8.2. This works except that the bash prompt blocks as if Windows
>GVim is a console program and the shell is waiting to get control
>back of the console. I am not entirely sure why the shell waits for
>Gvim to exit. The same technique I am trying to was recommended for
>MSysGit Bash and Vim 7.4 by Albert Armea at:
>https://blog.albertarmea.com/post/115102365718/using-gvim-from-git-bash
>The best reason I can fathom is that I read elsewhere that MinGW is a
>more minimalist UNIX implementation than say Cygwin and does not
>implement fork() despite providing the header file. Another
>possibility is that some trick integration set up in the bundle for
>Vim and GVim with Git is inadvertently fighting my attempt to use a
>Windows executable.
>
>Due to how Bash is invoked by the Git Bash bundle, the easiest way
>for me to configure user specific bash aliases or the like is to
>create two files:
>
>~/.bash_profile is minimal and contains:
>
>if [ -f ~/.bashrc ]; then. ~/bashrc; fi
>
>~/.bashrc has my local alias and a bash function gvim () as follows:
>
>gvim () { (env -u HOME -u VIM "/c/Program Files (x86)/vim/vim82/gvim.exe" "$*")& }
Self correction: To support multiple parameters properly I should use "$@" not
"@*", which confuses Gvim, so:
~/.bashrc has my local alias and a bash function gvim () as follows:
gvim () { (env -u HOME -u VIM "/c/Program Files (x86)/vim/vim82/gvim.exe" "$@")& }
>Another place on the Internet, I found advice to unset the HOME and
>VIM environment variables local to MinGW Bash as Windows GVIm 8.2 is
>started, but I converted a simple bash alias to bash function. While
>the env command above would run GVim as a simple alias, the Git Bash
>shell blocks waiting for GVim to exit. The bash function is needed
>so I can embed the env in a subshell with parentheses and push it to
>the background, while still passing parameters to the inner command
>line. This bash function works, starting GVim and letting the shell
>continue. I do notice that this Windows GVim shows up as a process
>when using the ps command at the Git Bash prompt. I am not sure if
>anything funny happens, based on the order I close Git Bash and GVim.
>
>I am not sure if this is the best approach. Another idea I saw on
>the Internet suggested using the bash disown built-in command, but I
>was getting syntax errors. I tried debugging with set -x in Git Bash
>but extra commands I did not expect were being generated, probably
>due to Git integration. I decided that this method is best, for now,
>but I am wondering if there are any gotchas lurking here.
>
>Thanks in advance for any advice.
--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200514220224.GC1444%40linux.site.
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CA%2BJN8RKQ39%3D5UUjEaQt4a0YmRo6oKnGEWKGT5vca9%3DkTzii65Q%40mail.gmail.com.
Thursday, May 14, 2020
Re: How to search a match on a line and then make a change on the next line?
>On 2020-05-14 13:32, boB Stepp wrote:
>> Hmm. That is what I was speculating -- that "\1" was empty -- and
>> you have proven that plus giving me another little trouble shooting
>> technique. But an example in the book "Learning the vi and Vim
>> Editors, 7th ed." by Arnold Robbins, Elbert Hannah and Linda Lamb
>> made me believe what I was trying was doable. In chapter 6:
>> Global Replacement on page 82 the authors give this snippet of text:
>>
>> mgibox routine;
>> mgrbox routine;
>> mgabox routine;
>>
>> In this exercise we want to replace "box" with "square". The
>> authors give two ways to accomplish this. One of them is:
>>
>> :g/mg\([ira]]\)box/s//mg\1square/g
>>
>> Here where the line found is also the line to change (unlike mine
>> where I want to change the next line) the "\1" register is
>> accessible.
>
>In this case it's not whether the line is the same but that the
>pattern is the same. By (re)using the pattern from the :g in the :s
>by using an empty pattern here:
>
> s//replacement/flags
>
>it (re)captures the portion captured from the same pattern found in
>the :g part of the command. So if you happened to have two adjacent
>lines both containing "capture", you could do something like
>
> :g/\(capture\)/+s//replacement with \1 in it/
>
>(which has the "+" relative-offset to the line after the initial
>match) to replace the one on the 2nd line with "replacement with
>capture in it".
>
>Hopefully that sheds a bit of light on matters?
I now see the light! Thanks, Tim!
--
Wishing you only the best,
boB Stepp
--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200514220308.GD17993%40Dream-Machine1.
Re: Starting Native Windows GVim 8.2 from MinGW Git Bash
>I finally have a newish Windows 10 64-bit laptop for a course and,
>per instructions, have installed Git Bash that uses MinGW from:
>https://git-scm.com/downloads
>
>I also have a standard native Window build of GVIm 8.2 installed under:
>C:\Program File (x86)\Vim\vim82
>which I believe was the default for the standard installer.
>
>MinGW Git Bash ships with a built-in version of vim 8.2 as MinGW
>program, but does not include GVim.
>
>What I am looking to do is to start the native Windows version of
>GVim from a the Git Bash prompt. Rather than change the path I hoped
>to use a simple bash alias with a full path to start Windows GVim
>8.2. This works except that the bash prompt blocks as if Windows
>GVim is a console program and the shell is waiting to get control
>back of the console. I am not entirely sure why the shell waits for
>Gvim to exit. The same technique I am trying to was recommended for
>MSysGit Bash and Vim 7.4 by Albert Armea at:
>https://blog.albertarmea.com/post/115102365718/using-gvim-from-git-bash
>The best reason I can fathom is that I read elsewhere that MinGW is a
>more minimalist UNIX implementation than say Cygwin and does not
>implement fork() despite providing the header file. Another
>possibility is that some trick integration set up in the bundle for
>Vim and GVim with Git is inadvertently fighting my attempt to use a
>Windows executable.
>
>Due to how Bash is invoked by the Git Bash bundle, the easiest way
>for me to configure user specific bash aliases or the like is to
>create two files:
>
>~/.bash_profile is minimal and contains:
>
>if [ -f ~/.bashrc ]; then. ~/bashrc; fi
>
>~/.bashrc has my local alias and a bash function gvim () as follows:
>
>gvim () { (env -u HOME -u VIM "/c/Program Files (x86)/vim/vim82/gvim.exe" "$*")& }
Self correction: To support multiple parameters properly I should use "$@" not
"@*", which confuses Gvim, so:
~/.bashrc has my local alias and a bash function gvim () as follows:
gvim () { (env -u HOME -u VIM "/c/Program Files (x86)/vim/vim82/gvim.exe" "$@")& }
>Another place on the Internet, I found advice to unset the HOME and
>VIM environment variables local to MinGW Bash as Windows GVIm 8.2 is
>started, but I converted a simple bash alias to bash function. While
>the env command above would run GVim as a simple alias, the Git Bash
>shell blocks waiting for GVim to exit. The bash function is needed
>so I can embed the env in a subshell with parentheses and push it to
>the background, while still passing parameters to the inner command
>line. This bash function works, starting GVim and letting the shell
>continue. I do notice that this Windows GVim shows up as a process
>when using the ps command at the Git Bash prompt. I am not sure if
>anything funny happens, based on the order I close Git Bash and GVim.
>
>I am not sure if this is the best approach. Another idea I saw on
>the Internet suggested using the bash disown built-in command, but I
>was getting syntax errors. I tried debugging with set -x in Git Bash
>but extra commands I did not expect were being generated, probably
>due to Git integration. I decided that this method is best, for now,
>but I am wondering if there are any gotchas lurking here.
>
>Thanks in advance for any advice.
--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200514220224.GC1444%40linux.site.
Re: Runtime of record/play feature
> Hi, I was recently working on a large CSV file in Vim. I needed to do some
> changes in the file and I utilized the recording feature for it. Recording
> feature is really awesome and worked well for my use case.
>
> However working on a file whenever applied on multiple lines, it is slow
> till the point where we can actually see the edit being done on every line.
>
> I would like to know why is it so slow? Has it something to do with the
> design pattern?
>
> Also, is there any consideration of making it faster (if possible)?
Have you tried :set lazyredraw?
What also helps, is switching away from Vim, (e.g. in a terminal
multiplexer move to a different pane, in the gui, simply minimize the
vim window), so that Vim is not busy redrawing
Best,
Christian
--
Bevor ich ein alter Mann wurde, war ich darauf bedacht, würdig zu
leben. Jetzt, im Alter, richtet sich mein Streben darauf, würdig zu
sterben.
-- Lucius Annaeus Seneca (an Lucilius)
--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200514194414.GG2077%40256bit.org.
Re: How to search a match on a line and then make a change on the next line?
>> :g/\(field [[:alnum:]_]*\)address2/+s/pobox/[\1]pobox/
>>
>>you'll see resulting lines like
>>
>> []pobox
>>
>>to show that the contents of \1 are empty.
>
> Hmm. That is what I was speculating -- that "\1" was empty -- and
> you have proven that plus giving me another little trouble shooting
> technique. But an example in the book "Learning the vi and Vim
> Editors, 7th ed." by Arnold Robbins, Elbert Hannah and Linda Lamb
> made me believe what I was trying was doable. In chapter 6:
> Global Replacement on page 82 the authors give this snippet of text:
>
> mgibox routine;
> mgrbox routine;
> mgabox routine;
>
> In this exercise we want to replace "box" with "square". The
> authors give two ways to accomplish this. One of them is:
>
> :g/mg\([ira]]\)box/s//mg\1square/g
>
> Here where the line found is also the line to change (unlike mine
> where I want to change the next line) the "\1" register is
> accessible.
In this case it's not whether the line is the same but that the
pattern is the same. By (re)using the pattern from the :g in the :s
by using an empty pattern here:
s//replacement/flags
it (re)captures the portion captured from the same pattern found in
the :g part of the command. So if you happened to have two adjacent
lines both containing "capture", you could do something like
:g/\(capture\)/+s//replacement with \1 in it/
(which has the "+" relative-offset to the line after the initial
match) to replace the one on the 2nd line with "replacement with
capture in it".
Hopefully that sheds a bit of light on matters?
-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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200514142007.34ce5a94%40bigbox.attlocal.net.