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

Running Indent in a Cygwin Shell from GVim

Expand Messages
  • Waters, Bill
    This may be more of a Cygwin question, but I ll see if you guys can help... I am trying to use indent (http://www.gnu.org/software/indent/manual/indent.html)
    Message 1 of 7 , May 1 7:11 PM
    • 0 Attachment

      This may be more of a Cygwin question, but I’ll see if you guys can help…

       

      I am trying to use indent (http://www.gnu.org/software/indent/manual/indent.html) on my new Win7 machine.  When I ran it from GVim, I got a bunch of ^M characters inserted into the result.

       

      I had the same problem running it in a standalone Cygwin shell.  I tracked that back to the fact that the drive was getting mounted as binary instead of text.  So, I changed the line in my \cygwin\etc\fstab file to this…

       

      none /cygdrive cygdrive text,noacl,posix=0,user 0 0

                                    ^^^^

       

      Then the output from indent looks as expected, with no ^M characters.

       

      Unfortunately, I still get output with ^M characters when I run indent from GVim.

       

      Here are the related settings in my _vimrc file:

       

      set shell=c:/cygwin/bin/bash.exe

      set shellcmdflag=-c

       

      " Run indent on the entire file

      nnoremap <silent> <S-F7> :%!indent<CR>

       

      Any ideas as to how to resolve this?

       

      Thanks,

      Bill

      --
      --
      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
      ... Would I be assuming correctly that the file you re running indent on has Windows-stlye line endings? I m not sure how to work around this if that s the
      Message 2 of 7 , May 2 7:58 AM
      • 0 Attachment
        On Wednesday, May 1, 2013 9:11:52 PM UTC-5, Bill Waters wrote:
        > This may be more of a Cygwin question, but I’ll see if you guys can help…
        >
        >  
        >
        > I am trying to use indent (http://www.gnu.org/software/indent/manual/indent.html) on my new Win7 machine.  When
        > I ran it from GVim, I got a bunch of ^M characters inserted into the result.
        >
        >  
        >
        > I had the same problem running it in a standalone Cygwin shell.  I tracked that back to the fact that the drive was getting mounted as binary instead of text.  So, I changed the line
        > in my \cygwin\etc\fstab file to this…
        >
        >  
        >
        > none /cygdrive cygdrive text,noacl,posix=0,user 0 0
        >
        >                               ^^^^
        >
        >  
        >
        > Then the output from indent looks as expected, with no ^M characters.
        >
        >  
        >
        > Unfortunately, I still get output with ^M characters when I run indent from GVim.
        >
        >  
        >
        > Here are the related settings in my _vimrc file:
        >
        >  
        >
        > set shell=c:/cygwin/bin/bash.exe
        >
        > set shellcmdflag=-c
        >
        >  
        >
        > " Run indent on the entire file
        >
        > nnoremap <silent> <S-F7> :%!indent<CR>
        >
        >  
        >
        > Any ideas as to how to resolve this?
        >
        >  
        >
        > Thanks,
        >
        > Bill

        Would I be assuming correctly that the file you're running 'indent' on has Windows-stlye line endings?

        I'm not sure how to work around this if that's the case, but you could try piping it through tr to remove the trailing line endings before it gets to Vim. Or you could follow up the indent command with a simple :%s#\r$## command to remove them after they get back to Vim.

        --
        --
        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.
      • George Dinwiddie
        Bill, ... As I recall (it s been awhile since I ve used Windows), the key is to have Cygwin use unix line endings (bare LF). - George ... -- ... * George
        Message 3 of 7 , May 2 9:40 AM
        • 0 Attachment
          Bill,

          On 5/1/13 10:11 PM, Waters, Bill wrote:
          > This may be more of a Cygwin question, but I’ll see if you guys can help…
          >
          > I am trying to use indent
          > (http://www.gnu.org/software/indent/manual/indent.html) on my new Win7
          > machine. When I ran it from GVim, I got a bunch of ^M characters
          > inserted into the result.

          As I recall (it's been awhile since I've used Windows), the key is to
          have Cygwin use unix line endings (bare LF).

          - George

          >
          > I had the same problem running it in a standalone Cygwin shell. I
          > tracked that back to the fact that the drive was getting mounted as
          > binary instead of text. So, I changed the line in my \cygwin\etc\fstab
          > file to this…
          >
          > none /cygdrive cygdrive text,noacl,posix=0,user 0 0
          >
          > ^^^^
          >
          > Then the output from indent looks as expected, with no ^M characters.
          >
          > Unfortunately, I still get output with ^M characters when I run indent
          > from GVim.
          >
          > Here are the related settings in my _vimrc file:
          >
          > set shell=c:/cygwin/bin/bash.exe
          >
          > set shellcmdflag=-c
          >
          > " Run indent on the entire file
          >
          > nnoremap <silent> <S-F7> :%!indent<CR>
          >
          > Any ideas as to how to resolve this?
          >
          > Thanks,
          >
          > Bill
          >
          > --
          > --
          > 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.
          >
          >

          --
          ----------------------------------------------------------------------
          * George Dinwiddie * http://blog.gdinwiddie.com
          Software Development http://www.idiacomputing.com
          Consultant and Coach http://www.agilemaryland.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@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Waters, Bill
          ... The fileformat is dos. ... Yeah, you would think that would work. But the formatting is all off with the ^M characters inserted. Even simple things like
          Message 4 of 7 , May 2 10:25 AM
          • 0 Attachment
            >-----Original Message-----
            >From: vim_use@... [mailto:vim_use@...] On Behalf Of Ben Fritz
            >Sent: Thursday, May 02, 2013 7:58 AM
            >To: vim_use@...
            >Subject: Re: Running Indent in a Cygwin Shell from GVim
            >
            >On Wednesday, May 1, 2013 9:11:52 PM UTC-5, Bill Waters wrote:
            >> This may be more of a Cygwin question, but I'll see if you guys can
            >> help...
            >>
            >>
            >>
            >> I am trying to use indent
            >> (http://www.gnu.org/software/indent/manual/indent.html) on my new Win7 machine. When I ran it from GVim, I got a bunch of ^M characters inserted into the result.
            >>
            >>
            >>
            >> I had the same problem running it in a standalone Cygwin shell. I
            >> tracked that back to the fact that the drive was getting mounted as
            >> binary instead of text. So, I changed the line in my
            >> \cygwin\etc\fstab file to this...
            >>
            >>
            >>
            >> none /cygdrive cygdrive text,noacl,posix=0,user 0 0
            >>
            >> ^^^^
            >>
            >>
            >>
            >> Then the output from indent looks as expected, with no ^M characters.
            >>
            >>
            >>
            >> Unfortunately, I still get output with ^M characters when I run indent from GVim.
            >>
            >>
            >>
            >> Here are the related settings in my _vimrc file:
            >>
            >>
            >>
            >> set shell=c:/cygwin/bin/bash.exe
            >>
            >> set shellcmdflag=-c
            >>
            >>
            >>
            >> " Run indent on the entire file
            >>
            >> nnoremap <silent> <S-F7> :%!indent<CR>
            >>
            >>
            >>
            >> Any ideas as to how to resolve this?
            >>
            >>
            >>
            >> Thanks,
            >>
            >> Bill
            >
            >Would I be assuming correctly that the file you're running 'indent'
            >on has Windows-stlye line endings?

            The fileformat is dos.


            >I'm not sure how to work around this if that's the case, but you
            >could try piping it through tr to remove the trailing line endings
            >before it gets to Vim. Or you could follow up the indent command
            >with a simple :%s#\r$## command to remove them after they get back
            >to Vim.

            Yeah, you would think that would work. But the formatting is all off with the ^M characters inserted. Even simple things like the number of leading spaces from one line of code made up of a basic assignment statement to the next line.

            I think that the root of the problem is that in the shell from GVim the file is getting treated as binary instead of text. Not sure how to fix that.

            Typing that gave me a thought... I removed these lines...

            set shell=c:/cygwin/bin/bash.exe
            set shellcmdflag=-c

            So, now the shell is "C:\Windows\system32\cmd.exe". Then when I run indent in GVim I don't get any ^M characters in the result.

            I'd rather use the cygwin shell though.

            Thanks,
            Bill


            --
            --
            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.
          • Gary Johnson
            ... This is just a hunch, and not having indent or an example file I ... Regards, Gary -- -- You received this message from the vim_use maillist. Do not
            Message 5 of 7 , May 2 12:12 PM
            • 0 Attachment
              On 2013-05-02, Waters, Bill wrote:

              > I think that the root of the problem is that in the shell from
              > GVim the file is getting treated as binary instead of text. Not
              > sure how to fix that.
              >
              > Typing that gave me a thought... I removed these lines...
              >
              > set shell=c:/cygwin/bin/bash.exe
              > set shellcmdflag=-c
              >
              > So, now the shell is "C:\Windows\system32\cmd.exe". Then when I
              > run indent in GVim I don't get any ^M characters in the result.
              >
              > I'd rather use the cygwin shell though.

              This is just a hunch, and not having indent or an example file I
              don't have a way to test it, but try this:

              :let $SHELLOPTS = "igncr"

              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@....
              For more options, visit https://groups.google.com/groups/opt_out.
            • Waters, Bill
              ... No difference. Thanks for the suggestion though. Bill -- -- You received this message from the vim_use maillist. Do not top-post! Type your reply below
              Message 6 of 7 , May 2 2:00 PM
              • 0 Attachment
                >-----Original Message-----
                >From: vim_use@... [mailto:vim_use@...] On Behalf Of Gary Johnson
                >Sent: Thursday, May 02, 2013 12:12 PM
                >To: vim_use@...
                >Subject: Re: Running Indent in a Cygwin Shell from GVim
                >
                >On 2013-05-02, Waters, Bill wrote:
                >
                >> I think that the root of the problem is that in the shell from GVim
                >> the file is getting treated as binary instead of text. Not sure how
                >> to fix that.
                >>
                >> Typing that gave me a thought... I removed these lines...
                >>
                >> set shell=c:/cygwin/bin/bash.exe
                >> set shellcmdflag=-c
                >>
                >> So, now the shell is "C:\Windows\system32\cmd.exe". Then when I run
                >> indent in GVim I don't get any ^M characters in the result.
                >>
                >> I'd rather use the cygwin shell though.
                >
                >This is just a hunch, and not having indent or an example file
                >I don't have a way to test it, but try this:
                >
                > :let $SHELLOPTS = "igncr"
                >
                >Regards,
                >Gary

                No difference. Thanks for the suggestion though.

                Bill

                --
                --
                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.
              • Linda W
                ... No... I ll be it s in the files he is indenting. His vim -- especially if he is using the gvim/vim in windows (vs. the one in the cygwin package) will
                Message 7 of 7 , May 17 9:38 PM
                • 0 Attachment
                  Gary Johnson wrote:
                  > On 2013-05-02, Waters, Bill wrote:
                  >
                  >> I think that the root of the problem is that in the shell from
                  >> GVim the file is getting treated as binary instead of text. Not
                  >> sure how to fix that.
                  >>
                  ----
                  No... I'll be it's in the files he is indenting. His vim -- especially if
                  he is using the gvim/vim in windows (vs. the one in the cygwin
                  package) will likely be defaulting to CRLF.

                  Bill -- two things to do. 1) make sure your vimrc
                  has a "set fileformat=unix" somewhere in it so your vim won't default
                  to creating CR's,

                  Second.. what indent are you using? Is it one in cygwin or another?
                  The one in cygwin *shouldn't* be inserting "CR"...

                  (what format do you want them in, anyway?)

                  If all else fails -- write a bash script:
                  ----
                  #!/bin/bash
                  indent "$@"|tr -d "\r"
                  ----
                  and call it instead of indent directly.

                  (you probably already have this solved, just noticed
                  the post, so sorry if this is superfluous).

                  --
                  --
                  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.