-
Hello. I need to detect line endings of the file for correct injecting piece of code inside. Of course, I can detect it manully (read and analyze), but I'm not sure it's the best solution. VS already detected line endings: and I want to obtain this data. Any ideas except using a hardcode WPF magic? :) If it possible, may be we want to see this logic in Vsix Toolkin? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Do you want the line ending that should be used, or the line ending that is actually used? For example, the document could be using LF, but the editor settings or EditorConfig file says that the line endings should be CRLF. There's a few options (code samples of each are at the bottom).
|
Beta Was this translation helpful? Give feedback.
Do you want the line ending that should be used, or the line ending that is actually used? For example, the document could be using LF, but the editor settings or EditorConfig file says that the line endings should be CRLF.
There's a few options (code samples of each are at the bottom).
IEditorOptions
If you want the line ending that should be used, then you could look at the document's options. Get your hands on an
ITextBuffer
, then get theIEditorOptions
from its properties. There's aGetNewLineCharacter()
extension method that provides the line ending that should be used in the document.Important
Having used this, I think this option is only what Visual Studio is configured to use, be…