Visible toggle for editor newline style

Just wondering if anybody has seen a plugin that could display the linefeed style for a given file in the editor and ideally offter a toggle to an alternative style. Talking about the age old Windows /r/n vs Unix /n here. Got a few template files that mustn't be in Windows style, otherwise all other file types are generally better using Windows /r/n for developers who insist on using Notepad.

I know I can toggle the default linefeed used for the whole IDE, what I'm after is more file by file or even by filetype.

Alternatively does search & replace fully support control chars? I've not been able to get  Replace.. \r\n -with \n regexes to work (replace button remains disabled)? I'm having to switch to Notepad2 to edit these files which is a clumsy workflow.

- Richard

3 comments
Comment actions Permalink

Hi Richard,

This is not an answer to your question, just some notes/tips.

The IDE will preserve detected linefeed style for all operations.

For example, if default is set to Unix, but some file already has Windows style, then upon opening and editing such file the linefeed will not be changed (works like that in PhpStorm). That's why if you copy text from Linux-style to Windows-style file the linefeed characters will be converted automatically.

If you need to create another file with linefeed different to default (assuming it is set to Unix), you have few options here:
1) Temporarily change default to Windows, create new file and change default back
2) Copy already existing Windows-style file within IDE, delete all contents and .. start working
3) Create such file outside IDE (Notepad++ on Windows, for example) with just 2 empty lines (so IDE can detect linefeed type) and then open it in IDE.

0
Comment actions Permalink

Editing outside of IDEA is pretty much how I've gotten around it. Knew it'd persist once set, just missed the notification & conversions Notepad2, Editplus et al. give you.

Is the lack of support for a replace of a /r/n to /n via regex a bug or feature?

NB: Carridge Return and Newline also seems invisible to whitespaces & soft wrapping views?

0
Comment actions Permalink

Hi Richard,

Is the lack of support for a replace of a /r/n to /n via regex a bug or feature?

I'm pretty confident it is a feature (that's my understanding). I think it is made to simplify things -- new line (\n) means new line regardless of the linefeed type and therefore the same regex replace pattern can be applied to all matching files without the need to be aware of the exact linefeed.

NB: Carridge Return and Newline also seems invisible to whitespaces & soft wrapping views?

Yes. Whitespaces can be mix of tab and space caharacters .. so you may need to differenciate between them.

0

Please sign in to leave a comment.