Saturday, November 30, 2019

Re: Problems using :read with external command

On 2019-11-30 20:36, Cesar Romani wrote:
> I have a file, test.txt, containing two lines:
>
> 18415
> 480
>
> If I do:
> :%!gawk "{sum+=$1}END{print sum}"
> I get the result in a new buffer, but if I try to put the result
> below the last line, using
> r %!gawk "{sum+=$1}END{print sum}"
> I get:
> E484: Can't open file test.txt!gawk

If the file is on disk, you can read in the results of passing it
through awk:

:$r !gawk '{sum+=$1}END{print sum}' %

(note the single-quotes to ensure the "$1" gets passed properly to
awk).

Alternatively, you can pass the file (or a range of its lines)
through awk and have awk print the lines as well as the sum:

:%!awk '{i+=$1; print}END{print i}'

Or, you can do it all within vim:

:let @a=0 | g/^/let @a=@a+getline('.')

and then put the contents of register "a" at the end of your file. :-)

-tim



PS: Strangely I needed to do

let @a=@a+getline('.')

because

let @a+=getline('.')

failed with

E734: Wrong variable type for +=

A little unexpected given that the docs say

:let {var} += {expr1} Like ":let {var} = {var} + {expr1}".

but the latter form works where the former form doesn't.





--
--
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/20191130201856.7fd5aad0%40bigbox.attlocal.net.

Problems using :read with external command

I have a file, test.txt, containing two lines:

18415
480

If I do:
:%!gawk "{sum+=$1}END{print sum}"
I get the result in a new buffer, but if I try to put the result below
the last line, using
r %!gawk "{sum+=$1}END{print sum}"
I get:
E484: Can't open file test.txt!gawk

How can I put the result of an external command below the last line?
Many 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/qrv5fi%241kk1%241%40blaine.gmane.org.

Re: vim mode and mapping

thanks. I am more interested to know why separate mappings don't work and how to make it work, if possible. 
this two key mapping will have complexity issue, since everything i* now incurs a mapping, and the same issue (one key is subject to mapping and the next one isn't) might manifest somewhere else, a separate investigation and special mapping to work around every case isn't a good solution.

On Saturday, November 30, 2019 at 2:05:44 AM UTC-8, Igor wrote:
noremap ur ip

--
--
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/88e2c674-6fe7-4b8e-82cc-ab8036cfb309%40googlegroups.com.

Re: vim mode and mapping

noremap ur ip

--
--
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/ea6bd50b-7ec2-4155-ba0b-1f5c47bacb46%40googlegroups.com.

Friday, November 29, 2019

vim mode and mapping

hi, I use colemak keyboard layout, and put many mappings in my vimrc to simulate vim finger movements on the original querty layout. it mostly works fine but there are some mappings don't work up to expectation and I am trying to understand why. for example, if I have these mappings
noremap u i  noremap r p
I expect pressing vur to select current paragraph since that should be mapped to vip. in reality, however, I have to press vup to select the paragraph. judging from the effect, the u key is correctly translated to i for processing, whereas the next r key isn't and I really have to type in a plain p key for vim to receive a functional sequence. this is pretty inconsistent and confusing and I have to remember the key after v is subject to my mappings, and the next one isn't.

what makes to two mapped keys behave differently? as far as I can tell, they should all be available under nvo modes. 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/4b05c8b8-7298-41af-95cf-679fa3c72de9%40googlegroups.com.

Re: vimrc debug help

On 2019-11-29, Francis Grizzly Smit wrote:
> I'd do that in .gvimrc  for a start

That's not necessary. I set mine in my vimrc and it works fine.

On 29/11/2019 20:32, zenius wrote:

> set guifont=Monospace\ 5

What happens when you execute that command at the command line?
Does your system have that font? You can find out what 'guifont' is
set to and where it was last set with

:verbose set guifont?

and get a dialog box allowing you to set an available font with

:set guifont=*

or by selecting Edit -> Select Font... from the menu bar.

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/20191129151810.GC19311%40phoenix.

Re: vimrc debug help

I'd do that in .gvimrc  for a start

try :tab help helpgrep

or :help helpgrep

to learn how to find out how to search form stuff


then

:helpgrep font

or :tab helpgrep font

to get all the help on fonts

or

:tab helpgrep guifont

or :tab help guifont

                    *'guifont'* *'gfn'*
                           *E235* *E596*
'guifont' 'gfn'        string    (default "")
            global
            {not in Vi}
            {only available when compiled with GUI enabled}
    This is a list of fonts which will be used for the GUI version of Vim.
    In its simplest form the value is just one font name.  When
    the font cannot be found you will get an error message.  To try other
    font names a list can be specified, font names separated with commas.
    The first valid font is used.

    On systems where 'guifontset' is supported (X11) and 'guifontset' is
    not empty, then 'guifont' is not used.
:

:

:


On 29/11/2019 20:32, zenius wrote:
Hi guys,

New to the vim_use group - hi :) Apologies if I'm breaking policy with this! Please point me to policy guides if I am.

I'm struggling to set the guifont from my .vimrc and I don't know how to debug it :( Can you advise?

I've been using vim (I use gvim almost exclusively) for a couple of years, but only tend to learn reactively - I face a problem and I search how to solve it. But I can't seem to fix this one! I've included my .vimrc below. I'm using the command that I believe *should* change the guifont, but it doesn't work from my .vimrc. It gets set to (I guess) the default of 'Monospace 16' whenever I open a new vim window. Can any of you see what I'm doing wrong?

Thanks in advance!

(N.B. I pretty much only code in linux world so I haven't got around to trying to set guifont based on OS.

Also, if you see commands where you infer I'm trying to do something, but you know it won't work, please say :) )

.vimrc:

syntax on
set guifont=Monospace\ 5
set backspace=indent,eol,start
set number
set ignorecase
set hlsearch
set cursorline
set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
set list
set lines=15
set columns=80
set directory^=$HOME/.vim/tmp//
set ruler
set autoindent
set noswapfile
filetype plugin indent on

au BufRead,BufNewFile *.v setfiletype systemverilog
au BufRead,BufNewFile *.sv setfiletype systemverilog
au BufRead,BufNewFile *.svh setfiletype systemverilog
au BufRead,BufNewFile *.sva setfiletype systemverilog
au BufRead,BufNewFile *.vc setfiletype systemverilog
au BufRead,BufNewFile *.xml setfiletype xml
--
--
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/1c67ebf9-6c4d-4108-ad9f-759ca9473883%40googlegroups.com.
--
   .~.     In my life God comes first....     /V\         but Linux is pretty high after that :-D    /( )\    Francis (Grizzly) Smit    ^^-^^    http://www.smit.id.au/  

