3

Is there a way to automatically insert \item whenever I hit enter within an itemize or enumerate in Sublime Text 2?

3
  • Welcome to TeX.sx! A tip: You can use backticks ` to mark your inline code.
    – Corentin
    Commented Nov 13, 2012 at 22:43
  • Thanks! I didn't realize that itemize and enumerate was really code. Commented Nov 13, 2012 at 23:20
  • Marking them as code makes it clear that you are speaking about environments.
    – Corentin
    Commented Nov 13, 2012 at 23:23

2 Answers 2

5

If you have the LaTeXTools plugin, it already does that exept that it is mapped on Shift+Enter instead of Enter.

The corresponding code is in the default (PLATFORM).sublime-keymap

// automatic addition of new \items when hitting Shift+Enter in a list environment
{ "keys": ["shift+enter"], "command": "insert_snippet", "args": {"contents": "\n\\item $0"}, 
"context":  
    [
        {"key": "selector", "operator": "equal", "operand": "meta.function.environment.list.latex"},
        { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
        { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }
    ]
},

You can duplicate it or modify it in order to map it on another key by replacing the content inside of the first brackets after "keys"

3
  • 1
    Thanks! But when I change "shift+enter" to "enter", pressing enter right after \end{itemize} still inserts \item? Is that just a small glitch? Commented Dec 5, 2012 at 23:00
  • @AlfredXing I never noticed this but you are right. It is less annoying with the original shortcut. Maybe that's why they did not choose enter ! Commented Dec 6, 2012 at 10:39
  • @AlfredXing Tried to dig into this and ended up by opening a thread on ST2 forum to try to know more about this: sublimetext.com/forum/… Commented Dec 6, 2012 at 11:24
1

If you're using the LaTeX Tools package, hitting Shift+Enter within any sort of list environment will insert new \items (if you're not, you really should be). If you want change this to just Enter, you'll have to change the user keybindings (Preferences > Package Settings > LaTeXTools > Keybindings – User).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .