Difference between revisions of "How to avoid DOS line endings in Windows tools"

From Second Life Wiki
Jump to navigation Jump to search
m (→‎Strip'em: made ')' bold, too. You don't give an explicit list of files to strip'em but a regex.)
 
(13 intermediate revisions by 7 users not shown)
Line 1: Line 1:
===Developer Editors===
{{RightToc}}
If you are going to work on the viewer code you need to conform to the [https://wiki.secondlife.com/wiki/Coding_standard Coding Standard].  Your editor must be able to do two things:
* Lines must end with a LF (linefeed) character.
* A tab must generate 4 spaces.


==Windows==
If you are going to work on the viewer code you need to conform to the [[Coding Standard]].
Standards your editor must support:
* Lines must end with a <code>LF</code> (linefeed) character. In addition to the editor specific notes below, you should consider using the Mercurial extension [http://mercurial.selenic.com/wiki/EolExtension EolExtension] to make line-endings less of a problem.
* A tab must be the same width as 4 spaces.
 
==Strip'em==
*Third party tool for Visual Studio 2008/2010 to automatically convert files to specified line ending type when a file is saved.
*Download and instructions: http://grebulon.com/software/stripem.php
*You will need to set to save to '''Unix (LF)''' line ending and add <code>|xml</code> to the regular expression of files this tool watches. 
**This is done in its options floater accessed from inside Visual Studio, '''Tools''' -> '''Stripem'''.
*You need to configure Visual Studio to automatically reload files that change externally.
**Select '''Tools''' -> '''Options...''' -> '''Environment''' -> '''Documents''' from the VS menu.
**Check '''Detect when file is changed outside the environment''' and '''Auto-load changes, if saved'''.
 
==Notepad++==
Configuring Notepad++ ([http://notepadplusplus.org/ download Notepad++])
Configuring Notepad++ ([http://notepadplusplus.org/ download Notepad++])


* Line ending
* Line ending
** You should not need to specify the line ending for an existing file but for a new file you will want to set Edit->EOL Conversion->UNIX Format
** You should not need to specify the line ending for an existing file but for a new file you will want to set '''Edit''' > '''EOL Conversion''' > '''UNIX Format'''
* Tab spacing
* Tab spacing
** Go to Settings->Preferences->Language Menu/Tab Settings.
** Go to '''Settings''' > '''Preferences''' > '''Language Menu/Tab Settings'''.
** Click on [Default]
** Click on '''Default'''
** Change Tab Size to 4
** Change '''Tab Size''' to <code>4</code>
** Check the box Replace by space
** Uncheck the box '''Replace by space'''
** Note: if you are going to be using the program as a general editor you can customize which file types this tab to space conversion applies to.
** Note: if you are going to be using the program as a general editor, you can customize which file types this tab to space conversion applies to.
 


==Macintosh==
==Programmer's Notepad==
Configuring Programmer's Notepad ([http://pnotepad.org/ download Programmer's Notepad])


==Linux==
* Per-file Line-ending Setting
** You should not need to specify the line ending for an existing file but for a new file you will want to set '''File''' > '''Properties...''' > '''Line Endings''' to '''Unix (LF)'''
* To set "Unix" line endings as default for new files
** Go to '''Tools''' > '''Options''' > '''General''' > '''Defaults'''
** Set '''Line Endings''' to '''Unix (LF)'''
* Tab spacing
** Go to '''Tools''' > '''Options''' > '''General''' > '''Defaults'''
** Make sure the '''Use the tab character for indentation''' setting is checked.
** Set '''Tab Width''' to <code>4</code>
* Visible whitespace
** It is convenient to be able to tell at a glance if there are incorrect characters used for indentation or line endings
** Go to '''Tools''' > '''Options''' > '''General''' > '''Defaults'''
** Check the box '''Visible Line Endings'''
** Check the box '''Visible Whitespace Characters'''
* Correcting line endings on existing files
** Go to '''Tools''' > '''Line Endings''' > '''Unix (LF)''' to convert the file

Latest revision as of 07:13, 11 September 2011

If you are going to work on the viewer code you need to conform to the Coding Standard. Standards your editor must support:

  • Lines must end with a LF (linefeed) character. In addition to the editor specific notes below, you should consider using the Mercurial extension EolExtension to make line-endings less of a problem.
  • A tab must be the same width as 4 spaces.

Strip'em

  • Third party tool for Visual Studio 2008/2010 to automatically convert files to specified line ending type when a file is saved.
  • Download and instructions: http://grebulon.com/software/stripem.php
  • You will need to set to save to Unix (LF) line ending and add |xml to the regular expression of files this tool watches.
    • This is done in its options floater accessed from inside Visual Studio, Tools -> Stripem.
  • You need to configure Visual Studio to automatically reload files that change externally.
    • Select Tools -> Options... -> Environment -> Documents from the VS menu.
    • Check Detect when file is changed outside the environment and Auto-load changes, if saved.

Notepad++

Configuring Notepad++ (download Notepad++)

  • Line ending
    • You should not need to specify the line ending for an existing file but for a new file you will want to set Edit > EOL Conversion > UNIX Format
  • Tab spacing
    • Go to Settings > Preferences > Language Menu/Tab Settings.
    • Click on Default
    • Change Tab Size to 4
    • Uncheck the box Replace by space
    • Note: if you are going to be using the program as a general editor, you can customize which file types this tab to space conversion applies to.


Programmer's Notepad

Configuring Programmer's Notepad (download Programmer's Notepad)

  • Per-file Line-ending Setting
    • You should not need to specify the line ending for an existing file but for a new file you will want to set File > Properties... > Line Endings to Unix (LF)
  • To set "Unix" line endings as default for new files
    • Go to Tools > Options > General > Defaults
    • Set Line Endings to Unix (LF)
  • Tab spacing
    • Go to Tools > Options > General > Defaults
    • Make sure the Use the tab character for indentation setting is checked.
    • Set Tab Width to 4
  • Visible whitespace
    • It is convenient to be able to tell at a glance if there are incorrect characters used for indentation or line endings
    • Go to Tools > Options > General > Defaults
    • Check the box Visible Line Endings
    • Check the box Visible Whitespace Characters
  • Correcting line endings on existing files
    • Go to Tools > Line Endings > Unix (LF) to convert the file