on master help sign in
x for line selection
a5be718Blaž Hrastnik
helix-view/src/commands.rs+12
@@ -235,6 +235,18 @@ pub fn split_selection_on_newline(view: &mut View, _count: usize) {
235 view.state.selection = selection::split_on_matches(text, view.state.selection(), &REGEX)
235 view.state.selection = selection::split_on_matches(text, view.state.selection(), &REGEX)
236}
236}
237
237
238+pub fn select_line(view: &mut View, _count: usize) {
239+ // TODO: count
240+ let pos = view.state.selection().primary();
241+ let text = view.state.doc();
242+ let line = text.char_to_line(pos.head);
243+ let start = text.line_to_char(line);
244+ let end = text.line_to_char(line + 1);
245+
246+ // TODO: use a transaction
247+ view.state.selection = Selection::single(start, end);
248+}
249+
238pub fn delete_selection(view: &mut View, _count: usize) {
250pub fn delete_selection(view: &mut View, _count: usize) {
239 let transaction =
251 let transaction =
240 Transaction::change_by_selection(&view.state, |range| (range.from(), range.to(), None));
252 Transaction::change_by_selection(&view.state, |range| (range.from(), range.to(), None));
helix-view/src/keymap.rs+1
@@ -145,6 +145,7 @@ pub fn default() -> Keymaps {
145 vec![key!('c')] => commands::change_selection,
145 vec![key!('c')] => commands::change_selection,
146 vec![key!('s')] => commands::split_selection_on_newline,
146 vec![key!('s')] => commands::split_selection_on_newline,
147 vec![key!(';')] => commands::collapse_selection,
147 vec![key!(';')] => commands::collapse_selection,
148+ vec![key!('x')] => commands::select_line,
148 vec![key!('u')] => commands::undo,
149 vec![key!('u')] => commands::undo,
149 vec![shift!('U')] => commands::redo,
150 vec![shift!('U')] => commands::redo,
150 vec![key!('y')] => commands::yank,
151 vec![key!('y')] => commands::yank,