vim with Windows developments under linux and git

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

vim with Windows developments under linux and git

Pierre Couderc
I have the usual problems with ^M and some other ones in these cases.

I vant to use vim to develop Windows   apps under linux (building in
some Windows VM), with vim under linux.
I do not want to get rid of ^M, I want to keep all my files in some
specialized directory in Windows format managed by git and vim.

Is there somewhere an howto  for "good practices", particularly to set
vimrc ?

And, cerise sur le gateau, vim should remain correct for normal linux
files...

Thanks
PC

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: vim with Windows developments under linux and git

Gary Johnson-4
On 2015-05-22, Pierre Couderc wrote:

> I have the usual problems with ^M and some other ones in these cases.
>
> I vant to use vim to develop Windows   apps under linux (building in
> some Windows VM), with vim under linux.
> I do not want to get rid of ^M, I want to keep all my files in some
> specialized directory in Windows format managed by git and vim.
>
> Is there somewhere an howto  for "good practices", particularly to
> set vimrc ?
>
> And, cerise sur le gateau, vim should remain correct for normal linux
> files...

This behavior is controlled by the 'fileformat' and 'fileformats'
options.  Vim already sets 'fileformat' according to the line
endings it finds when opening existing files.  To have Vim set
'fileformat' as you want for new files, set 'fileformat' in your
~/.vimrc, for example:

    au BufNewFile /path/to/specialized/directory/* set fileformat=dos

I don't know what you mean by "the usual problems with ^M".  Unless
you are editing files with inconsistent line endings, Vim should
automatically set 'fileformat' correctly so that you don't even have
to think about which line endings you are using.

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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: vim with Windows developments under linux and git

Andrew Long-7
On 22 May 2015, at 17:00, Gary Johnson wrote:

> On 2015-05-22, Pierre Couderc wrote:
>> I have the usual problems with ^M and some other ones in these cases.
>>
>> <snip/>
>
> This behavior is controlled by the 'fileformat' and 'fileformats'
> options.  Vim already sets 'fileformat' according to the line
> endings it finds when opening existing files.  To have Vim set
> 'fileformat' as you want for new files, set 'fileformat' in your
> ~/.vimrc, for example:
>
>    au BufNewFile /path/to/specialized/directory/* set fileformat=dos
>
> I don't know what you mean by "the usual problems with ^M".  Unless
> you are editing files with inconsistent line endings, Vim should
> automatically set 'fileformat' correctly so that you don't even have
> to think about which line endings you are using.
I've seen this in the past when a file, created in Windows with CR-LF line endings, doesn't have a line ending at end-of-file, so yes, that might be a case of 'inconsistent line endings'. In such cases I just do a global replace ':%s/<CTRL-V><CTRL-M>//' to get rid of the spurious characters and then settle on the desired file format

Regards, Andy


--
Andrew Long
Andrew dot Long at Mac dot 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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

signature.asc (242 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: vim with Windows developments under linux and git

Pierre Couderc
In reply to this post by Pierre Couderc
Le vendredi 22 mai 2015 17:08:01 UTC+2, pcouderc12 a écrit :

> I have the usual problems with ^M and some other ones in these cases.
>
> I vant to use vim to develop Windows   apps under linux (building in
> some Windows VM), with vim under linux.
> I do not want to get rid of ^M, I want to keep all my files in some
> specialized directory in Windows format managed by git and vim.
>
> Is there somewhere an howto  for "good practices", particularly to set
> vimrc ?
>
> And, cerise sur le gateau, vim should remain correct for normal linux
> files...
>
> Thanks
> PC
Thank you Gary, thank you Andrew.
My question is : Is there a howto or good practices for developping Windows apps unfer linux, git and vim environment.
So the problem is not to remove rc-lf but more on the contrary to add them if missing...

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: vim with Windows developments under linux and git

Pierre Couderc
In reply to this post by Andrew Long-7
Le vendredi 22 mai 2015 18:19:29 UTC+2, Andrew Long a écrit :

> On 22 May 2015, at 17:00, Gary Johnson wrote:
> > On 2015-05-22, Pierre Couderc wrote:
> >> I have the usual problems with ^M and some other ones in these cases.
> >>
> >> <snip/>
> >
> > This behavior is controlled by the 'fileformat' and 'fileformats'
> > options.  Vim already sets 'fileformat' according to the line
> > endings it finds when opening existing files.  To have Vim set
> > 'fileformat' as you want for new files, set 'fileformat' in your
> > ~/.vimrc, for example:
> >
> >    au BufNewFile /path/to/specialized/directory/* set fileformat=dos
> >
> > I don't know what you mean by "the usual problems with ^M".  Unless
> > you are editing files with inconsistent line endings, Vim should
> > automatically set 'fileformat' correctly so that you don't even have
> > to think about which line endings you are using.
>
> I've seen this in the past when a file, created in Windows with CR-LF line endings, doesn't have a line ending at end-of-file, so yes, that might be a case of 'inconsistent line endings'. In such cases I just do a global replace ':%s/<CTRL-V><CTRL-M>//' to get rid of the spurious characters and then settle on the desired file format
>
> Regards, Andy
>
>
> --
> Andrew Long
> Andrew dot Long at Mac dot com
Thank you A,

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: vim with Windows developments under linux and git

Gary Johnson-4
In reply to this post by Pierre Couderc
On 2015-05-23, pcouderc12 wrote:

> Le vendredi 22 mai 2015 17:08:01 UTC+2, pcouderc12 a écrit :
> > I have the usual problems with ^M and some other ones in these cases.
> >
> > I vant to use vim to develop Windows   apps under linux (building in
> > some Windows VM), with vim under linux.
> > I do not want to get rid of ^M, I want to keep all my files in some
> > specialized directory in Windows format managed by git and vim.
> >
> > Is there somewhere an howto  for "good practices", particularly to set
> > vimrc ?
> >
> > And, cerise sur le gateau, vim should remain correct for normal linux
> > files...
> >
> > Thanks
> > PC
>
> Thank you Gary, thank you Andrew.
> My question is : Is there a howto or good practices for
> developping Windows apps unfer linux, git and vim environment.
> So the problem is not to remove rc-lf but more on the contrary
> to add them if missing...

I'll leave the issues of developing Windows applications under Linux
and configuring git appropriately for someone who understands those
issues better than I do.

As for line endings, there are three cases:
    1.  The file contains only CR-LF (DOS) line endings.
    2.  The file contains only LF (Unix) line endings.
    3.  The file contains both LF and CR-LF line endings.

In case #1, Vim will set the 'fileformat' to "dos" and not show any
^M characters.  There is nothing you need to do.

In case #2, Vim will set the 'fileformat' to "unix" and of course
not show any ^M characters as there are none.  The simplest way to
change the line endings to CR-LF is to execute the following.

    :set ff=dos
    :w

In case #3, Vim will set the 'fileformat' to "unix" and display a
^M character at the end of every line that has a CR-LF line ending.
The simplest way to change all the line endings to CR-LF is the
following.

    :%s/\r$//
    :set ff=dos
    :w

HTH,
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: vim with Windows developments under linux and git

John Little-4
In reply to this post by Pierre Couderc
On Saturday, May 23, 2015 at 3:08:01 AM UTC+12, pcouderc12 wrote:

> Is there somewhere an howto  for "good practices", particularly to set
> vimrc ?

People's preferences vary widely, particularly with these DOS/unix compatiblity issues, so I doubt you'll find a widely accepted "good practices" guide.

I would suggest, though, including the 'fileformat' setting in your status line,
and setting 'laststatus' to 2 so that a status line always appears.  This way you see what vim thinks the file is.

Usually for my stuff I want unix endings, even when on Windows, so I suppress the fileformat if it's unix, but use a different colour if it's dos, so my statusline setting  includes
     %1*%{&ff=~'u'?'':&ff}%*

Regards, John Little

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: vim with Windows developments under linux and git

Pierre Couderc
In reply to this post by Gary Johnson-4
Le 23/05/2015 18:57, Gary Johnson a écrit :

> On 2015-05-23, pcouderc12 wrote:
>> Le vendredi 22 mai 2015 17:08:01 UTC+2, pcouderc12 a écrit :
>>> I have the usual problems with ^M and some other ones in these cases.
>>>
>>> I vant to use vim to develop Windows   apps under linux (building in
>>> some Windows VM), with vim under linux.
>>> I do not want to get rid of ^M, I want to keep all my files in some
>>> specialized directory in Windows format managed by git and vim.
>>>
>>> Is there somewhere an howto  for "good practices", particularly to set
>>> vimrc ?
>>>
>>> And, cerise sur le gateau, vim should remain correct for normal linux
>>> files...
>>>
>>> Thanks
>>> PC
>> Thank you Gary, thank you Andrew.
>> My question is : Is there a howto or good practices for
>> developping Windows apps unfer linux, git and vim environment.
>> So the problem is not to remove rc-lf but more on the contrary
>> to add them if missing...
> I'll leave the issues of developing Windows applications under Linux
> and configuring git appropriately for someone who understands those
> issues better than I do.
>
> As for line endings, there are three cases:
>      1.  The file contains only CR-LF (DOS) line endings.
>      2.  The file contains only LF (Unix) line endings.
>      3.  The file contains both LF and CR-LF line endings.
>
> In case #1, Vim will set the 'fileformat' to "dos" and not show any
> ^M characters.  There is nothing you need to do.
>
> In case #2, Vim will set the 'fileformat' to "unix" and of course
> not show any ^M characters as there are none.  The simplest way to
> change the line endings to CR-LF is to execute the following.
>
>      :set ff=dos
>      :w
>
> In case #3, Vim will set the 'fileformat' to "unix" and display a
> ^M character at the end of every line that has a CR-LF line ending.
> The simplest way to change all the line endings to CR-LF is the
> following.
>
>      :%s/\r$//
>      :set ff=dos
>      :w
>
> HTH,
> Gary
>
Thank you, this is a fine summary of these matters, and  a good howto

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: vim with Windows developments under linux and git

Pierre Couderc
In reply to this post by John Little-4
Le 24/05/2015 03:25, John Little a écrit :
> On Saturday, May 23, 2015 at 3:08:01 AM UTC+12, pcouderc12 wrote:
>
>> Is there somewhere an howto  for "good practices", particularly to set
>> vimrc ?
> People's preferences vary widely, particularly with these DOS/unix compatiblity issues, so I doubt you'll find a widely accepted "good practices" guide.
Yes, but I did hope...
>
> I would suggest, though, including the 'fileformat' setting in your status line,
> and setting 'laststatus' to 2 so that a status line always appears.  This way you see what vim thinks the file is.
>
> Usually for my stuff I want unix endings, even when on Windows, so I suppress the fileformat if it's unix, but use a different colour if it's dos, so my statusline setting  includes
>       %1*%{&ff=~'u'?'':&ff}%*
>
> Regards, John Little
Thank you, I shall do that : at least to well understand in what case we
are.
>

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: vim with Windows developments under linux and git

Benjamin Fritz
In reply to this post by Gary Johnson-4
To get rid of the trailing ^M characters and correct the format I prefer:

:e ++ff=dos
:w

See:
http://vim.wikia.com/wiki/File_format
http://vim.wikia.com/wiki/Automatically_reload_files_with_mixed_line-endings_in_DOS_fileformat

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.