How to change encoding for an unnamed buffer in VIM?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












Is it possible?



I only know how it can be done for a named buffer (file). It should be reopened with



++enc=<encoding> option. But an unnamed buffer cannot be reopened.



I executed :set encoding=utf-8 but the text displayed in VIM was still unreadable. Only after I saved the buffer to a file, opened it and reopened it with :e ++enc=utf-8 it could be read well. However I noticed that there was an error [ILLEGAL BYTE in line 37]. But I'm happy with that. The main thing is that the contents are readable.



There was no error when I ran :set encoding=utf-8, but nothing seemed to happen too.



VIM 7.4







share|improve this question


























    up vote
    0
    down vote

    favorite












    Is it possible?



    I only know how it can be done for a named buffer (file). It should be reopened with



    ++enc=<encoding> option. But an unnamed buffer cannot be reopened.



    I executed :set encoding=utf-8 but the text displayed in VIM was still unreadable. Only after I saved the buffer to a file, opened it and reopened it with :e ++enc=utf-8 it could be read well. However I noticed that there was an error [ILLEGAL BYTE in line 37]. But I'm happy with that. The main thing is that the contents are readable.



    There was no error when I ran :set encoding=utf-8, but nothing seemed to happen too.



    VIM 7.4







    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Is it possible?



      I only know how it can be done for a named buffer (file). It should be reopened with



      ++enc=<encoding> option. But an unnamed buffer cannot be reopened.



      I executed :set encoding=utf-8 but the text displayed in VIM was still unreadable. Only after I saved the buffer to a file, opened it and reopened it with :e ++enc=utf-8 it could be read well. However I noticed that there was an error [ILLEGAL BYTE in line 37]. But I'm happy with that. The main thing is that the contents are readable.



      There was no error when I ran :set encoding=utf-8, but nothing seemed to happen too.



      VIM 7.4







      share|improve this question














      Is it possible?



      I only know how it can be done for a named buffer (file). It should be reopened with



      ++enc=<encoding> option. But an unnamed buffer cannot be reopened.



      I executed :set encoding=utf-8 but the text displayed in VIM was still unreadable. Only after I saved the buffer to a file, opened it and reopened it with :e ++enc=utf-8 it could be read well. However I noticed that there was an error [ILLEGAL BYTE in line 37]. But I'm happy with that. The main thing is that the contents are readable.



      There was no error when I ran :set encoding=utf-8, but nothing seemed to happen too.



      VIM 7.4









      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 25 '17 at 10:30

























      asked Dec 25 '17 at 9:33









      ka3ak

      536415




      536415




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          There's no need to re-open it - while in command mode, you can set the encoding to whatever you like with:



          :set encoding=whatever


          e.g.



          :set encoding=utf-8


          BTW, type :help encoding-names in vim for a list of supported encodings.






          share|improve this answer




















          • I've tried it, but there may be a difference between '++enc' and 'set encoding'. I'll update my question.
            – ka3ak
            Dec 25 '17 at 10:06










          • maybe put it in your ~/.vimrc so that utf-8 is the default encoding (i'm a little surprised it isn't aready the default...unless your .vimrc has decades worth of cruft like mine)
            – cas
            Dec 25 '17 at 10:21










          • It is the default encoding. Because if I start vim and execute ':set encoding?' it shows me 'encoding=utf-8'. I don't know whether this is an intentional behaviour or not but '++enc' seems to be able to force encoding regardless whether there are some invalid characters there while 'set encoding' can't.
            – ka3ak
            Dec 25 '17 at 10:27











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f412923%2fhow-to-change-encoding-for-an-unnamed-buffer-in-vim%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          There's no need to re-open it - while in command mode, you can set the encoding to whatever you like with:



          :set encoding=whatever


          e.g.



          :set encoding=utf-8


          BTW, type :help encoding-names in vim for a list of supported encodings.






          share|improve this answer




















          • I've tried it, but there may be a difference between '++enc' and 'set encoding'. I'll update my question.
            – ka3ak
            Dec 25 '17 at 10:06










          • maybe put it in your ~/.vimrc so that utf-8 is the default encoding (i'm a little surprised it isn't aready the default...unless your .vimrc has decades worth of cruft like mine)
            – cas
            Dec 25 '17 at 10:21










          • It is the default encoding. Because if I start vim and execute ':set encoding?' it shows me 'encoding=utf-8'. I don't know whether this is an intentional behaviour or not but '++enc' seems to be able to force encoding regardless whether there are some invalid characters there while 'set encoding' can't.
            – ka3ak
            Dec 25 '17 at 10:27















          up vote
          0
          down vote













          There's no need to re-open it - while in command mode, you can set the encoding to whatever you like with:



          :set encoding=whatever


          e.g.



          :set encoding=utf-8


          BTW, type :help encoding-names in vim for a list of supported encodings.






          share|improve this answer




















          • I've tried it, but there may be a difference between '++enc' and 'set encoding'. I'll update my question.
            – ka3ak
            Dec 25 '17 at 10:06










          • maybe put it in your ~/.vimrc so that utf-8 is the default encoding (i'm a little surprised it isn't aready the default...unless your .vimrc has decades worth of cruft like mine)
            – cas
            Dec 25 '17 at 10:21










          • It is the default encoding. Because if I start vim and execute ':set encoding?' it shows me 'encoding=utf-8'. I don't know whether this is an intentional behaviour or not but '++enc' seems to be able to force encoding regardless whether there are some invalid characters there while 'set encoding' can't.
            – ka3ak
            Dec 25 '17 at 10:27













          up vote
          0
          down vote










          up vote
          0
          down vote









          There's no need to re-open it - while in command mode, you can set the encoding to whatever you like with:



          :set encoding=whatever


          e.g.



          :set encoding=utf-8


          BTW, type :help encoding-names in vim for a list of supported encodings.






          share|improve this answer












          There's no need to re-open it - while in command mode, you can set the encoding to whatever you like with:



          :set encoding=whatever


          e.g.



          :set encoding=utf-8


          BTW, type :help encoding-names in vim for a list of supported encodings.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 25 '17 at 9:57









          cas

          37.7k44394




          37.7k44394











          • I've tried it, but there may be a difference between '++enc' and 'set encoding'. I'll update my question.
            – ka3ak
            Dec 25 '17 at 10:06










          • maybe put it in your ~/.vimrc so that utf-8 is the default encoding (i'm a little surprised it isn't aready the default...unless your .vimrc has decades worth of cruft like mine)
            – cas
            Dec 25 '17 at 10:21










          • It is the default encoding. Because if I start vim and execute ':set encoding?' it shows me 'encoding=utf-8'. I don't know whether this is an intentional behaviour or not but '++enc' seems to be able to force encoding regardless whether there are some invalid characters there while 'set encoding' can't.
            – ka3ak
            Dec 25 '17 at 10:27

















          • I've tried it, but there may be a difference between '++enc' and 'set encoding'. I'll update my question.
            – ka3ak
            Dec 25 '17 at 10:06










          • maybe put it in your ~/.vimrc so that utf-8 is the default encoding (i'm a little surprised it isn't aready the default...unless your .vimrc has decades worth of cruft like mine)
            – cas
            Dec 25 '17 at 10:21










          • It is the default encoding. Because if I start vim and execute ':set encoding?' it shows me 'encoding=utf-8'. I don't know whether this is an intentional behaviour or not but '++enc' seems to be able to force encoding regardless whether there are some invalid characters there while 'set encoding' can't.
            – ka3ak
            Dec 25 '17 at 10:27
















          I've tried it, but there may be a difference between '++enc' and 'set encoding'. I'll update my question.
          – ka3ak
          Dec 25 '17 at 10:06




          I've tried it, but there may be a difference between '++enc' and 'set encoding'. I'll update my question.
          – ka3ak
          Dec 25 '17 at 10:06












          maybe put it in your ~/.vimrc so that utf-8 is the default encoding (i'm a little surprised it isn't aready the default...unless your .vimrc has decades worth of cruft like mine)
          – cas
          Dec 25 '17 at 10:21




          maybe put it in your ~/.vimrc so that utf-8 is the default encoding (i'm a little surprised it isn't aready the default...unless your .vimrc has decades worth of cruft like mine)
          – cas
          Dec 25 '17 at 10:21












          It is the default encoding. Because if I start vim and execute ':set encoding?' it shows me 'encoding=utf-8'. I don't know whether this is an intentional behaviour or not but '++enc' seems to be able to force encoding regardless whether there are some invalid characters there while 'set encoding' can't.
          – ka3ak
          Dec 25 '17 at 10:27





          It is the default encoding. Because if I start vim and execute ':set encoding?' it shows me 'encoding=utf-8'. I don't know whether this is an intentional behaviour or not but '++enc' seems to be able to force encoding regardless whether there are some invalid characters there while 'set encoding' can't.
          – ka3ak
          Dec 25 '17 at 10:27













           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f412923%2fhow-to-change-encoding-for-an-unnamed-buffer-in-vim%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay