Loading ...
Sorry, an error occurred while loading the content.

Re: substitution with accented characters

Expand Messages
  • Nicolas Dermine
    ... Hi Cesar, I am not sure if that is exactly what you are asking for but if your need is to do a search and replace , you could type this to change í into
    Message 1 of 5 , Apr 16, 2013
    • 0 Attachment



      On Wed, Apr 17, 2013 at 3:52 AM, Cesar Romani <cesar.romani@...> wrote:
      Suppose I have the following text:

      Diagonalizaci&#243;n de matrices. Formas cuadr&#225;ticas.
      El Espacio Af&#237;n
      El problema de la Programaci&#243;n Lineal
      El Espacio Eucl&#237;deo

      How can I replace the &#...; with their corresponding characters?

      I know that &#243; is ó
                  &#225; is á
                  &#237; is í

      The text can be very large with several of the &#...;

      Hi Cesar,

      I am not sure if that is exactly what you are asking for but if your need is to do a "search and replace", you could type this to change &#237; into í :

      :%s/&#237;/í/g

      Then, similarly:

      :%s/&#225;/á/g
      :%s/&#243;ó/g

      If you need to do this often you may want to record a macro or write a function or look for a plugin that does it.


      I installed Tim Pope's unimpaired plugin to try out Drew Neil's suggestion and it works.
      With that plugin installed, in normal mode, gg]xG would do the trick.

      hope that helps,
      nico



       

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



      --
      --
      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@....
      For more options, visit https://groups.google.com/groups/opt_out.
       
       
    • Ben Fritz
      ... Are you looking for something like this? ... Depending on your encoding you might need to throw in an iconv() call somewhere. -- -- You received this
      Message 2 of 5 , Apr 16, 2013
      • 0 Attachment
        On Tuesday, April 16, 2013 8:52:22 PM UTC-5, andalou wrote:
        > Suppose I have the following text:
        >
        > Diagonalización de matrices. Formas cuadráticas.
        > El Espacio Afín
        > El problema de la Programación Lineal
        > El Espacio Euclídeo
        >
        > How can I replace the &#...; with their corresponding characters?
        >
        > I know that ó is ó
        > á is á
        > í is í
        >
        > The text can be very large with several of the &#...;
        >

        Are you looking for something like this?

        :%s/&#\(\d\+\);/\=nr2char(submatch(1))/g

        :help sub-replace-expression
        :help submatch()
        :help nr2char()

        Depending on your encoding you might need to throw in an iconv() call somewhere.

        --
        --
        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@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Cesar Romani
        ... Thanks Ben, that is what I was looking for. Regards, -- Cesar -- -- You received this message from the vim_use maillist. Do not top-post! Type your reply
        Message 3 of 5 , Apr 16, 2013
        • 0 Attachment
          On 16/04/2013 10:12 p.m., Ben Fritz wrote:
          > On Tuesday, April 16, 2013 8:52:22 PM UTC-5, andalou wrote:
          >> Suppose I have the following text:
          >>
          >> Diagonalización de matrices. Formas cuadráticas.
          >> El Espacio Afín
          >> El problema de la Programación Lineal
          >> El Espacio Euclídeo
          >>
          >> How can I replace the&#...; with their corresponding characters?
          >>
          >> I know tható is ó
          >> á is á
          >> í is í
          >>
          >> The text can be very large with several of the&#...;
          >>
          >
          > Are you looking for something like this?
          >
          > :%s/&#\(\d\+\);/\=nr2char(submatch(1))/g
          >
          > :help sub-replace-expression
          > :help submatch()
          > :help nr2char()
          >
          > Depending on your encoding you might need to throw in an iconv() call
          > somewhere.

          Thanks Ben, that is what I was looking for.

          Regards,

          --
          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@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Tony Mechelynck
          ... You may, if you want, refine this expression (the actual implementation is left as an exercise to the student) for hex entities like e.g. #x4E09; for 三,
          Message 4 of 5 , Apr 17, 2013
          • 0 Attachment
            On 17/04/13 05:12, Ben Fritz wrote:
            > On Tuesday, April 16, 2013 8:52:22 PM UTC-5, andalou wrote:
            >> Suppose I have the following text:
            >>
            >> Diagonalización de matrices. Formas cuadráticas.
            >> El Espacio Afín
            >> El problema de la Programación Lineal
            >> El Espacio Euclídeo
            >>
            >> How can I replace the &#...; with their corresponding characters?
            >>
            >> I know that ó is ó
            >> á is á
            >> í is í
            >>
            >> The text can be very large with several of the &#...;
            >>
            >
            > Are you looking for something like this?
            >
            > :%s/&#\(\d\+\);/\=nr2char(submatch(1))/g
            >
            > :help sub-replace-expression
            > :help submatch()
            > :help nr2char()
            >
            > Depending on your encoding you might need to throw in an iconv() call somewhere.
            >

            You may, if you want, refine this expression (the actual implementation
            is left as an exercise to the student) for hex entities like e.g.
            #x4E09; for 三, the CJK pictogram for the number three (Unicode
            codepoint U+4E09). Of course, for symbolic entity names you will have to
            identify each of them separately, which may require some other approach,
            such as working with a function and a Dictionary like { 'lt':'<',
            'gt':'>', 'nbsp':"\xA0", 'amp':'&', 'aacute':'á', 'eacute':'é',
            'iacute':'í', 'oacute':'ó', 'uacute':'ú', 'uuml':'ü', 'ntilde':'ñ',
            'Aacute':'Á', …etc… }

            Of course, if your example text is part of an HTML page, all browsers
            MUST display the characters correctly even if you leave the &…; entities in.


            Best regards,
            Tony.
            --
            An authority is a person who can tell you more about something than you
            really care to know.

            --
            --
            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@....
            For more options, visit https://groups.google.com/groups/opt_out.
          Your message has been successfully submitted and would be delivered to recipients shortly.