Friday, January 4, 2019

term_sendkeys syntax error on windows

Hi,

From a vimscript, some term_sendkeys syntax does not pass because of quote or not escaped chars.


If you see the attached screen, Point 4 term_sendkeys succeed, not point 5.
Can you help me for the syntax.

Thank you
NiVa


fun! BuildRuby() "{{{
" 1. open a terminal
" terminal

" 2. go back to vimscript and sleep hummm.
" sleep 800m

" 3. get just opened terminal
let bufnr=0
for buf in getbufinfo() | if getbufvar(buf.bufnr,'&buftype')=='terminal' | let bufnr = buf.bufnr | endif | endfor

" 4. init env
call term_sendkeys(bufnr, '"c:/program files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvarsamd64_x86.bat
"')

" 5.
call term_sendkeys(bufnr, 'cd /d '.expand($userprofile).'/source/ruby-2.6.0-rc1
')

endfunction "}}}




--
--
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, January 3, 2019

Re: Problem with function

On Thu, Jan 3, 2019 at 10:09 PM Cesar Romani <cesar.romani@gmail.com> wrote:
>
> I'm using vim 8.1.682 on Windows.
> I'd like to know what is wrong with following function?:
>
> function! Finalize()
> :'<,'>join
> :s/ /,/g
> endfunction
> vmap ,f :call Finalize()<cr>
>
> If I visually select the following text:
>
> 2.233 2.204
> 2.077 2.066 1.987
> 6.381 6.372 6.427 6.437
> 6.152 6.115
>
> It correctly executes, but I get the error:
> E16: Invalid range
>
> But if I execute separately each line inside the function, i.e.
> :'<,'>join
> :s/ /,/g
>
> I don't get any error
>
> Thanks in advance,
>
> --
> Cesar

It's unusual to explicitly use :'<,'> in a function.

Try the following instead:

function Finalize() range
execute a:firstline . ',' . a:lastline 'join'
s/ /,/g
endfunction

The :join command inside the function should then get the same range
that was passed to the :call command calling the function. Without the
"range" flag, the function is called once for every line in the range
of the :call command.

see
:help E124
:help :func-range
:help function-range-example
:help :execute


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

Problem with function

I'm using vim 8.1.682 on Windows.
I'd like to know what is wrong with following function?:

function! Finalize()
:'<,'>join
:s/ /,/g
endfunction
vmap ,f :call Finalize()<cr>

If I visually select the following text:

2.233 2.204
2.077 2.066 1.987
6.381 6.372 6.427 6.437
6.152 6.115

It correctly executes, but I get the error:
E16: Invalid range

But if I execute separately each line inside the function, i.e.
:'<,'>join
:s/ /,/g

I don't get any error

Thanks in advance,

--
Cesar

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

display warning msg a little longer or until another keypress

Hi everyone,

An example of this would be when I have shm-=s and I search for a string, when it wraps I get the warning msg "search hit BOTTOM, continuing at TOP" and I have changed my WarngingMsg highlight to make this easier to see, but without disabling wrapscan, I often find the warning msg disappears so fast that I didn't realize I wrapped until I see the line numbers, etc.
Does anyone know of a way to get the warning msg to display a little longer or require an additional n/N or some such keypress to then continue on ?

thx for everything 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.
For more options, visit https://groups.google.com/d/optout.

Wednesday, January 2, 2019

Re: Dynamically creating an autocmd group

Thanks Andy, didn't notice you can add additional command like that, even though that is essentially what we are doing when you run the command.  Go figure.

--
--
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: Dynamically creating an autocmd group

Am 02.01.2019 um 15:01 schrieb David Fishburn:> :ver
> VIM - Vi IMproved 8.1 (2018 May 18, compiled Dec 30 2018 14:48:55)
> MS-Windows 32-bit GUI version with OLE support
> Included patches: 1-662
>
> I have the following augroup:
>
> augroup MyTest
> autocmd!
> autocmd FocusGained * :if has('clipboard') | echomsg "has clipboard" | endif
> autocmd User * :echomsg "anything"
> augroup END
>
> I want to be able to dynamically create additional entries in this
> augroup based on which version of Vim I am running. I would prefer
> not to just use:
>
> if v:version < 7.1
> augroup ..
> augroup END
> else
> augroup ..
> augroup END
> endif
>
> Since I am checking multiple things and multiple versions and don't
> want to repeat the code over and over again.
>
> I have tried some simple things:
>
> :exec "augroup dave \ autocmd! \ autocmd User Test echomsg 'it worked' \ augroup END"
> :au dave
> --- Autocommands ---
> Press ENTER or type command to continue
>
> exec "augroup dave | autocmd! | autocmd User Test echomsg 'it worked' | augroup END"
> exec "augroup dave \| autocmd! \| autocmd User Test echomsg 'it worked' \| augroup END"
>
> None of them seem to work, just can't get that syntax correct.
>
> If someone can help that would be great.
> The syntax must also support the if statement:
> autocmd FocusGained * :if has('clipboard') | echomsg "has clipboard" | endif
>
> TIA,
> David

It seems to me you just missed some basic syntax (?).

You can write:

:augroup MyTest
:augroup END
:augroup dave
:augroup END

" clear existing autocmds of each group:
:autocmd! MyTest
:autocmd! dave

" add autocommands
:autocmd MyTest FocusGained * :if has('clipboard') | echomsg "has clipboard" | endif
:autocmd dave User Test :echomsg 'It works!'

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

Dynamically creating an autocmd group

:ver
VIM - Vi IMproved 8.1 (2018 May 18, compiled Dec 30 2018 14:48:55)
MS-Windows 32-bit GUI version with OLE support
Included patches: 1-662

I have the following augroup:

augroup MyTest
    autocmd!
    autocmd FocusGained  * :if has('clipboard') | echomsg "has clipboard" | endif
    autocmd User * :echomsg "anything"
augroup END

I want to be able to dynamically create additional entries in this augroup based on which version of Vim I am running.  I would prefer not to just use:

if v:version < 7.1
   augroup ..
   augroup END
else
   augroup ..
   augroup END
endif

Since I am checking multiple things and multiple versions and don't want to repeat the code over and over again.

I have tried some simple things:

:exec "augroup dave \ autocmd! \ autocmd User Test echomsg 'it worked' \ augroup END"
:au dave
--- Autocommands ---
Press ENTER or type command to continue

exec "augroup dave | autocmd! | autocmd User Test echomsg 'it worked' | augroup END"
exec "augroup dave \| autocmd! \| autocmd User Test echomsg 'it worked' \| augroup END"

None of them seem to work, just can't get that syntax correct.

If someone can help that would be great.
The syntax must also support the if statement:
    autocmd FocusGained  * :if has('clipboard') | echomsg "has clipboard" | endif

TIA,
David

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

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