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
--
--
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/20191116180552.GA13099%40hairstyle.local.
Saturday, November 16, 2019
Re: Trailing ^M on Windows
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.
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/CAJkCKXtDBLPtAtP0MjeBOwBzJXKKf%2BYVj5VT9F_%2BqjhMQ5xiYg%40mail.gmail.com.
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.
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/CAJkCKXtDBLPtAtP0MjeBOwBzJXKKf%2BYVj5VT9F_%2BqjhMQ5xiYg%40mail.gmail.com.
Trailing ^M on Windows
Hello everyone,
I have been battling with trailing ^M on Windows, and I was wondering if
any of you could help me figure it out.
Let's create a file with `\r\n`s (that's how the clipboard appears to be
populated when I copy things from Chrome):
> echo -en "OS cliboards are hart...\r\naren't they?\r\n" > clipboard.txt
> cat clipboard.txt
OS cliboards are hart...
aren't they?
> cat clipboard.txt -A
OS cliboards are hart...^M$
aren't they?^M$
Let's open up vim now (`vim -u NONE`) and do some experiments:
1) read 'clipboard.txt', under the cursor
:read clipboard.txt
The content is loaded, not trailing ^M, at the bottom I see:
"clpboard.txt" [dos format] 2 lines, 40 characters
2) load 'clipboard.txt' using `read!`
:read! cat clipboard.txt
The content is loaded, no trailing ^M
3) load the content into a variable, then paste it under the cursor
:let @@ = system('cat clipboard.txt') | exe 'normal p'
The content is loaded, trailing ^M are added
Let's now push the file into the OS clipboard:
> cat clipboard.txt | clip.exe
Open up vim again, and:
4) paste from the `*` register (works with `Shift+Ins` too):
:exe 'normal "*p'
OS clipboard is read, no trailing ^M
5) load the content of the clipboard using `read!`
:read! powershell.exe Get-Clipboard
The content is loaded, no trailing ^M
6) Read the content of the clipboard into a variable, then paste it under the cursor
:let @@ = system('powershell.exe Get-Clipboard') | exe 'normal p'
OS clipboard is read, trailing ^M are added
These last 2 experiments, really, left me speechless: in both cases we
are reading the output of a command, but somehow `:read` seems to strip
^M, while `system()` not. Can someone help me figure this out?
Thanks
--
Matteo Landi
https://matteolandi.net
--
--
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/20191116112441.GA12005%40hairstyle.local.
I have been battling with trailing ^M on Windows, and I was wondering if
any of you could help me figure it out.
Let's create a file with `\r\n`s (that's how the clipboard appears to be
populated when I copy things from Chrome):
> echo -en "OS cliboards are hart...\r\naren't they?\r\n" > clipboard.txt
> cat clipboard.txt
OS cliboards are hart...
aren't they?
> cat clipboard.txt -A
OS cliboards are hart...^M$
aren't they?^M$
Let's open up vim now (`vim -u NONE`) and do some experiments:
1) read 'clipboard.txt', under the cursor
:read clipboard.txt
The content is loaded, not trailing ^M, at the bottom I see:
"clpboard.txt" [dos format] 2 lines, 40 characters
2) load 'clipboard.txt' using `read!`
:read! cat clipboard.txt
The content is loaded, no trailing ^M
3) load the content into a variable, then paste it under the cursor
:let @@ = system('cat clipboard.txt') | exe 'normal p'
The content is loaded, trailing ^M are added
Let's now push the file into the OS clipboard:
> cat clipboard.txt | clip.exe
Open up vim again, and:
4) paste from the `*` register (works with `Shift+Ins` too):
:exe 'normal "*p'
OS clipboard is read, no trailing ^M
5) load the content of the clipboard using `read!`
:read! powershell.exe Get-Clipboard
The content is loaded, no trailing ^M
6) Read the content of the clipboard into a variable, then paste it under the cursor
:let @@ = system('powershell.exe Get-Clipboard') | exe 'normal p'
OS clipboard is read, trailing ^M are added
These last 2 experiments, really, left me speechless: in both cases we
are reading the output of a command, but somehow `:read` seems to strip
^M, while `system()` not. Can someone help me figure this out?
Thanks
--
Matteo Landi
https://matteolandi.net
--
--
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/20191116112441.GA12005%40hairstyle.local.
Friday, November 15, 2019
Re: Is there a command comparison cheat sheet between nvi and vim?
On 2019-11-15 11:33, 'Ottavio Caruso' via vim_use wrote:
> apart from the excellent "vi_diff" in the docs, is anybody aware of
> a basic cheat sheet of commands comparison between vim and *BSD nvi?
While I'm not aware of any succinct cheat-sheet, I've picked up on a
few notable differences:
For the most part, neovim is a superset of vim which is a superset of
vi.
However, (excluding neovim/vim diffs for this discussion) here are a
few hiccups I've encountered:
^A: in vim, increments the number under the cursor; in nvi, searches
for the word under the cursor (similar to "*" in vim, except it
starts at the cursor, not searching for the whole word, so if your
cursor is on the "h" of "the" it will search for the next instance of
"he" not "the")
To increment/decrement by {count} in nvi, use the #+ and #- commands
^X in vim's insert mode enters a sub-mode for completion while in nvi
it adds the character whose hex-value you specify (akin to `:help
i_CTRL-V_digit` in vim)
In nvi, ^D/0^D/^T do the same thing in insert-mode, but only at the
beginning of the line; in vim they operate anywhere within the line
Undo in nvi is traditional vi undo with only one level of undo(*)
whereas using "u" in vim keeps undoing. (*)Nvi does have multiple
undo levels, but you undo once with "u", then use the "." repeat
operator to continue undoing. Otherwise, a second "u" undoes the undo.
Windows work differently, nvi opens them with ":N fileswitches between
them with ^W where vim uses ^W as a prefix for other window-related
commands; nvi uses ":bg" and ":fg" to push screens/windows to the
background or pull them to the foreground; and uses ":resize
[+|-]size" to resize them.
While nvi can playback macros stored in registers, you have to
populate those registers manually/explicitly since there's no
record-macro functionality. I.e., write your macro into a file and
then yank/delete into a register that you can then play back.
Hope this gives you some starting points to work with.
-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/20191115101709.205adf5d%40bigbox.attlocal.net.
> apart from the excellent "vi_diff" in the docs, is anybody aware of
> a basic cheat sheet of commands comparison between vim and *BSD nvi?
While I'm not aware of any succinct cheat-sheet, I've picked up on a
few notable differences:
For the most part, neovim is a superset of vim which is a superset of
vi.
However, (excluding neovim/vim diffs for this discussion) here are a
few hiccups I've encountered:
^A: in vim, increments the number under the cursor; in nvi, searches
for the word under the cursor (similar to "*" in vim, except it
starts at the cursor, not searching for the whole word, so if your
cursor is on the "h" of "the" it will search for the next instance of
"he" not "the")
To increment/decrement by {count} in nvi, use the #+ and #- commands
^X in vim's insert mode enters a sub-mode for completion while in nvi
it adds the character whose hex-value you specify (akin to `:help
i_CTRL-V_digit` in vim)
In nvi, ^D/0^D/^T do the same thing in insert-mode, but only at the
beginning of the line; in vim they operate anywhere within the line
Undo in nvi is traditional vi undo with only one level of undo(*)
whereas using "u" in vim keeps undoing. (*)Nvi does have multiple
undo levels, but you undo once with "u", then use the "." repeat
operator to continue undoing. Otherwise, a second "u" undoes the undo.
Windows work differently, nvi opens them with ":N fileswitches between
them with ^W where vim uses ^W as a prefix for other window-related
commands; nvi uses ":bg" and ":fg" to push screens/windows to the
background or pull them to the foreground; and uses ":resize
[+|-]size" to resize them.
While nvi can playback macros stored in registers, you have to
populate those registers manually/explicitly since there's no
record-macro functionality. I.e., write your macro into a file and
then yank/delete into a register that you can then play back.
Hope this gives you some starting points to work with.
-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/20191115101709.205adf5d%40bigbox.attlocal.net.
Is there a command comparison cheat sheet between nvi and vim?
Hi all,
apart from the excellent "vi_diff" in the docs, is anybody aware of a
basic cheat sheet of commands comparison between vim and *BSD nvi?
Thanks
--
Ottavio Caruso
--
--
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/CAEJNuHyk33g1LMxwLYLuaGRTkCoK55xN%2BP5GMOZkCVO%3DEq_S%2Bw%40mail.gmail.com.
apart from the excellent "vi_diff" in the docs, is anybody aware of a
basic cheat sheet of commands comparison between vim and *BSD nvi?
Thanks
--
Ottavio Caruso
--
--
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/CAEJNuHyk33g1LMxwLYLuaGRTkCoK55xN%2BP5GMOZkCVO%3DEq_S%2Bw%40mail.gmail.com.
Wednesday, November 13, 2019
Re: Un-POSIX-like behavior of join command
This is great, issue fixed by project BDFL within a few hours of reporting.
As a token of thanks I have sent a donation to ICCF.
> On Nov 12, 2019, at 8:19 PM, Tony Mechelynck <antoine.mechelynck@gmail.com> wrote:
>
> P.P.S. It is _already_ fixed (patch 8.1.2293).
>
> 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/CAJkCKXtAm5qooCd%3DUsv_yqykzD1Oot%3DDBCJqhqXV4kFGdtBUFA%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/C7272512-D9DF-4E3A-8A7E-9B8151F1EE46%40umanwizard.com.
As a token of thanks I have sent a donation to ICCF.
> On Nov 12, 2019, at 8:19 PM, Tony Mechelynck <antoine.mechelynck@gmail.com> wrote:
>
> P.P.S. It is _already_ fixed (patch 8.1.2293).
>
> 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/CAJkCKXtAm5qooCd%3DUsv_yqykzD1Oot%3DDBCJqhqXV4kFGdtBUFA%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/C7272512-D9DF-4E3A-8A7E-9B8151F1EE46%40umanwizard.com.
Tuesday, November 12, 2019
Re: Un-POSIX-like behavior of join command
P.P.S. It is _already_ fixed (patch 8.1.2293).
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/CAJkCKXtAm5qooCd%3DUsv_yqykzD1Oot%3DDBCJqhqXV4kFGdtBUFA%40mail.gmail.com.
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/CAJkCKXtAm5qooCd%3DUsv_yqykzD1Oot%3DDBCJqhqXV4kFGdtBUFA%40mail.gmail.com.
Subscribe to:
Posts (Atom)