vimrc debug help

Hi guys,

New to the vim_use group - hi :) Apologies if I'm breaking policy with this! Please point me to policy guides if I am.

I'm struggling to set the guifont from my .vimrc and I don't know how to debug it :( Can you advise?

I've been using vim (I use gvim almost exclusively) for a couple of years, but only tend to learn reactively - I face a problem and I search how to solve it. But I can't seem to fix this one! I've included my .vimrc below. I'm using the command that I believe *should* change the guifont, but it doesn't work from my .vimrc. It gets set to (I guess) the default of 'Monospace 16' whenever I open a new vim window. Can any of you see what I'm doing wrong?

Thanks in advance!

(N.B. I pretty much only code in linux world so I haven't got around to trying to set guifont based on OS.

Also, if you see commands where you infer I'm trying to do something, but you know it won't work, please say :) )

.vimrc:

syntax on
set guifont=Monospace\ 5
set backspace=indent,eol,start
set number
set ignorecase
set hlsearch
set cursorline
set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
set list
set lines=15
set columns=80
set directory^=$HOME/.vim/tmp//
set ruler
set autoindent
set noswapfile
filetype plugin indent on

au BufRead,BufNewFile *.v setfiletype systemverilog
au BufRead,BufNewFile *.sv setfiletype systemverilog
au BufRead,BufNewFile *.svh setfiletype systemverilog
au BufRead,BufNewFile *.sva setfiletype systemverilog
au BufRead,BufNewFile *.vc setfiletype systemverilog
au BufRead,BufNewFile *.xml setfiletype xml

--
--
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/1c67ebf9-6c4d-4108-ad9f-759ca9473883%40googlegroups.com.

Thursday, November 28, 2019

Re: Trailing ^M on Windows

