diff --git a/services/web/app/views/project/editor/editor.pug b/services/web/app/views/project/editor/editor.pug index fed1889d79..352db77b7e 100644 --- a/services/web/app/views/project/editor/editor.pug +++ b/services/web/app/views/project/editor/editor.pug @@ -58,6 +58,7 @@ div.full-size( read-only="!permissions.write", file-name="editor.open_doc_name", on-ctrl-enter="recompileViaKey", + on-save="recompileViaKey", on-ctrl-j="toggleReviewPanel", on-ctrl-shift-c="addNewCommentFromKbdShortcut", on-ctrl-shift-a="toggleTrackChangesFromKbdShortcut", diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor.coffee index fd6a8224e4..2552a7a95d 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor.coffee @@ -3,6 +3,7 @@ define [ "ace/ace" "ace/ext-searchbox" "ace/ext-modelist" + "ace/keybinding-vim" "ide/editor/directives/aceEditor/undo/UndoManager" "ide/editor/directives/aceEditor/auto-complete/AutoCompleteManager" "ide/editor/directives/aceEditor/spell-check/SpellCheckManager" @@ -14,9 +15,10 @@ define [ "ide/graphics/services/graphics" "ide/preamble/services/preamble" "ide/files/services/files" -], (App, Ace, SearchBox, ModeList, UndoManager, AutoCompleteManager, SpellCheckManager, HighlightsManager, CursorPositionManager, TrackChangesManager, MetadataManager) -> +], (App, Ace, SearchBox, Vim, ModeList, UndoManager, AutoCompleteManager, SpellCheckManager, HighlightsManager, CursorPositionManager, TrackChangesManager, MetadataManager) -> EditSession = ace.require('ace/edit_session').EditSession ModeList = ace.require('ace/ext/modelist') + Vim = ace.require('ace/keyboard/vim').Vim # set the path for ace workers if using a CDN (from editor.pug) if window.aceWorkerPath != "" @@ -60,6 +62,7 @@ define [ onCtrlJ: "=" # Toggle the review panel onCtrlShiftC: "=" # Add a new comment onCtrlShiftA: "=" # Toggle track-changes on/off + onSave: "=" # Cmd/Ctrl-S or :w in Vim syntaxValidation: "=" reviewPanel: "=" eventsBridge: "=" @@ -107,15 +110,20 @@ define [ autoCompleteManager = new AutoCompleteManager(scope, editor, element, metadataManager, graphics, preamble, files) # Prevert Ctrl|Cmd-S from triggering save dialog - editor.commands.addCommand - name: "save", - bindKey: win: "Ctrl-S", mac: "Command-S" - exec: () -> - readOnly: true + scope.$watch "onSave", (callback) -> + if callback? + editor.commands.addCommand + name: "save", + bindKey: win: "Ctrl-S", mac: "Command-S" + exec: () -> + callback() + readOnly: true + Vim.defineEx 'write', 'w', callback editor.commands.removeCommand "transposeletters" editor.commands.removeCommand "showSettingsMenu" editor.commands.removeCommand "foldall" + # For European keyboards, the / is above 7 so needs Shift pressing. # This comes through as Command-Shift-/ on OS X, which is mapped to # toggleBlockComment.