Skip to content

Commit f86726c

Browse files
authored
Wrap word under caret into bold/emphasis/underline (#1668)
This commit adds separate key bindings for wrapping words or selections into text emphasis tags. If nothing is selected, expand selection to word boundaries before inserting emphasis snippet.
1 parent 6e40195 commit f86726c

File tree

3 files changed

+516
-3
lines changed

3 files changed

+516
-3
lines changed

Default (Linux).sublime-keymap

Lines changed: 172 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,53 +352,224 @@ LaTeX Package keymap for Linux
352352
]
353353
},
354354

355-
// Wrap selected text in emph, bold or underline
355+
// Wrap word under caret in bold
356+
{
357+
"keys": ["ctrl+l","ctrl+b"],
358+
"command": "chain",
359+
"args": {
360+
"commands": [
361+
{ "command": "expand_selection", "args": { "to": "word" } },
362+
{ "command": "insert_snippet", "args": { "name":"Packages/LaTeXTools/snippets/latex/bf.sublime-snippet" } }
363+
]
364+
},
365+
"context": [
366+
{ "key": "selection_empty", "match_all": true },
367+
{ "key": "selector", "operand": "text.tex.latex - text.tex.latex meta.environment.math" }
368+
]
369+
},
370+
{
371+
"keys": ["ctrl+l","ctrl+b"],
372+
"command": "chain",
373+
"args": {
374+
"commands": [
375+
{ "command": "expand_selection", "args": { "to": "word" } },
376+
{ "command": "insert_snippet", "args": { "name":"Packages/LaTeXTools/snippets/math/bf.sublime-snippet" } }
377+
]
378+
},
379+
"context": [
380+
{ "key": "selection_empty", "match_all": true },
381+
{ "key": "selector", "operand": "text.tex.latex meta.environment.math" }
382+
]
383+
},
384+
385+
// Wrap selected text in bold
356386
{
357387
"keys": ["ctrl+l","ctrl+b"],
358388
"command": "insert_snippet", "args": { "name":"Packages/LaTeXTools/snippets/latex/bf.sublime-snippet" },
359389
"context": [
390+
{ "key": "selection_empty", "operand": false, "match_all": true },
360391
{ "key": "selector", "operand": "text.tex.latex - text.tex.latex meta.environment.math" }
361392
]
362393
},
363394
{
364395
"keys": ["ctrl+l","ctrl+b"],
365396
"command": "insert_snippet", "args": { "name":"Packages/LaTeXTools/snippets/math/bf.sublime-snippet" },
366397
"context": [
398+
{ "key": "selection_empty", "operand": false, "match_all": true },
367399
{ "key": "selector", "operand": "text.tex.latex meta.environment.math" }
368400
]
369401
},
402+
403+
// Wrap word under caret in emph
404+
{
405+
"keys": ["ctrl+l","ctrl+e"],
406+
"command": "chain",
407+
"args": {
408+
"commands": [
409+
{ "command": "expand_selection", "args": { "to": "word" } },
410+
{ "command": "insert_snippet", "args": { "name":"Packages/LaTeXTools/snippets/latex/em.sublime-snippet" } }
411+
]
412+
},
413+
"context": [
414+
{ "key": "selection_empty", "match_all": true },
415+
{ "key": "selector", "operand": "text.tex.latex" }
416+
]
417+
},
418+
419+
// Wrap selected text in emph
370420
{
371421
"keys": ["ctrl+l","ctrl+e"],
372422
"command": "insert_snippet", "args": { "name":"Packages/LaTeXTools/snippets/latex/em.sublime-snippet" },
373423
"context": [
424+
{ "key": "selection_empty", "operand": false, "match_all": true },
374425
{ "key": "selector", "operand": "text.tex.latex" }
375426
]
376427
},
428+
429+
// Wrap word under caret in italic
430+
{
431+
"keys": ["ctrl+l","ctrl+i"],
432+
"command": "chain",
433+
"args": {
434+
"commands": [
435+
{ "command": "expand_selection", "args": { "to": "word" } },
436+
{ "command": "insert_snippet", "args": { "name":"Packages/LaTeXTools/snippets/latex/it.sublime-snippet" } }
437+
]
438+
},
439+
"context": [
440+
{ "key": "selection_empty", "match_all": true },
441+
{ "key": "selector", "operand": "text.tex.latex - text.tex.latex meta.environment.math" }
442+
]
443+
},
444+
{
445+
"keys": ["ctrl+l","ctrl+i"],
446+
"command": "chain",
447+
"args": {
448+
"commands": [
449+
{ "command": "expand_selection", "args": { "to": "word" } },
450+
{ "command": "insert_snippet", "args": { "name":"Packages/LaTeXTools/snippets/math/it.sublime-snippet" } }
451+
]
452+
},
453+
"context": [
454+
{ "key": "selection_empty", "match_all": true },
455+
{ "key": "selector", "operand": "text.tex.latex meta.environment.math" }
456+
]
457+
},
458+
459+
// Wrap selected text in italic
460+
{
461+
"keys": ["ctrl+l","ctrl+i"],
462+
"command": "insert_snippet", "args": { "name":"Packages/LaTeXTools/snippets/latex/it.sublime-snippet" },
463+
"context": [
464+
{ "key": "selection_empty", "operand": false, "match_all": true },
465+
{ "key": "selector", "operand": "text.tex.latex - text.tex.latex meta.environment.math" }
466+
]
467+
},
468+
{
469+
"keys": ["ctrl+l","ctrl+i"],
470+
"command": "insert_snippet", "args": { "name":"Packages/LaTeXTools/snippets/math/it.sublime-snippet" },
471+
"context": [
472+
{ "key": "selection_empty", "operand": false, "match_all": true },
473+
{ "key": "selector", "operand": "text.tex.latex meta.environment.math" }
474+
]
475+
},
476+
477+
// Wrap word under caret in sl
478+
{
479+
"keys": ["ctrl+l","ctrl+s"],
480+
"command": "chain",
481+
"args": {
482+
"commands": [
483+
{ "command": "expand_selection", "args": { "to": "word" } },
484+
{ "command": "insert_snippet", "args": { "name":"Packages/LaTeXTools/snippets/latex/sl.sublime-snippet" } }
485+
]
486+
},
487+
"context": [
488+
{ "key": "selection_empty", "match_all": true },
489+
{ "key": "selector", "operand": "text.tex.latex - text.tex.latex meta.environment.math" }
490+
]
491+
},
492+
493+
// Wrap selected text in sl
377494
{
378495
"keys": ["ctrl+l","ctrl+s"],
379496
"command": "insert_snippet", "args": { "name":"Packages/LaTeXTools/snippets/latex/sl.sublime-snippet" },
380497
"context": [
498+
{ "key": "selection_empty", "operand": false, "match_all": true },
499+
{ "key": "selector", "operand": "text.tex.latex - text.tex.latex meta.environment.math" }
500+
]
501+
},
502+
503+
// Wrap word under caret in tt
504+
{
505+
"keys": ["ctrl+l","ctrl+t"],
506+
"command": "chain",
507+
"args": {
508+
"commands": [
509+
{ "command": "expand_selection", "args": { "to": "word" } },
510+
{ "command": "insert_snippet", "args": { "name":"Packages/LaTeXTools/snippets/latex/tt.sublime-snippet" } }
511+
]
512+
},
513+
"context": [
514+
{ "key": "selection_empty", "match_all": true },
381515
{ "key": "selector", "operand": "text.tex.latex - text.tex.latex meta.environment.math" }
382516
]
383517
},
518+
{
519+
"keys": ["ctrl+l","ctrl+t"],
520+
"command": "chain",
521+
"args": {
522+
"commands": [
523+
{ "command": "expand_selection", "args": { "to": "word" } },
524+
{ "command": "insert_snippet", "args": { "name":"Packages/LaTeXTools/snippets/math/tt.sublime-snippet" } }
525+
]
526+
},
527+
"context": [
528+
{ "key": "selection_empty", "match_all": true },
529+
{ "key": "selector", "operand": "text.tex.latex meta.environment.math" }
530+
]
531+
},
532+
533+
// Wrap selected text in tt
384534
{
385535
"keys": ["ctrl+l","ctrl+t"],
386536
"command": "insert_snippet", "args": { "name":"Packages/LaTeXTools/snippets/latex/tt.sublime-snippet" },
387537
"context": [
538+
{ "key": "selection_empty", "operand": false, "match_all": true },
388539
{ "key": "selector", "operand": "text.tex.latex - text.tex.latex meta.environment.math" }
389540
]
390541
},
391542
{
392543
"keys": ["ctrl+l","ctrl+t"],
393544
"command": "insert_snippet", "args": { "name":"Packages/LaTeXTools/snippets/math/tt.sublime-snippet" },
394545
"context": [
546+
{ "key": "selection_empty", "operand": false, "match_all": true },
395547
{ "key": "selector", "operand": "text.tex.latex meta.environment.math" }
396548
]
397549
},
550+
551+
// Wrap word under caret in underline
552+
{
553+
"keys": ["ctrl+l","ctrl+u"],
554+
"command": "chain",
555+
"args": {
556+
"commands": [
557+
{ "command": "expand_selection", "args": { "to": "word" } },
558+
{ "command": "insert_snippet", "args": { "name":"Packages/LaTeXTools/snippets/latex/un.sublime-snippet" } }
559+
]
560+
},
561+
"context": [
562+
{ "key": "selection_empty", "match_all": true },
563+
{ "key": "selector", "operand": "text.tex.latex" }
564+
]
565+
},
566+
567+
// Wrap selected text in underline
398568
{
399569
"keys": ["ctrl+l","ctrl+u"],
400570
"command": "insert_snippet", "args": { "name":"Packages/LaTeXTools/snippets/latex/un.sublime-snippet" },
401571
"context": [
572+
{ "key": "selection_empty", "operand": false, "match_all": true },
402573
{ "key": "selector", "operand": "text.tex.latex" }
403574
]
404575
},

0 commit comments

Comments
 (0)