Character bracketing

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Character bracketing

Fameli, Nicola

Hi there,


something's up with my vi(m) editor in my mac pro Terminal app (Mac OS Catalina) and it's driving me insane.


It happens when I make a new file, say a python function in which I might write from the command line:

$vim function.py

def function(variable):

   pass

then I type :wq to save it and exit.

Next time I open it I'll see each letter bracketed by ^@, as in:

^@d^@^@e^@^@f^@ ^@f^@^@u^@^@n... you get the idea.


Interestingly, if I add text to an existing file, save it and close it, the issue isn't there next time I open it. It seems to happen only when I make a fresh file and with vim 8.1.2292 as well as 8.2.1719.


Any help to solve this would be much appreciated.


Keep up the great work,

Nicola


--
--
You received this message from the "vim_mac" 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_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_mac/f708145cf95e4f14ad3fdb1d213ad9ff%40ubc.ca.
Reply | Threaded
Open this post in threaded view
|

Re: Character bracketing

Tony Mechelynck
On Saturday, October 17, 2020 at 11:49:25 AM UTC+2, Fameli, Nicola wrote:

Hi there,


something's up with my vi(m) editor in my mac pro Terminal app (Mac OS Catalina) and it's driving me insane.


It happens when I make a new file, say a python function in which I might write from the command line:

$vim function.py

def function(variable):

   pass

then I type :wq to save it and exit.

Next time I open it I'll see each letter bracketed by ^@, as in:

^@d^@^@e^@^@f^@ ^@f^@^@u^@^@n... you get the idea.


Interestingly, if I add text to an existing file, save it and close it, the issue isn't there next time I open it. It seems to happen only when I make a fresh file and with vim 8.1.2292 as well as 8.2.1719.


Any help to solve this would be much appreciated.


Keep up the great work,

Nicola


Open a non-existing filename in Vim and then type:

       :verbose set term? termencoding? encoding? fileencoding? fileencodings?
       :language ctype

with of course <Enter> at the end of each line. What are the answers?

Best regards,
Tony.

--
--
You received this message from the "vim_mac" 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_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_mac/7d6b918d-3266-406e-9571-264c8a97a1f9o%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Character bracketing

Fameli, Nicola





From: [hidden email] <[hidden email]> on behalf of Tony Mechelynck <[hidden email]>
Sent: 18 October 2020 8:46
To: vim_mac
Subject: Re: Character bracketing
 
[CAUTION: Non-UBC Email]
On Saturday, October 17, 2020 at 11:49:25 AM UTC+2, Fameli, Nicola wrote:

Hi there,


something's up with my vi(m) editor in my mac pro Terminal app (Mac OS Catalina) and it's driving me insane.


It happens when I make a new file, say a python function in which I might write from the command line:

$vim function.py

def function(variable):

   pass

then I type :wq to save it and exit.

Next time I open it I'll see each letter bracketed by ^@, as in:

^@d^@^@e^@^@f^@ ^@f^@^@u^@^@n... you get the idea.


Interestingly, if I add text to an existing file, save it and close it, the issue isn't there next time I open it. It seems to happen only when I make a fresh file and with vim 8.1.2292 as well as 8.2.1719.


Any help to solve this would be much appreciated.


Keep up the great work,

Nicola


Open a non-existing filename in Vim and then type:

       :verbose set term? termencoding? encoding? fileencoding? fileencodings?
       :language ctype

with of course <Enter> at the end of each line. What are the answers?

Best regards,
Tony.
--
--

Hi Tony,

thanks for the instructions. Here are the responses to those commands:

:verbose set term? termencoding? encoding? fileencoding? fileencodings?
term=xterm-256color
  termencoding=
  encoding=utf-16
        Last set from ~/.vimrc line 3
  fileencoding=
  fileencodings=ucs-bom,utf-8,default,latin1
        Last set from ~/.vimrc line 3

:language ctype
Current ctype language: "en_CA.UTF-8"

Best regards,
Nicola

