regex - Using Sublime Text to ensure one sentence per line in LaTeX documents -


the goal adopt third way---a.k.a. using semantic linefeeds. involves typing 1 sentence per line of tex file. makes easier use version control systems when working tex files , other, text-heavy files. (a similar recommendation made in answer this question.)

of course, manually insert line break @ end of every sentence. however, lead bad habits (e.g. typing sentence per line when writing emails). i'm looking alternative way of implementing this.

one solution, of using sublime text, use st's keybindings. essentially, turn spacebar keyboard shortcut script

  • check whether precedes end of sentence, and
  • if is, insert line break.

here's relevant snippet:

{ "keys": [" "],         "context":  [                 {"key": "selector", "operator": "equal", "operand": "text.tex.latex"},                 {"key": "preceding_text", "operator": "regex_match", "operand": "(^.+\\.$)|(^.+\\?$)|(^.+\\!$)|(^.+\\.+\\)$)"},                 {"key": "preceding_text", "operator": "not_regex_match", "operand": "(^.*\\\\ex\\.$)|(^.*\\\\[abz]\\.$)"},                 {"key": "preceding_text", "operator": "not_regex_match", "operand": "(^.*[cc]f\\.$)|(^.*\\b[pp]+\\.$)|(^.*etc\\.$)|(^.*\\b[a-z]\\.$)|(^\\w\\.$)|(^.*m[sr]\\.$)|(^.*mrs\\.$)"}                 ],         "command": "insert", "args": {"characters": " %\n"}     } 

i append sublime/packages/user/default (osx).sublime-keymap , seems trick.

the snippet supposed precedes space, , give match if have string ends 1 of following:

  • a period,
  • an exclamation mark,
  • a question mark,
  • a closing parenthesis preceded period.

it ignore strings end period if preceded 1 of following:

  • '\ex', '\a', '\b', '\z' (this able use linguex package),
  • 'cf', 'cf',
  • 'p', 'pp', 'p',
  • 'etc'
  • 'mr', 'mrs', 'ms', 'dr',
  • single capital letters (for use of initials in sentence).

i'm curious see if there other things should add list ('ibid', suppose one).

i'm wondering whether there less clunky solutions problem.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -