LaTeXTools: New Keybindings!

Heads-up: the keybindings for the LaTeXTools plugin have changed. Make sure to read the README file for details: go to and scroll down (or click the “Read More” link near the project description).

Why change things? When I started working on this plugin, my objective was to emulate the functionality of the LaTeX bundle for TextMate. In particular, I tried to use the same keyboard shortcuts. However, this slowly led to an accumulation of problems. One was that, as I added features to the plugin, it became harder and harder to assign them to shortcuts that were not already used by Sublime Text 2 itself. The other problem is actually due to ST2’s greatest feature: it’s a cross-platform editor, and the plugin must also work equally well on Windows and Mac, with full Linux support also coming soon (yes!). However, different OS’s have slightly different conventions and expectations about what certain keys do. Bottom line: things were getting unmanageable.

Enter the new keyboard shortcut scheme. It’s actually very simple:

  1. The build command is still bound to ctrl-b on Windows and Linux, and cmd-b on OS X. For the time being, the Goto Anything functionality is also still bound to ctrl-r / cmd-r.
  2. All other plugin commands use ctrl-l or cmd-l followed by another key or key combination. That’s “ell” for LaTeX.

Example: to do a forward search (i.e. jump to the point int he PDF file corresponding to the current cursor position) on Windows, enter Ctrl-l followed by j. This is abbreviated as ctrl-l,j (the same convention used by Sublime Text). On OS X, this is cmd-l,j. In fact, from now on, I shall write C-l to mean either ctrl-l or cmd-l, depending on the platform.

I have tried to use mostly C-l plus a single keystroke, with reasonable mnemonics. For instance: “j” for jump to PDF, “c” for LaTeX command based on the current word, etc. Wrapping commands use the C- key twice: so, wrap in bold is C-l,C-b, etc. Reference and cite completion uses C-l,Ctrl-space (yes, even on OS X, that’s Command-ell, Control-space), but you can also use C-l,x (for cross-reference). Finally, to toggle the focus from/to the PDF upon compilation, there is a three-key sequence: C-l,t,f. I’ll try to reserve these for toggles and other less frequently used stuff.

Now, on ST2, the C-l shortcut is bound to “Extend selection to line”. That’s reassigned to C-l,C-l. The nice thing is that no other standard ST2 keyboard shortcut is affected.

As an additional benefit, these bindings are consistent with the “nice” (or “compact”) on-screen keyboard in Windows 8, which only has a Ctrl key (no Windows key, no Alt key).