You received this message from the "vim_mac" 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_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_mac/7d6b918d-3266-406e-9571-264c8a97a1f9o%40googlegroups.com.

--
--
You received this message from the "vim_mac" 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_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_mac/3e0e896bc6fe402592ff4d0b22d3cb9b%40ubc.ca.
Reply | Threaded
Open this post in threaded view
|

Re: Character bracketing

Bram Moolenaar

> something's up with my vi(m) editor in my mac pro Terminal app (Mac OS Catalina) and it's driving me insane.
>
> It happens when I make a new file, say a python function in which I might write from the command line:
>
> $vim function.py
>
> def function(variable):
>
>    pass
>
> then I type :wq to save it and exit.
>
> Next time I open it I'll see each letter bracketed by ^@, as in:
>
> ^@d^@^@e^@^@f^@ ^@f^@^@u^@^@n... you get the idea.
>
>
> Interestingly, if I add text to an existing file, save it and close
> it, the issue isn't there next time I open it. It seems to happen only
> when I make a fresh file and with vim 8.1.2292 as well as 8.2.1719.
>
>
> Any help to solve this would be much appreciated.

Check the 'fileencoding' and 'encoding'.  I suspect one of them is
utf-16.  Perhaps a plugin sets 'fileencoding' for this filetype, check
with:
        verbose set fileencoding?


--
From "know your smileys":
 :-F Bucktoothed vampire with one tooth missing

 /// Bram Moolenaar -- [hidden email] -- 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_mac" 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_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_mac/202010191113.09JBD2hl1116449%40masaka.moolenaar.net.
Reply | Threaded
Open this post in threaded view
|

Re: Character bracketing

Tony Mechelynck
In reply to this post by Fameli, Nicola
On Sunday, October 18, 2020 at 9:51:26 PM UTC+2, Fameli, Nicola wrote:





From: [hidden email] <[hidden email]> on behalf of Tony Mechelynck <[hidden email]>
Sent: 18 October 2020 8:46
To: vim_mac
Subject: Re: Character bracketing
 
[CAUTION: Non-UBC Email]
On Saturday, October 17, 2020 at 11:49:25 AM UTC+2, Fameli, Nicola wrote:

Hi there,


something's up with my vi(m) editor in my mac pro Terminal app (Mac OS Catalina) and it's driving me insane.


It happens when I make a new file, say a python function in which I might write from the command line:

$vim function.py

def function(variable):

   pass

then I type :wq to save it and exit.

Next time I open it I'll see each letter bracketed by ^@, as in:

^@d^@^@e^@^@f^@ ^@f^@^@u^@^@n... you get the idea.


Interestingly, if I add text to an existing file, save it and close it, the issue isn't there next time I open it. It seems to happen only when I make a fresh file and with vim 8.1.2292 as well as 8.2.1719.


Any help to solve this would be much appreciated.


Keep up the great work,

Nicola


Open a non-existing filename in Vim and then type:

       :verbose set term? termencoding? encoding? fileencoding? fileencodings?
       :language ctype

with of course <Enter> at the end of each line. What are the answers?

Best regards,
Tony.
--
--

Hi Tony,

thanks for the instructions. Here are the responses to those commands:

:verbose set term? termencoding? encoding? fileencoding? fileencodings?
term=xterm-256color
  termencoding=
  encoding=utf-16
        Last set from ~/.vimrc line 3
  fileencoding=
  fileencodings=ucs-bom,utf-8,default,latin1
        Last set from ~/.vimrc line 3

:language ctype
Current ctype language: "en_CA.UTF-8"

Best regards,
Nicola

The problem is at line 3 of your vimrc, which sets 'encoding' to utf-16 where utf-8 would be better. You might also want to set a default for 'fileencoding' by means of
        :setglobal fileencoding=utf8

Using :setglobal means that it will be used _only_ for new files, because for existing files the 'fileencodings' (plural) heuristics will try to determine the current encoding. If you want to create a UTF-16 file anyway, then ":setlocal fenc=utf-16 bomb" (without the quotes) will create it with a BOM so that when reopening it it will be detected as UTF-16 and not as Latin1 with about every other character being a NULL (Ctrl-@)

