Skip to content

Instantly share code, notes, and snippets.

@karlseguin
Created February 13, 2015 03:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karlseguin/2a52a19cfbfab2d6b27c to your computer and use it in GitHub Desktop.
Save karlseguin/2a52a19cfbfab2d6b27c to your computer and use it in GitHub Desktop.
Atom editor multiple wrap guides
# place this in your init.coffee
atom.workspace.observeTextEditors (e) ->
editor = atom.views.getView(e)
clone = editor.querySelector('.wrap-guide').cloneNode()
clone.style.left = (editor.getDefaultCharacterWidth() * 120) + "px"
editor.querySelector('.underlayer').appendChild(clone)
@geek0x23
Copy link

Thanks for this. In the latest versions, however, I did have to make a slight tweak because the line was being drawn before editor.getDefaultCharacterWidth() could determine exactly how many pixels wide something had to be. Here are my modifications:

# multiple wrap guides
atom.workspace.observeTextEditors (e) ->
  editor = atom.views.getView(e)
  clone = editor.querySelector('.wrap-guide').cloneNode()
  process.nextTick ->
    clone.style.left = (editor.getDefaultCharacterWidth() * 120) + "px"
    editor.querySelector('.underlayer').appendChild(clone)

@janka102
Copy link

Many thanks! Using Atom v1.0.0 with Shadow DOM I had to change it a bit

# second wrap guide at 120
atom.workspace.observeTextEditors (e) ->
  editor = atom.views.getView(e)
  clone = editor.querySelector('* /deep/ .wrap-guide').cloneNode()
  process.nextTick ->
    clone.style.left = (editor.getDefaultCharacterWidth() * 120) + "px"
    editor.querySelector('* /deep/ .lines').appendChild(clone)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment