aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-02-19 04:59:24 +0000
committerBlaž Hrastnik2021-02-19 04:59:24 +0000
commit7a1ff5e45f829df17dfdcbd4923ae9e83fc2bf3f (patch)
treed550fd8913676f7be7165a7f0f5491be8b1037e5 /helix-term/src
parent4ab5631d6521ffae6b31e9b9c72dd31a49e793ce (diff)
commands: Wire up toggle comments as ctrl-c
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/commands.rs10
-rw-r--r--helix-term/src/keymap.rs3
2 files changed, 12 insertions, 1 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 621e1223..4fe80971 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -1,5 +1,5 @@
use helix_core::{
- graphemes,
+ comment, graphemes,
indent::TAB_WIDTH,
regex::Regex,
register, selection,
@@ -1077,3 +1077,11 @@ pub fn completion(cx: &mut Context) {
pub fn next_view(cx: &mut Context) {
cx.editor.tree.focus_next()
}
+
+// comments
+pub fn toggle_comments(cx: &mut Context) {
+ let doc = cx.doc();
+ let transaction = comment::toggle_line_comments(&doc.state);
+
+ doc.apply(&transaction);
+}
diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs
index 932a6431..124456c9 100644
--- a/helix-term/src/keymap.rs
+++ b/helix-term/src/keymap.rs
@@ -198,6 +198,9 @@ pub fn default() -> Keymaps {
code: KeyCode::Tab,
modifiers: Modifiers::NONE
}] => commands::next_view,
+
+ // move under <space>c
+ vec![ctrl!('c')] => commands::toggle_comments,
),
Mode::Insert => hashmap!(
vec![Key {