See at https://vim.fandom.com/wiki/Working_with_Unicode the recommended vimrc code and where to find details in the Vim help about the several options set by that code.

Best regards,
Tony.

--
--
You received this message from the "vim_mac" 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_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_mac/723643dd-7bea-4bad-9764-ccb4e6f9b51co%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Character bracketing

Fameli, Nicola


From: [hidden email] <[hidden email]> on behalf of Tony Mechelynck <[hidden email]>
Sent: 19 October 2020 4:27
To: vim_mac
Subject: Re: Character bracketing
 
[CAUTION: Non-UBC Email]
On Sunday, October 18, 2020 at 9:51:26 PM UTC+2, Fameli, Nicola wrote:





From: [hidden email] <[hidden email]> on behalf of Tony Mechelynck <[hidden email]>
Sent: 18 October 2020 8:46
To: vim_mac
Subject: Re: Character bracketing
 
[CAUTION: Non-UBC Email]
On Saturday, October 17, 2020 at 11:49:25 AM UTC+2, Fameli, Nicola wrote:

Hi there,


something's up with my vi(m) editor in my mac pro Terminal app (Mac OS Catalina) and it's driving me insane.


It happens when I make a new file, say a python function in which I might write from the command line:

$vim function.py

def function(variable):

   pass

then I type :wq to save it and exit.

Next time I open it I'll see each letter bracketed by ^@, as in:

^@d^@^@e^@^@f^@ ^@f^@^@u^@^@n... you get the idea.


Interestingly, if I add text to an existing file, save it and close it, the issue isn't there next time I open it. It seems to happen only when I make a fresh file and with vim 8.1.2292 as well as 8.2.1719.


Any help to solve this would be much appreciated.


Keep up the great work,

Nicola


Open a non-existing filename in Vim and then type:

       :verbose set term? termencoding? encoding? fileencoding? fileencodings?
       :language ctype

with of course <Enter> at the end of each line. What are the answers?

Best regards,
Tony.
--
--

Hi Tony,

thanks for the instructions. Here are the responses to those commands:

:verbose set term? termencoding? encoding? fileencoding? fileencodings?
term=xterm-256color
  termencoding=
  encoding=utf-16
        Last set from ~/.vimrc line 3
  fileencoding=
  fileencodings=ucs-bom,utf-8,default,latin1
        Last set from ~/.vimrc line 3

:language ctype
Current ctype language: "en_CA.UTF-8"

Best regards,
Nicola

The problem is at line 3 of your vimrc, which sets 'encoding' to utf-16 where utf-8 would be better. You might also want to set a default for 'fileencoding' by means of
        :setglobal fileencoding=utf8

Using :setglobal means that it will be used _only_ for new files, because for existing files the 'fileencodings' (plural) heuristics will try to determine the current encoding. If you want to create a UTF-16 file anyway, then ":setlocal fenc=utf-16 bomb" (without the quotes) will create it with a BOM so that when reopening it it will be detected as UTF-16 and not as Latin1 with about every other character being a NULL (Ctrl-@)

See at https://vim.fandom.com/wiki/Working_with_Unicode the recommended vimrc code and where to find details in the Vim help about the several options set by that code.

Best regards,
Tony.
--
--

Dear Tony,

I reverted back to the original .vimrc file, which didn't have that utf-16 encoding line and apparently things work normally now. I am not sure how that change came about, even though I am most likely the one who made it, and why this issue had not arisen before the last few days, since vi is my text editor of choice for programming, scritpting, latex, etc.

In any case, it seems to be solved now... fingers crossed.

Kind regards,
Nicola


You received this message from the "vim_mac" 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_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_mac/723643dd-7bea-4bad-9764-ccb4e6f9b51co%40googlegroups.com.

--
--
You received this message from the "vim_mac" 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_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_mac/af9a269c25624f2492143b5b514e2eeb%40ubc.ca.