Yes, it was the Cygwin version of Vim. Is it expected to behave differently, in terms of EOL automatic recognition? (sorry for asking something I could have checked myself, but I am on the go, and figured it'd be best if I replied to you and kept thr thread alive).

Thanks 

Il gio 28 nov 2019, 17:18 'Andy Wokula' via vim_use <vim_use@googlegroups.com> ha scritto:
Am 16.11.2019 um 12:25 schrieb Matteo Landi:
> Hello everyone,
>
> I have been battling with trailing ^M on Windows

Are you using the Cygwin version of Vim?
     :echo has('win32unix')

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/5DDFF358.6000502%40yahoo.de.

--
--
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/CAKpQHWYZd9BMxEG2ZgrDn_A-zvG0H-7aa1u0pnQ6fcfTaVPDfg%40mail.gmail.com.

Re: Why does argsdo duplicates a file?

Thank you John Little for detailed explanation and thanks a lot Gary Johnson for simplified solution.

--
--
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/2e4e9571-7ae2-4147-b33c-6efc0657fffc%40googlegroups.com.

Re: Trailing ^M on Windows

Am 16.11.2019 um 12:25 schrieb Matteo Landi:
> Hello everyone,
>
> I have been battling with trailing ^M on Windows

Are you using the Cygwin version of Vim?
:echo has('win32unix')

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/5DDFF358.6000502%40yahoo.de.

Wednesday, November 27, 2019

Re: Why does argsdo duplicates a file?

On 2019-11-26, John Little wrote:
> On Wednesday, November 27, 2019 at 1:00:31 AM UTC+13, Igor wrote:
>
> Assuming the current directory has files a.txt, b.txt, c.txt
>
> : args *.txt
>
> : argdo vs
>
> > What happens is: c.txt is displayed left most, then the same c.txt ...
>
> > I expected to see c.txt displayed in one single window, but it it displayed
> in two windows. Why?
>
> The argdo vs behaves like you'd entered the following sequence:
>
> :vs
> :next
> :vs
> :next
> :vs
>
> Each command in isolation is doing its thing correctly.  There's three splits,
> resulting in four vim windows.
>
> If what you want is as many vim windows as arguments, in order, try
>
> :1,$-argdo vs | wincmd w
> :next
>
> Note there's lots of options affecting vim's behaviour here.  For example, if
> you have 'splitright' set, it's simpler:
>
> :set spr
> :1,$-argdo vs
> :next

Even simpler is

:vert all

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/20191127083239.GB31400%40phoenix.

Tuesday, November 26, 2019

Re: Why does argsdo duplicates a file?

On Wednesday, November 27, 2019 at 1:00:31 AM UTC+13, Igor wrote:

Assuming the current directory has files a.txt, b.txt, c.txt

: args *.txt

: argdo vs

> What happens is: c.txt is displayed left most, then the same c.txt ...

> I expected to see c.txt displayed in one single window, but it it displayed in two windows. Why?

The argdo vs behaves like you'd entered the following sequence:

:vs
:next
:vs
:next
:vs

Each command in isolation is doing its thing correctly.  There's three splits,
resulting in four vim windows.

If what you want is as many vim windows as arguments, in order, try

:1,$-argdo vs | wincmd w
:next

Note there's lots of options affecting vim's behaviour here.  For example, if you have 'splitright' set, it's simpler:

:set spr
:1,$-argdo vs
:next

Regards, John Little

--
--
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/07bbb4a8-dc68-47ca-875c-a90a8a749507%40googlegroups.com.

highlights two patterns in same line not possible ?

Hi,

According this content:

      SPBNB _008
_008: NOP   0; 


and those highlight pattern to recognize bold words it seems this highlight just one out of both why ?

Patterns:
syn match s7JumpStatement   /^\(L*\d\+:\)*\s\+\zs\(SPA\|SPL\|SPBNB\|SPBN\|SPBB\|SPB\|SPBI\|SPBIN\|SLW\|SPO\|SPS\|SPZ\|SPN\|SPP\|SPM\|SPPZ\|SPMZ\|SPU\|LOOP\)\ze\(\w\+;\)\@!/
syn match s7JumpToLabel     /^\s\+\(SPA\|SPL\|SPBNB\|SPBN\|SPBB\|SPB\|SPBI\|SPBIN\|SLW\|SPO\|SPS\|SPZ\|SPN\|SPP\|SPM\|SPPZ\|SPMZ\|SPU\|LOOP\)\s\+\zs\w\+\ze;.*$/
    HiLink s7JumpStatement       Statement
    HiLink s7JumpToLabel         JumpLabel


Thank you
NiVa

--
--
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/ab6af423-3b5b-473e-a86c-9467e9a6c093%40googlegroups.com.

Why does argsdo duplicates a file?

Hi,
on vim 8.1.1244 on Ubuntu I started vim with: vim -u NONE
After using it for a while I decided to open some files into argument list: args *.txt
Now I would like to split those files: argdo vs
What happens is: c.txt is displayed left most, then the same c.txt is displayed in second window,
then b.txt is displayed in its own window and at the right there is d.txt displayed in the last window.

I expected to see c.txt displayed in one single window, but it it displayed in two windows. Why?

Regards

--
--
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/7e181a3b-4bba-4114-b2f7-86bfabe59b79%40googlegroups.com.

Saturday, November 23, 2019

Re: Mapping erases search count message

On 2019-11-23, Bram Moolenaar wrote:
> Gary Johnson wrote:
>
> > On 2019-08-29, Christian Brabandt wrote:
> > > On Do, 29 Aug 2019, Christian Brabandt wrote:
> > >
> > > >
> > > > On Di, 27 Aug 2019, Gary Johnson wrote:
> > > >
> > > > > On 2019-08-28, Christian Brabandt wrote:
> > > > > > On Di, 27 Aug 2019, Gary Johnson wrote:
> > > > > >
> > > > > > > I just tried exposing the search count message by removing 'S' from
> > > > > > > 'shortmess', but I couldn't see it. I discovered that it is hidden,
> > > > > > > erased and/or not updated by a couple of my mappings.
> > > > > > >
> > > > > > > nnoremap <silent> n nzv:call AdjCursor()<CR>
> > > > > > > nnoremap <silent> N Nzv:call AdjCursor()<CR>
> > > > > > >
> > > > > > > Here is a simple experiment that demonstrates the problem. Create
> > > > > > > a file, test.vim, that contains the following.
> > > > > > >
> > > > > > > set shortmess-=S
> > > > > > > nnoremap <silent> n n
> > > > > > > help map.txt
> > > > > > >
> > > > > > > Open a standard-sized, 80x24 terminal, and in it run
> > > > > > >
> > > > > > > $ vim -N -u NONE -i NONE -S test.vim
> > > > > > >
> > > > > > > Then search for "command":
> > > > > > >
> > > > > > > /command
> > > > > > >
> > > > > > > After hitting Enter, the cursor will be at the start of "commands"
> > > > > > > on line 7 and the command line will contain this:
> > > > > > >
> > > > > > > /command [1/>99]
> > > > > > >
> > > > > > > After hitting 'n', the cursor advances to line 13 and the command
> > > > > > > line stays the same, even showing "[1/>99]" when it should be
> > > > > > > showing "[2/>99]".
> > > > > > >
> > > > > > > Another 'n' advances the cursor to line 17, the screen scrolls
> > > > > > > up so that that line is at the bottom of the window, and the command
> > > > > > > line is empty--no search count message at all.
> > > > > > >
> > > > > > > I would think that <silent> would prevent the mapping from
> > > > > > > disturbing the command line, in which case this is a bug.
> > > > > > >
> > > > > > > If it's not a bug, then is there some way of defining a mapping that
> > > > > > > does not interfere with the search count message, or some way of
> > > > > > > restoring that message at the end of a mapping?
> > > > > >
> > > > > > Is that with patch 8.1.1288 included?
> > > > >
> > > > > Sorry, I forgot to include the version information. Yes, I used the
> > > > > latest version, 8.1.1933.
> > > >
> > > > Hm, I need to investigate.
> > >
> > > I see what is happening. A mapping with the `<silent>` flag will set the
> > > internal variable cmd_silent to prevent it from being output the command
> > > line. So what your mapping does is it acts like 'n' without outputting
> > > anything on the command line.
> > >
> > > But this is not what you want. You want the default behaviour of n,
> > > which does output the command to search + the new search index feature.
> > >
> > > (See the difference on the commandline between a plain `n` and a n
> > > mapped with `nnoremap <silent> n n`).
> > >
> > > So the obvious fix would be to remove the `<silent>` command. While this
> > > fixes your minimal test case, it most likely is no fix for your actual
> > > issue, that calling the AdjCursor() function will be output in the
> > > command line in addition (possibly overwriting the command line).
> > >
> > > What might work (depending on the complexity of your AdjCursor()
> > > function) is to use an expression mapping that simply returns 'n' after
> > > having done whatever action it needs to be doing. However, this might be
> > > a bit difficult since you want this to happen after the cursor has been
> > > placed.
> > >
> > > Another alternative might be a mapping like this:
> > >
> > > nmap n nzv
> > > nnoremap <silent> zv zv:call AdjCursor()<cr>
> >
> > Thanks for looking further into this, Christian.
> >
> > I don't understand how that first mapping in your alternative
> > mappings works. I thought that using nmap (not nnoremap) to map
> > n to a rhs including n would cause an infinite recursion, but it
> > doesn't.
> >
> > Those mappings solve part of the problem. That is, if AdjCursor()
> > is an empty function, they work fine--the search count message is
> > always visible. But if AdjCursor() is the actual function (which
> > scrolls the window when needed to keep the cursor at least two lines
> > from the top and bottom), then whenever the window is scrolled, the
> > message disappears.
> >
> > In fact, removing all the mappings and just executing Ctrl-E or
> > Ctrl-Y to scroll the window after a search erases the search count
> > message. I think that's a bug. I can see no reason why scrolling
> > should erase that message unless scrolling moves the cursor.
> >
> > Further, certain motion commands such as j, k and gg _don't_ erase
> > the search count message, even though it would make sense for them
> > to do so. It's weird to jump from the bottom of a buffer to the top
> > with gg and still see the last search count message in the command
> > line.
> >
> > The purpose of AdjCursor () is to scroll the window after a search
> > moves the cursor near the top or bottom of the window so as to
> > provide at least two lines of context around the cursor. (It should
> > really be named AdjWindow().) It behaves like scrolloff=2, but only
> > after certain commands. I don't want 'scrolloff' on all the time.
> >
> > That gave me an idea, a different solution to the problem:
> > temporarily enable 'scrolloff' instead of scrolling the window.
> > Here is what I just came up with and it seems to work well.
> >
> > nmap <silent> n :call ScrolloffCmd('n')<cr>
> > nmap <silent> N :call ScrolloffCmd('N')<cr>
> > function! ScrolloffCmd(cmd)
> > set scrolloff=2
> > try
> > exe 'normal!' a:cmd
> > catch
> > echohl ErrorMsg
> > echomsg matchstr(v:exception, ':\zs.*')
> > echohl NONE
> > endtry
> > set scrolloff=0
> > endfunction
>
> Looking through older problems...
>
> I tried the example with remapping "n", but it works OK for me.
> Was this problem fixed already? Or is only that example fixed and there
> a remaining problem?

There was a patch that fixed part of the problem, and I rewrote my
function to avoid another part of the problem. It's been working
fine since early September. I don't think there is any more that
you need to do. Thank you and Christian again.

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/20191124074541.GA31400%40phoenix.

Re: How to use "tail -f" in Vim's 8.1 :terminal command window?

* Bram Moolenaar <Bram@moolenaar.net> wrote:
>
> It works fine for me. It might indeed depend on the value of
> 'backupcopy'.
I also tried 'set bkc=yes' in vimrc, it works. But it is not very responsive. Sometimes, tail -f didn't update the changes. But most of the time it does.

--
Gua Chung Lim

"UNIX is basically a simple operating system,
but you have to be a genius to understand the simplicity."
-- Dennis M. Ritchie

--
--
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/20191124061410.GA114%40gmail.com.

Re: Mapping erases search count message

Gary Johnson wrote:

> On 2019-08-29, Christian Brabandt wrote:
> > On Do, 29 Aug 2019, Christian Brabandt wrote:
> >
> > >
> > > On Di, 27 Aug 2019, Gary Johnson wrote:
> > >
> > > > On 2019-08-28, Christian Brabandt wrote:
> > > > > On Di, 27 Aug 2019, Gary Johnson wrote:
> > > > >
> > > > > > I just tried exposing the search count message by removing 'S' from
> > > > > > 'shortmess', but I couldn't see it. I discovered that it is hidden,
> > > > > > erased and/or not updated by a couple of my mappings.
> > > > > >
> > > > > > nnoremap <silent> n nzv:call AdjCursor()<CR>
> > > > > > nnoremap <silent> N Nzv:call AdjCursor()<CR>
> > > > > >
> > > > > > Here is a simple experiment that demonstrates the problem. Create
> > > > > > a file, test.vim, that contains the following.
> > > > > >
> > > > > > set shortmess-=S
> > > > > > nnoremap <silent> n n
> > > > > > help map.txt
> > > > > >
> > > > > > Open a standard-sized, 80x24 terminal, and in it run
> > > > > >
> > > > > > $ vim -N -u NONE -i NONE -S test.vim
> > > > > >
> > > > > > Then search for "command":
> > > > > >
> > > > > > /command
> > > > > >
> > > > > > After hitting Enter, the cursor will be at the start of "commands"
> > > > > > on line 7 and the command line will contain this:
> > > > > >
> > > > > > /command [1/>99]
> > > > > >
> > > > > > After hitting 'n', the cursor advances to line 13 and the command
> > > > > > line stays the same, even showing "[1/>99]" when it should be
> > > > > > showing "[2/>99]".
> > > > > >
> > > > > > Another 'n' advances the cursor to line 17, the screen scrolls
> > > > > > up so that that line is at the bottom of the window, and the command
> > > > > > line is empty--no search count message at all.
> > > > > >
> > > > > > I would think that <silent> would prevent the mapping from
> > > > > > disturbing the command line, in which case this is a bug.
> > > > > >
> > > > > > If it's not a bug, then is there some way of defining a mapping that
> > > > > > does not interfere with the search count message, or some way of
> > > > > > restoring that message at the end of a mapping?
> > > > >
> > > > > Is that with patch 8.1.1288 included?
> > > >
> > > > Sorry, I forgot to include the version information. Yes, I used the
> > > > latest version, 8.1.1933.
> > >
> > > Hm, I need to investigate.
> >
> > I see what is happening. A mapping with the `<silent>` flag will set the
> > internal variable cmd_silent to prevent it from being output the command
> > line. So what your mapping does is it acts like 'n' without outputting
> > anything on the command line.
> >
> > But this is not what you want. You want the default behaviour of n,
> > which does output the command to search + the new search index feature.
> >
> > (See the difference on the commandline between a plain `n` and a n
> > mapped with `nnoremap <silent> n n`).
> >
> > So the obvious fix would be to remove the `<silent>` command. While this
> > fixes your minimal test case, it most likely is no fix for your actual
> > issue, that calling the AdjCursor() function will be output in the
> > command line in addition (possibly overwriting the command line).
> >
> > What might work (depending on the complexity of your AdjCursor()
> > function) is to use an expression mapping that simply returns 'n' after
> > having done whatever action it needs to be doing. However, this might be
> > a bit difficult since you want this to happen after the cursor has been
> > placed.
> >
> > Another alternative might be a mapping like this:
> >
> > nmap n nzv
> > nnoremap <silent> zv zv:call AdjCursor()<cr>
>
> Thanks for looking further into this, Christian.
>
> I don't understand how that first mapping in your alternative
> mappings works. I thought that using nmap (not nnoremap) to map
> n to a rhs including n would cause an infinite recursion, but it
> doesn't.
>
> Those mappings solve part of the problem. That is, if AdjCursor()
> is an empty function, they work fine--the search count message is
> always visible. But if AdjCursor() is the actual function (which
> scrolls the window when needed to keep the cursor at least two lines
> from the top and bottom), then whenever the window is scrolled, the
> message disappears.
>
> In fact, removing all the mappings and just executing Ctrl-E or
> Ctrl-Y to scroll the window after a search erases the search count
> message. I think that's a bug. I can see no reason why scrolling
> should erase that message unless scrolling moves the cursor.
>
> Further, certain motion commands such as j, k and gg _don't_ erase
> the search count message, even though it would make sense for them
> to do so. It's weird to jump from the bottom of a buffer to the top
> with gg and still see the last search count message in the command
> line.
>
> The purpose of AdjCursor () is to scroll the window after a search
> moves the cursor near the top or bottom of the window so as to
> provide at least two lines of context around the cursor. (It should
> really be named AdjWindow().) It behaves like scrolloff=2, but only
> after certain commands. I don't want 'scrolloff' on all the time.
>
> That gave me an idea, a different solution to the problem:
> temporarily enable 'scrolloff' instead of scrolling the window.
> Here is what I just came up with and it seems to work well.
>
> nmap <silent> n :call ScrolloffCmd('n')<cr>
> nmap <silent> N :call ScrolloffCmd('N')<cr>
> function! ScrolloffCmd(cmd)
> set scrolloff=2
> try
> exe 'normal!' a:cmd
> catch
> echohl ErrorMsg
> echomsg matchstr(v:exception, ':\zs.*')
> echohl NONE
> endtry
> set scrolloff=0
> endfunction

Looking through older problems...

I tried the example with remapping "n", but it works OK for me.
Was this problem fixed already? Or is only that example fixed and there
a remaining problem?

--
FIXME and XXX are two common keywords used to mark broken or incomplete code
not only since XXX as a sex reference would grab everybody's attention but
simply due to the fact that Vim would highlight these words.
-- Hendrik Scholz

/// 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/201911232215.xANMFexv031914%40masaka.moolenaar.net.

Re: How to use "tail -f" in Vim's 8.1 :terminal command window?

Brian Matthews wrote:

> On 11/23/19 10:12 AM, Matteo Landi wrote:
> > Did you try the same, tail - f, but from outside vim?
> >
> > If not wrong, vim is dumping the whole buffer to the file on save
> (not 'appending' new content) so I wouldn't be surprised it tail - f did
> not work because of it.
> >
>
> And I think by default vim renames the current file then writes to a
> completely new file, so the file you're tailing never changes, in fact
> it gets deleted. You can modify that behavior with various options
> (backup, writebackup, backupcopy). I got tail -f to show something by
> setting nobackup (which is the default) and nowritebackup (which isn't),
> then modifying a file I was tailing. Because of the way tail works, this
> would only do something useful if you're just adding lines to the file,
> but it does work.

It works fine for me. It might indeed depend on the value of
'backupcopy'.

--
Nobody will ever need more than 640 kB RAM.
-- Bill Gates, 1983
Windows 98 requires 16 MB RAM.
-- Bill Gates, 1999
Logical conclusion: Nobody will ever need Windows 98.

/// 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/201911232058.xANKw3BP020260%40masaka.moolenaar.net.

Re: How to use "tail -f" in Vim's 8.1 :terminal command window?

On 11/23/19 10:12 AM, Matteo Landi wrote:
> Did you try the same, tail - f, but from outside vim?
>
> If not wrong, vim is dumping the whole buffer to the file on save
(not 'appending' new content) so I wouldn't be surprised it tail - f did
not work because of it.
>

And I think by default vim renames the current file then writes to a
completely new file, so the file you're tailing never changes, in fact
it gets deleted. You can modify that behavior with various options
(backup, writebackup, backupcopy). I got tail -f to show something by
setting nobackup (which is the default) and nowritebackup (which isn't),
then modifying a file I was tailing. Because of the way tail works, this
would only do something useful if you're just adding lines to the file,
but it does work.

Brian

--
--
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/0a0e1b32-e46b-43ba-8730-cbc3a39eeed6%40gmail.com.

Re: How to use "tail -f" in Vim's 8.1 :terminal command window?

Did you try the same, tail - f, but from outside vim?

If not wrong, vim is dumping the whole buffer to the file on save (not 'appending' new content) so I wouldn't be surprised it tail - f did not work because of it.

Il sab 23 nov 2019, 16:35 Igor <igor2x@gmail.com> ha scritto:
Hi,
I installed Vim 8.1 on Ubuntu 16.04 using PPA.

1. Now I am editing myfile.txt file in vim.
2. I opened new terminal windows inside vim
with command: :terminal

3. New terminal opens. I typed in:
tail -f myfile.txt
4. I moved back to ordinary Vim window:
Ctrl+w
5. I type in some text and save with :w

PROBLEM: I expect terminal windows refreshes
because of tail -f command, but actually
nothing really happens in :terminal window.

If this is working this would be super-powerful
feature using vim and ssh.

Any idea?

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/d42999ee-a94b-46a7-80e4-5f7ccf60c51a%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/CAKpQHWZKk7n9Y30hidNgtuhk_nd4C8Xyaqzs%2B%3D2ZSq8bHicnYA%40mail.gmail.com.

How to use "tail -f" in Vim's 8.1 :terminal command window?

Hi,
I installed Vim 8.1 on Ubuntu 16.04 using PPA.

1. Now I am editing myfile.txt file in vim.
2. I opened new terminal windows inside vim
with command: :terminal

3. New terminal opens. I typed in:
tail -f myfile.txt
4. I moved back to ordinary Vim window:
Ctrl+w
5. I type in some text and save with :w

PROBLEM: I expect terminal windows refreshes
because of tail -f command, but actually
nothing really happens in :terminal window.

If this is working this would be super-powerful
feature using vim and ssh.

Any idea?

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/d42999ee-a94b-46a7-80e4-5f7ccf60c51a%40googlegroups.com.

Thursday, November 21, 2019

Re: Are the --enable-hangulinput and --enable-xim confilct?

On Thu, Nov 21, 2019 at 4:47 PM Bram Moolenaar <Bram@moolenaar.net> wrote:
>
>
> Namsh wrote:
>
> > >> 2019-08-25 오후 2:25에 Hongyi Zhao 이(가) 쓴 글:
> > >>> Hi,
> > >>>
> > >>> I try to build vim with the --enable-hangulinput and --enable-xim
> > >>> confilct at the same time, but failed with error:
> > >>>
> > >>> -------------------------
> > >>> vim.h:1585:63: error: called object 'size_t' is not a function or
> > >>> function pointer
> > >>> #define STRNCMP(d, s, n) strncmp((char *)(d), (char *)(s), (size_t)(n))
> > >>> ^
> > >>> ex_docmd.c:8459:6: note: in expansion of macro 'STRNCMP'
> > >>> if (STRNCMP(arg, "FALLBACK ", 9) == 0)
> > >>> ^~~~~~~
> > >>> In file included from /usr/include/wchar.h:887:0,
> > >>> from spell.h:250,
> > >>> from vim.h:2110,
> > >>> from ex_docmd.c:14:
> > >>> /usr/include/x86_64-linux-gnu/bits/wchar2.h:507:20: note: declared here
> > >>> __fortify_function size_t
> > >>> ^~~~~~
> > >>> Makefile:3059: recipe for target 'objects/ex_docmd.o' failed
> > >>> make[1]: *** [objects/ex_docmd.o] Error 1
> > >>> make[1]: Leaving directory '/home/werner/software/editor/vim/vim.git/src'
> > >>> Makefile:26: recipe for target 'first' failed
> > >>> make: *** [first] Error 2
> > >>> -----------------------------
> > >>>
> > >>> Are these two options conflict?
> > >>
> > >> Regardless of compilation error, the hangulin feature is for
> > >> environments where XIM is not available.
> > >>
> > >> You can find next line with ':help hangul'.
> > >> ./configure --with-x --enable-multibyte --enable-hangulinput \
> > >> --disable-xim
> > >
> > > That's a bit of a disadvantage when someone tries to build a version
> > > that works with multiple languages. Can we make this a runtime choice
> > > instead of a compile time choice? No idea how much work that would be.
> >
> > Here is a minimal patch (no documentation, no indenting to minimize).
> > If vim supports both xim and hangulinpt and user set 'imdisable',
> > hangulinput feature is selected.
> >
> > I tested this patch by adding '--enable-xim --enable-hangulinput' to my
> > default configure option.
> > $ auto/configure --enable-perlinterp=no --disable-gpm
> > --enable-python3interp=dynamic --enable-tclinterp=no --enable-cscope
> > --with-features=huge --enable-terminal --enable-multibyte --enable-xim
> > --enable-hangulinput --prefix=/opt/local --with-x --enable-gui=gtk3
> >
> > While testing this patch, I noticed one glitch.
> > Though I set 'imdisable' in the vimrc and I confirmed the setting with
> > ':set imdisable?', when I typed S-Space for the first time, vim connects
> > to XIM. After that, go to english input mode and type S-Space again, vim
> > enters to hangulinput mode. My system environement may cause this glitch??
>
> Now that I try this patch I notice that hangulin.c doesn't build.
> Since nobody complained and this input method is unmaintained, let's
> just remove it.
>
> I hope someone can re-implement this for utf-8 encoding.

IIRC, +hangul_input was incompatible with GTK[1-3]. But don't take my
word for it, I don't speak Korean.

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/CAJkCKXtTanRCNAozjEo%2BSeSa%3Db%3DobNbinUfr7t_8c_22FhQs4Q%40mail.gmail.com.

Re: Are the --enable-hangulinput and --enable-xim confilct?

Namsh wrote:

> >> 2019-08-25 오후 2:25에 Hongyi Zhao 이(가) 쓴 글:
> >>> Hi,
> >>>
> >>> I try to build vim with the --enable-hangulinput and --enable-xim
> >>> confilct at the same time, but failed with error:
> >>>
> >>> -------------------------
> >>> vim.h:1585:63: error: called object 'size_t' is not a function or
> >>> function pointer
> >>> #define STRNCMP(d, s, n) strncmp((char *)(d), (char *)(s), (size_t)(n))
> >>> ^
> >>> ex_docmd.c:8459:6: note: in expansion of macro 'STRNCMP'
> >>> if (STRNCMP(arg, "FALLBACK ", 9) == 0)
> >>> ^~~~~~~
> >>> In file included from /usr/include/wchar.h:887:0,
> >>> from spell.h:250,
> >>> from vim.h:2110,
> >>> from ex_docmd.c:14:
> >>> /usr/include/x86_64-linux-gnu/bits/wchar2.h:507:20: note: declared here
> >>> __fortify_function size_t
> >>> ^~~~~~
> >>> Makefile:3059: recipe for target 'objects/ex_docmd.o' failed
> >>> make[1]: *** [objects/ex_docmd.o] Error 1
> >>> make[1]: Leaving directory '/home/werner/software/editor/vim/vim.git/src'
> >>> Makefile:26: recipe for target 'first' failed
> >>> make: *** [first] Error 2
> >>> -----------------------------
> >>>
> >>> Are these two options conflict?
> >>
> >> Regardless of compilation error, the hangulin feature is for
> >> environments where XIM is not available.
> >>
> >> You can find next line with ':help hangul'.
> >> ./configure --with-x --enable-multibyte --enable-hangulinput \
> >> --disable-xim
> >
> > That's a bit of a disadvantage when someone tries to build a version
> > that works with multiple languages. Can we make this a runtime choice
> > instead of a compile time choice? No idea how much work that would be.
>
> Here is a minimal patch (no documentation, no indenting to minimize).
> If vim supports both xim and hangulinpt and user set 'imdisable',
> hangulinput feature is selected.
>
> I tested this patch by adding '--enable-xim --enable-hangulinput' to my
> default configure option.
> $ auto/configure --enable-perlinterp=no --disable-gpm
> --enable-python3interp=dynamic --enable-tclinterp=no --enable-cscope
> --with-features=huge --enable-terminal --enable-multibyte --enable-xim
> --enable-hangulinput --prefix=/opt/local --with-x --enable-gui=gtk3
>
> While testing this patch, I noticed one glitch.
> Though I set 'imdisable' in the vimrc and I confirmed the setting with
> ':set imdisable?', when I typed S-Space for the first time, vim connects
> to XIM. After that, go to english input mode and type S-Space again, vim
> enters to hangulinput mode. My system environement may cause this glitch??

Now that I try this patch I notice that hangulin.c doesn't build.
Since nobody complained and this input method is unmaintained, let's
just remove it.

I hope someone can re-implement this for utf-8 encoding.

--
hundred-and-one symptoms of being an internet addict:
98. The Alta Vista administrators ask you what sites are missing
in their index files.

/// 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/201911211546.xALFkrp9004253%40masaka.moolenaar.net.

Re: vim Startup Problem: autoreplace

On Mi, 20 Nov 2019, Heinz Meier wrote:

> Hi,
>
> every time I start vim it replaces the end of the recent line with the letter
> "g" and end-of-line. This is very annoying. It does not happen if I edit the
> files as root.
>
> My ~/.vimrc is empty.
>
> Any idea what is wrong with my setup?

This is most likely terminal related. However those issues should be
fixed with the latest version. But you mnetioned neither vim nor
terminal version. Make sure your $TERM variable is configured correctly.
Also please show the output of v:termresponse.


Best,
Christian
--
Vor allem der Seele wegen ist es nötig, den Körper zu üben.
-- Jean Jacques Rousseau

--
--
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/20191121083910.GD498%40256bit.org.

Wednesday, November 20, 2019

vim Startup Problem: autoreplace

Hi,

every time I start vim it replaces the end of the recent line with the letter "g" and end-of-line. This is very annoying. It does not happen if I edit the files as root.

My ~/.vimrc is empty.

Any idea what is wrong with my setup?

Michael Schwartzkopff

--
--
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/340ed314-88e7-41ab-bc1d-f4be2a786d9a%40googlegroups.com.

Tuesday, November 19, 2019

Re: Trailing ^M on Windows

Hi Tony,

I was actually writing a plugin for this, and since I could change its implementation I ended up with something like (note the call to substitute() right after system()):

function! s:paste(...) " {{{
  let l:after = get(a:, 1, 1)
  let reg_save = @@

  let @@ = system(g:cb_paste_prg)
  " XXX pastin on Windows somehow leaves trailing ^M
  " gotta figure out a better way to fix this, but
  " for now, this will do!
  let @@ = substitute(@@, "\r\n", "\n", "g")
  setlocal paste
  if l:after
    exe 'normal p'
  else
    exe 'normal P'
  endif
  setlocal nopaste

  let @@ = reg_save
endfunction " }}}

I will leave this here for a little while, and then I will probably cross-post it on vim_dev.

Thanks again for the help.

On Mon, Nov 18, 2019 at 10:43 PM Tony Mechelynck <antoine.mechelynck@gmail.com> wrote:
On Mon, Nov 18, 2019 at 4:11 PM Matteo Landi <matteo@matteolandi.net> wrote:
>
> Hi Tony,
>
> The thing is, :read! appears to be stripping ^M already, irrespective of the use of ++opts:
>
>   :read !powershell.exe Get-Clipboard
>   :read ++ff=unix !powershell.exe Get-Clipboard
>   :read ++ff=dos !powershell.exe Get-Clipboard
>
> To be honest, I'd expect the second one, where we specify ++ff=unix, to leave trailing ^M, but somehow that's not happening, and for your reference (after I vim -u NONE):
>
>   :verbose set ff
>
> Returns 'fileformat=unix'
>
>   :verbose set ffs
>
> Returns 'fileformats=unix,dos'
>
> So am I correct if I say that there is something "weird" going on with system()?  I also found the following at the end of system()'s help page, but somehow the experienced behavior is not the documented one:
>
>   To make the result more system-independent, the shell output
>   is filtered to replace <CR> with <NL> for Macintosh, and
>   <CR><NL> with <NL> for DOS-like systems.
>
> I even tried to give systemlist() a go, but each entry of the array still has that trailing ^M, so it really seems like Vim cannot properly guess the fileformat from the command output.
>
> I am really in the dark here.

So am I.

As a last resort, the following Normal-mode mapping will remove (after
the fact) all ^M characters found at he end of a line:

:map <F5> :%s/<Ctrl-M>$//<CR>

Of course, you can replace <F5> by something else (if for instance
your Normal-mode F5 key is already mapped).

Meaning of the {rhs}:
        :       start an ex-command
        %       or 1,$ : from top to bottom of the file
        s       :s[ubstitute] (search and replace)
        /       replace what
        <Ctrl-M>  (typed as such: less-than, C, etc.) : ^M (carriage return)
        $       at end-of-line
        /       replace by what
        (nothing)   replace by nothing
        /       end of replace-what text
        (nothing)   no flags: replace once (at most) per line (N.B.
there can be only one end-of-line per line)
        <CR>    end of ex-command

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/CAJkCKXsaTWz2Mw-8nKe5H05_2WFG_iPNnEtMa1bCQ3aN0Ja-7g%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/CAKpQHWbLxLLvgQhRBX1b5Lg8xZZYWKAM-rJa4aw3Ofvyhkaqug%40mail.gmail.com.

Monday, November 18, 2019

Re: Trailing ^M on Windows

On Mon, Nov 18, 2019 at 4:11 PM Matteo Landi <matteo@matteolandi.net> wrote:
>
> Hi Tony,
>
> The thing is, :read! appears to be stripping ^M already, irrespective of the use of ++opts:
>
> :read !powershell.exe Get-Clipboard
> :read ++ff=unix !powershell.exe Get-Clipboard
> :read ++ff=dos !powershell.exe Get-Clipboard
>
> To be honest, I'd expect the second one, where we specify ++ff=unix, to leave trailing ^M, but somehow that's not happening, and for your reference (after I vim -u NONE):
>
> :verbose set ff
>
> Returns 'fileformat=unix'
>
> :verbose set ffs
>
> Returns 'fileformats=unix,dos'
>
> So am I correct if I say that there is something "weird" going on with system()? I also found the following at the end of system()'s help page, but somehow the experienced behavior is not the documented one:
>
> To make the result more system-independent, the shell output
> is filtered to replace <CR> with <NL> for Macintosh, and
> <CR><NL> with <NL> for DOS-like systems.
>
> I even tried to give systemlist() a go, but each entry of the array still has that trailing ^M, so it really seems like Vim cannot properly guess the fileformat from the command output.
>
> I am really in the dark here.

So am I.

As a last resort, the following Normal-mode mapping will remove (after
the fact) all ^M characters found at he end of a line:

:map <F5> :%s/<Ctrl-M>$//<CR>

Of course, you can replace <F5> by something else (if for instance
your Normal-mode F5 key is already mapped).

Meaning of the {rhs}:
: start an ex-command
% or 1,$ : from top to bottom of the file
s :s[ubstitute] (search and replace)
/ replace what
<Ctrl-M> (typed as such: less-than, C, etc.) : ^M (carriage return)
$ at end-of-line
/ replace by what
(nothing) replace by nothing
/ end of replace-what text
(nothing) no flags: replace once (at most) per line (N.B.
there can be only one end-of-line per line)
<CR> end of ex-command

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/CAJkCKXsaTWz2Mw-8nKe5H05_2WFG_iPNnEtMa1bCQ3aN0Ja-7g%40mail.gmail.com.

Re: Trailing ^M on Windows

Hi Tony,

The thing is, :read! appears to be stripping ^M already, irrespective of the use of ++opts:

  :read !powershell.exe Get-Clipboard
  :read ++ff=unix !powershell.exe Get-Clipboard
  :read ++ff=dos !powershell.exe Get-Clipboard

To be honest, I'd expect the second one, where we specify ++ff=unix, to leave trailing ^M, but somehow that's not happening, and for your reference (after I vim -u NONE):

  :verbose set ff

Returns 'fileformat=unix'

  :verbose set ffs

Returns 'fileformats=unix,dos'

So am I correct if I say that there is something "weird" going on with system()?  I also found the following at the end of system()'s help page, but somehow the experienced behavior is not the documented one:

  To make the result more system-independent, the shell output
  is filtered to replace <CR> with <NL> for Macintosh, and
  <CR><NL> with <NL> for DOS-like systems.

I even tried to give systemlist() a go, but each entry of the array still has that trailing ^M, so it really seems like Vim cannot properly guess the fileformat from the command output.

I am really in the dark here.

Thanks,

On Sun, Nov 17, 2019 at 5:57 AM Tony Mechelynck <antoine.mechelynck@gmail.com> wrote:
On Sat, Nov 16, 2019 at 7:06 PM Matteo Landi <matteo@matteolandi.net> wrote:
>
> On 11/16, Tony Mechelynck wrote:
> >On Windows, when you read a file in Vim and every (or almost every)
> >line ends with ^M, it usually means that the last line lacks an
> >end-of-line, which made Vim read the whole file as if it were a Unix
> >file. This is how I would fix such a file:
> >
> >    :new ++ff=dos filename.ext
> >    :wq
> >
> >(this has the side-effect of opening then closing a new window for
> >that file) — see ":help ++opt".
> >Reading the file with 'fileformat' explicitly set to dos forces both
> >CR+LF or LF alone (or nothing at end of file) to be recognised as
> >ends-of-lines. Writing the file (which still has 'fileformat' set to
> >dos) writes a proper CR+LF Dos/Windows end-of-line at the end of every
> >line including the last one, so the next time you read it it will be
> >recognised as a Windows file and you won't see those pesky ^M (i.e.
> >carriage-return) characters (they are still there but they are part of
> >the normal Dos/Window end-of-line).
> >
> >Or if you want to transmit the file to be read on a Unix system, you
> >can replace :wq by :wq ++ff=unix — in that case all lines will get a
> >proper LF-only Unix end-of-line, which both Vim (on any platform) and
> >any Unix program will be able to recognise properly. In this case the
> >^M characters are not even there so no one will see them.
> >
>
> Thanks Tony for your reply, but I am afraid I did not properly explain
> myself earlier, apologies.
>
> The actual problem I dealing with is trailing ^M when reading from the
> OS clipboard; I started with dumping trailing \r\n data on a file only
> to make it easier for people to reproduce my problem, but ultimately I
> need to figure out how to read from the clipboard without having ^M
> added at the end of each line.
>
> So, going back to my experiments, can anyone suggest why, the following
> strips trailing ^M:
>
>   :read! powershell.exe Get-Clipboard
>
> While this one instead, doesn't?
>
>   :let @@ = system('powershell.exe Get-Clipboard') | exe 'normal p'
>
> Also, for those who might wonder: reading from the */+ registers
> unfortunately is not an option, as I am trying build a mini-plugin
> around "cb" (https://github.com/iamFIREcracker/cb) which is a script
> that can work via ssh too where you don't have access to the OS
> clipboard; anyway, this is the reason why I am trying to read the
> content of the OS clipboard by using a command, `powershell.exe
> Get-Clipboard`, instead of using the */+ register.
>
> Let me know if this makes things a little more clear.
>
> Thanks.
>
> --
> Matteo Landi
> https://matteolandi.net

My previous answer still applies to this usecase.

As the documentation for :read says, this command accepts a ++opt
modifier, even when used with an !external command.

I expect that

        :read ++ff=dos !powershell.exe Get-Clipboard

(with the ++ff= modifier before the exclamation mark) will give you
the result you want, without the ^M characters. Try it, then tell us
if it works.

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/CAJkCKXvV7bzJfAGK%2BhnMmwqutb-Pee3gs1yv%3DKepK7929AL%3DDg%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/CAKpQHWZWnAZg86ey-1xcBhenW4tTCe8Y-vvR3DXkxS_5LYnr3A%40mail.gmail.com.

Saturday, November 16, 2019

Re: Trailing ^M on Windows

On Sat, Nov 16, 2019 at 7:06 PM Matteo Landi <matteo@matteolandi.net> wrote:
>
> On 11/16, Tony Mechelynck wrote:
> >On Windows, when you read a file in Vim and every (or almost every)
> >line ends with ^M, it usually means that the last line lacks an
> >end-of-line, which made Vim read the whole file as if it were a Unix
> >file. This is how I would fix such a file:
> >
> > :new ++ff=dos filename.ext
> > :wq
> >
> >(this has the side-effect of opening then closing a new window for
> >that file) — see ":help ++opt".
> >Reading the file with 'fileformat' explicitly set to dos forces both
> >CR+LF or LF alone (or nothing at end of file) to be recognised as
> >ends-of-lines. Writing the file (which still has 'fileformat' set to
> >dos) writes a proper CR+LF Dos/Windows end-of-line at the end of every
> >line including the last one, so the next time you read it it will be
> >recognised as a Windows file and you won't see those pesky ^M (i.e.
> >carriage-return) characters (they are still there but they are part of
> >the normal Dos/Window end-of-line).
> >
> >Or if you want to transmit the file to be read on a Unix system, you
> >can replace :wq by :wq ++ff=unix — in that case all lines will get a
> >proper LF-only Unix end-of-line, which both Vim (on any platform) and
> >any Unix program will be able to recognise properly. In this case the
> >^M characters are not even there so no one will see them.
> >
>
> Thanks Tony for your reply, but I am afraid I did not properly explain
> myself earlier, apologies.
>
> The actual problem I dealing with is trailing ^M when reading from the
> OS clipboard; I started with dumping trailing \r\n data on a file only
> to make it easier for people to reproduce my problem, but ultimately I
> need to figure out how to read from the clipboard without having ^M
> added at the end of each line.
>
> So, going back to my experiments, can anyone suggest why, the following
> strips trailing ^M:
>
> :read! powershell.exe Get-Clipboard
>
> While this one instead, doesn't?
>
> :let @@ = system('powershell.exe Get-Clipboard') | exe 'normal p'
>
> Also, for those who might wonder: reading from the */+ registers
> unfortunately is not an option, as I am trying build a mini-plugin
> around "cb" (https://github.com/iamFIREcracker/cb) which is a script
> that can work via ssh too where you don't have access to the OS
> clipboard; anyway, this is the reason why I am trying to read the
> content of the OS clipboard by using a command, `powershell.exe
> Get-Clipboard`, instead of using the */+ register.
>
> Let me know if this makes things a little more clear.
>
> Thanks.
>
> --
> Matteo Landi
> https://matteolandi.net

My previous answer still applies to this usecase.

As the documentation for :read says, this command accepts a ++opt
modifier, even when used with an !external command.

I expect that

:read ++ff=dos !powershell.exe Get-Clipboard

(with the ++ff= modifier before the exclamation mark) will give you
the result you want, without the ^M characters. Try it, then tell us
if it works.

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/CAJkCKXvV7bzJfAGK%2BhnMmwqutb-Pee3gs1yv%3DKepK7929AL%3DDg%40mail.gmail.com.