The WordPress theme/plugin (file) editor uses CodeMirror for syntax highlighting, and with the hook wp_enqueue_code_editor
(which is available starting from WordPress version 4.9.0), you can filter the default CodeMirror settings, as in the following example:
add_filter( 'wp_code_editor_settings', function( $settings ) {
$settings['codemirror']['indentUnit'] = 2;
$settings['codemirror']['indentWithTabs'] = false;
return $settings;
} );
See http://codemirror.net/doc/manual.html#config if you’d like to change other CodeMirror settings.
PS: You’d add the code above to the theme’s functions.php file.