Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is is possible to add padding between the gutter and code? #200

Closed
jkillian opened this issue Sep 22, 2016 · 7 comments
Closed

Is is possible to add padding between the gutter and code? #200

jkillian opened this issue Sep 22, 2016 · 7 comments
Assignees
Milestone

Comments

@jkillian
Copy link

monaco-editor npm version: 0.6.1

I have monaco styled similarly to below:

image

Is there a way to add a few pixels of padding between the edge of the gutter and the start of the code?

I noticed I could adjust the left CSS value of .monaco-scrollable-element, but it seems that most of the widths throughout the editor are computed, and I'm worried about changing inline styles like that.

@jkillian jkillian changed the title Add padding to left of code Is is possible to add padding between the gutter and code? Sep 22, 2016
@alexdima
Copy link
Member

alexdima commented Sep 26, 2016

There is a gap between the line numbers and the content called lineDecorations -- not the best naming :).

So lineDecorationsWidth (an editor option), which I think is 10px by default can be increased. You could add the vertical line as a CSS image background to the margin-view-overlays div or perhaps you have more awesome CSS skills :).

@alexdima alexdima self-assigned this Sep 26, 2016
@alexdima alexdima added this to the Backlog milestone Sep 26, 2016
@jkillian
Copy link
Author

Thanks for the answer @alexandrudima! lineDecorationsWidth is a useful option to know about. Unfortunately for my use case, however, this adds space between the line numbers and the border instead of between the border and the code.

But like you said, perhaps lineDecorationsWidth combined with some CSS trickery can fix things, will give it a shot 😄

@ldewailly
Copy link

In case it helps, this has worked for me:

.monaco-editor .view-line {
    padding-left: 5px;
}

@svoboda-jan
Copy link

I think there should be an option for padding because since everything is calculated, there is no easy way to add it via css and cover all cases.

The following code was needed to cover all (until now) known cases:

/* padding between the gutter and code */
.monaco-editor .view-line {
  padding-left: 5px;
}

/* fix cursor location */
.monaco-editor .cursor {
  margin-left: 5px;
}

/* fix highlighted text selection */
.monaco-editor .selectionHighlight {
  margin-left: 5px;
}

/* fix highlighted brackets */
.monaco-editor .bracket-match {
  margin-left: 5px;
}

/* fix multiline text selection */
.monaco-editor .cslr.selected-text {
  margin-left: 5px;
}

/* fix multiline text selection */
.monaco-editor .bottom-left-radius, .monaco-editor .top-left-radius {
  margin-left: 5px;
}

@nicolaerusan
Copy link

We're also looking for this functionality if anyone's got a solution or there's something being added to the styling options. The solution @svoboda-jan suggested doesn't seem to work in our case (the cursor ends up not being where the actual text is being inserted).

N

@userkang
Copy link

@svoboda-jan
This may be more simple

.monaco-editor .view-line,
.monaco-editor .view-overlays,
.monaco-editor .cursor {
  margin-top: 10px;
}

@PeterShaws
Copy link

This was enough in my case:

.monaco-editor .lines-content {
    padding-left: 5px;
}

@vscodebot vscodebot bot locked and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants