Skip to content

Single line mode #2009

@beikov

Description

@beikov

Getting a single line-mode to work is not as straightforward as I thought. It would be nice if this could be added as a configuration option. Here is what worked for me:

        editor.onKeyDown(e => {
            if (e.keyCode == monaco.KeyCode.Enter) {
                // We only prevent enter when the suggest model is not active
                if (editor.getContribution('editor.contrib.suggestController').model.state == 0) {
                    e.preventDefault();
                }
            }
        });
        editor.onDidPaste(e => {
           if (e.range.endLineNumber > 1) {
               let newContent = "";
               let lineCount = textModel.getLineCount();
               for (let i = 0; i < lineCount; i++) {
                   newContent += textModel.getLineContent(i + 1);
               }
               textModel.setValue(newContent);
           }
        });

with the following editor options:

            wordWrap: 'off',
            lineNumbers: 'off',
            lineDecorationsWidth: 0,
            overviewRulerLanes: 0,
            overviewRulerBorder: false,
            scrollbar: { horizontal: 'hidden', vertical: 'hidden' },

But I'm still having problems with removing some of the padding on the left and right side of the editor:

grafik

Any idea how to remove that padding?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions