Integrate Codemirror and set up - Javascript CodeMirror

Javascript examples for CodeMirror:Configuration

Description

Integrate Codemirror and set up

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.4.0/codemirror.css"> 
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.4.0/codemirror.js"></script> 
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.4.0/mode/htmlmixed/htmlmixed.min.js"></script> 
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.4.0/mode/javascript/javascript.min.js"></script> 
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.4.0/mode/css/css.min.js"></script> 
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.4.0/mode/xml/xml.min.js"></script> 
      <style id="compiled-css" type="text/css">

.CodeMirror {/*from  w  w w  .  j  a va2  s.com*/
   border-top: 1px solid #888;
   border-bottom: 1px solid #888;
}


      </style> 
   </head> 
   <body> 
      <!-- Create a simple CodeMirror instance -->  
      <textarea id="myCode"></textarea> 
      <script type="text/javascript">
      window.onload = function() {
        var myTextarea = document.getElementById("myCode");
        editor = CodeMirror.fromTextArea(myTextarea, {
          lineNumbers: true
        });
      };
    
      </script>   
   </body>
</html>

Related Tutorials