9951 explained code solutions for 126 technologies

aceAutomatically pick a mode based on file extension

<script src="https://pagecdn.io/lib/ace/1.4.12/ext-modelist.min.js"></script>

  var modes = ace.require('ace/ext/modelist');
  editor.session.setMode( modes.getModeForPath( 'file.js' ).mode );
</script>ctrl + c

includes mode list extension to automatically pick modes

var modes

declares modeList object


set syntaxt mode for editor (see how to init ace aditor)


will automatically detect mode based on file path


example file path to get mode for (javascript file in our case)