52 responses to “LaTeXTools: New Keybindings!

  1. Thanks for continuing to make your wonderful plugin even better!!

    So I was having trouble with completion in \cite{}, and on digging into the error messages I figured that the problem was some entries in my bib file with leading spaces before @article etc. Also some entries in my bib file were commented out; the plugin was still picking up the title and author list from those entries but missed picking up the keyword because the line didn’t start with @. Also, if the author list was split over multiple lines, sometimes the plugin wouldn’t pick it all up.

    Anyway, I realized that an easy fix to this was to use the .bbl files that bibtex generates, instead of using the .bib files directly. The advantage is that .bbl files are much better structured than a typical .bib file (which is usually generated by copy-pasting bibtex entries from the web). But bibtex is already smart enough to get around formatting issues and produce a nice structured output in the form of a .bbl file. Also, the .bbl file aggregates entries from all the included .bib files, and *only* those that are actually referenced in the tex file, so you can avoid the recursive search for .bib files and superfluous bibliography entries to boot.

    The only catch is that if you haven’t generated the .bbl file yet, or if you have a .bbl file but it doesn’t yet have your keyword, then the completion won’t work of course. A simple fix is to continue processing bib files *after* the bbl file, discarding all keywords previously seen.

    With a quick and dirty change to the I was able to use a .bbl file in the completion, making for a prettier output. I wanted to bring this idea for your consideration, and I can mail you my code if you like (although I haven’t implemented the fix above).

  2. Hallo,
    how can I view pdf (before ”ctrl+alt+v” ) on OSX? now is it ”super+L” or? I hit ”cmd+L”. nothing happens. and what is the ”super” key?

  3. Hello! When I try to compile tex file (with latextools in sublime text 2 on windows 7 russian and miktex) with a cyrillic chars in path, nothing happends. In console i see “[u’texify’, u’-b’, u’-p’, u’–tex-option=”–synctex=1″‘, u’E:\\Documents\\sublime\\\u0436\u0431\u043a.sublime\\jbk.tex’]”, where “\\u0436\u0431\u043a” is corrupted cyrillic chars. I dont know where i should paste this issue and paste it here, excuse me.

    • Thanks for the report. Unfortunately, unicode chars in the file path will cause trouble. I’m not sure there’s much I can do; I have another similar bug report on OS X. Question: can you run texify from the command line on that same path?

  4. First off, thanks so much for taking the time to build this package for Sublime text. It’s essential for my workflow. My question is whether you have a cheatsheet that lists out the keyboard shortcuts for your package in one place.

  5. I just tried using the new keybindings for the first time (on my Mac). And I realized that for me, Cmd+# is a shortcut to jump to the file in the #th tab of the current window. Do you have to disable/override that manually?

    I can send a screenshot of the appropriate menu item if that helps.

  6. Hello Marciano,

    Thank you for all the wonderful work on this plugin. I use it on OS X, and I’ve run into an annoyance that you may or may not be able to help with.

    The way I work with a .tex file is that I’ll have Skim open on one side of the screen and ST2 open on the other. I’ll usually have the PDF zoomed in so that the text width fills the window.

    If I am working on an equation and hit the build command, the plugin will do a forward search and move the PDF in the Skim window so that the beginning of the equation is on the left side of the window. Then in order to get the PDF centered again the way I want it, I have to move it back.

    Is there a way to disable the forward search when doing a build? I still want to have the capability to do a forward search, but I only want to do it when I actually want it. I believe this is how TeXShop works.


    • You’re the second person to ask, so I guess I’ll have to implement it 🙂

      BTW, I personally also *hate* that Skim behavior. Basically, when you do a forward search, it does not preserve the horizontal position (unless you have zoomed out so that you see the entire page, margin to margin). I think Yap on Windows used to not do that at all… unfortunately, it’s not something I can fix, except by not doing a forward search of course.

      • It’s good to hear that I’m not the only one with this problem. A setting in `LaTeXTools Preferences.sublime-settings` to turn off forward search after building would be nice. 🙂

    • Sorry for the double reply — it’s now in. See the README. Hope you like it 🙂

  7. @ntmoe the latest commits added this. See the README. Hope you like it 🙂

  8. I tried it out this afternoon. I really like the new option! The plug-in now works as I had wanted. Thanks so much!

  9. Hi, I am a Mac user. Loved this. but my skim doesn’t launch when compiling (cmd+b). may I know how I can make it work?

  10. Gabriel Droulers

    Hi, I’m considering changing from texshop to Sublime text 2 with your tool for Latex. However, I can’t seem to find how to compile the bibtex data in my latex document. Does latexmk take care of this? I use a single .bib file placed in my texmf tree… is there a way to make sublime compiler see it?

    Also, I can’t seem to do backward search with cmd+shift+click from skim, is this normal?

  11. Hi, first of all, thanks a lot for your efforts on LaTexTools!! I’m addicted to ST2 immediately for my TeX editing. However, after several rounds of googling, I still couldn’t figure out how to set up the building system correctly to enable bibtex. I used to do pdflatex + bibtex + pdflatex + pdflatex to get the bib file working. How should I modify the LaTeX.sublime-build file?

    • You don’t need to. Latexmk should take care of it automatically. You do need to have a bibliography command in your source though.

      • Thanks! I’m not quite sure about what you mean by “have a bibliography command in the source”. But this is what I do. I add an argument “-bibtex” to the LaTeX.sublime-build file, i.e. change the corresponding session to

        “cmd”: [“latexmk”, “-bibtex”,
        “-e”, “\\$pdflatex = ‘pdflatex %O -synctex=1 %S'”,
        “-f”, “-pdf”],

  12. Hello.
    I’m new to Sublime Text 2 and to your LaTeXTools plugin.
    Since I’m a mathematics professor, most of my editing involves
    mathematical expressions. One thing that I frustrates me is
    entering nested fractions like “\frac{3 + \frac{2}{x}}{\frac{1}{x} – \frac{x}{3}}”
    I can’t seem to get this to work using Sublime Text and your plugin. The outermost
    \frac expands fine but I can’t get the nested \frac’s to expand. What I end up getting
    is “\frac{3 + fra}{fra}”. Am I doing something wrong?

  13. Shut the fuck up your plugin is awesome! Dear god, I had no idea forward and inverse search were even possible. And I also get \ref and \cite lookups. I love your plugin man. Thanks!!

  14. Hi !
    I’m very impressed by your work and I love to use it.
    Do you know if there is any option to toggle in order to not bring up the console if the build succeed without error? I’m pretty new to ST2 and your extesion.

    Anyway, thanks for your work!

  15. First up thanks for sharing all this great work, an education. I am trying to figure out what I need to do to get this step working (!!!apologies if this is the wrong place to post this):

    -compile using hotkey cmd+b.
    -I want the Skim editor to open here and jump to the pdf spot of the corresponding cursor position in ST2.
    -when I hit cmd+b, Marked opens, yes I had previously installed Marked prior to installing Skim. I am trying to figure out how to disable Marked such that I can use cmd+b to open skim.

    When I check the installed packages in ST2, I have Markdown and Markdown (Pandoc). I have tried to Google my way to a solution but as yet I have not been successful. If you have any guidance, please let me know.
    Further, when I check system preferences, keyboard shortcuts, see, it appears I will have to configure the shortcuts. Any suggestions on how to import the configurations discussed above. Many Thanks.

  16. Thanks for replying. Skim is not in the Build System under Tools (Marked is). Does installling your plugin put Skim there, or is there a step I have missed? Thanks

  17. Hi and thanks you again for your great work ! I have question : is it possible to specify (for one time only) to compile with latex instead of pdftex … I have some pstrick figure in my document ….

  18. I love your plugin so far. However, I am having an issue with forward search on Mac OS 10.7 changing the focus to Skim. I thought focus should stay in the editor? Not sure if it matters, but I have the “keep_focus” preference set to true.
    Thanks for any help you can provide.

    • Hmmm… That should do it. There is a key combo that displays the current toggle settings in the status line (sorry I don’t remember what it is – please check the README). See if it says Focus-Editor. It may be that your settings are not being read in.

  19. Hmm. When I first open a .tex file, and check the toggle settings, it reports that “Keep focus: pref True toggle undefined”. The focus does stay in ST2 when I do a build though, just not with a forward search.

    Could this be caused by Skim? Whenever I use the forward search, Skim is triggered and a popup with a status bar says Reloading Document… while it jumps to the desired spot in the pdf.

    • Aaah… I see. I think that with a forward search the plugin always gives the focus to Skim. My thinking was, if the user only wants to redisplay, C-B is enough, so if s/he uses a forward search presumably s/he wants to look at the PDF. I’m not sure I want to change this behavior, because some users may find the change objectionable.

      As for Skim, you need to disable the “Check for file changes” toggle in the Sync tab (Preferences).

  20. That’s understandable. The readme does say that focus should stay in ST2 when doing a forward search with c-l,j. So that’s why I was expecting that behavior.

    I do have that setting in Skim disabled. Thanks again for the help.

  21. I’m sorry to insist but I would really appreciate to know if there is a way from Latextools/ST2 for compiling with latex instead of pdflatex ? where can I specifify the compiler command ?
    thanks in advance for your help and congrats again for your impressive work with latextools

    • You can personalize the LaTeX.sublime-build file. First, copy it to ..Packages/User, otherwise it will get clobbered the next time you update LaTeXTools. Next, look at the relevant section (osx, windows or linux) and change the cmd setting to fit your needs.

  22. Hi! Thank you very much for this lovely plug-in! I have two questions:
    1. Is there a way to have the ST2 widget/command window close when no error is found upon compilation?
    2. Is it possible to have the compilation output in a window instead of in the ST2 widget/command window?
    In advance, thanks! =)

    • Hi,

      1 is not currently possible, but could be added. I’ll consider this a feature request! 2 is quite a bit harder, especially because I’d really like to keep functionality the same across different platforms. So, it’s unlikely to happen.

      Thanks for your feedback, M

  23. Hello,

    Thanks for the plugin. I’ve recently installed sublime 3 and everything works perfectly. However when I hit Ctrl-b to compile the tex file, I receive this error:

    “Unable to find target command: make_pdf”

    Googled it and figured someone else is also having the same problem. Can you help fixing it please?


  24. Hi Marciano, Have you ever used github as revision control for latex documents with multiple coauthors?

    • Not really. I heard some people do. Have you?

      • No, but I’m looking for a good solution. Dropbox is enough when it’s just you and another person. With 3 or more people this becomes a coordination problem and a lot of the discussion ends up in the email chain, which is a pain.

  25. Hi,
    On Windows 7 crtl+b works a treat for me but ctrl+l does not. ctrl+l performs “Expand Selection to Line” which is a standard Sublime 2 command that I use all the time when munging text. Is there a way to change the “primer” keystrokes to something else that isn’t already a standard sublime 2 shortcut?

    Kind Regards,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s