Skip to content

Instantly share code, notes, and snippets.

View lucainnocenti's full-sized avatar

Luca Innocenti lucainnocenti

  • University of Palermo
  • Palermo
View GitHub Profile
@taufik-nurrohman
taufik-nurrohman / codemirror-0.js
Last active February 15, 2018 16:53
CodeMirror Hotkeys for Bold and Italic
editor.addKeyMap({
// bold
'Ctrl-B': function(cm) {
var s = cm.getSelection(),
t = s.slice(0, 2) === '**' && s.slice(-2) === '**';
cm.replaceSelection(t ? s.slice(2, -2) : '**' + s + '**', 'around');
},
// italic
'Ctrl-I': function(cm) {
var s = cm.getSelection(),