Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ctrl + [ support for exiting insert mode #536

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions bundles/vi/insert_map.moon
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ get_edit = (editor) ->
if text and #text > 0
(editor) -> editor\insert text

exit_insert_mode = (editor) ->
state.insert_edit = get_edit editor
insert_pos = nil
state.change_mode editor, 'command'
editor.cursor.column = math.max 1, editor.cursor.column - 1

insert_map = {
__meta: {

Expand All @@ -27,22 +33,11 @@ insert_map = {
blink_interval: -> config.cursor_blink_interval
}

escape: (editor) ->
state.insert_edit = get_edit editor
insert_pos = nil
state.change_mode editor, 'command'
editor.cursor.column = math.max 1, editor.cursor.column - 1

'ctrl_[': (editor) ->
state.insert_edit = get_edit editor
insert_pos = nil
state.change_mode editor, 'command'
editor.cursor.column = math.max 1, editor.cursor.column - 1

escape: (editor) -> exit_insert_mode editor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can just be written as

escape: exit_insert_mode

Same for next line.

Otherwise looks good to me!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I've done so.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've found that the ctrl + [ doesn't work when writing python code at least, there's probably something overriding the key combo for that syntax, I'll investigate further at some point.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you still want to merge this then?

'ctrl_[': (editor) -> exit_insert_mode editor
ctrl_i: (editor) -> editor\shift_right!
ctrl_d: (editor) -> editor\shift_left!
}

setmetatable insert_map, {
__call: (_, editor) ->
state.enter_edit_mode editor
Expand Down