diff options
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | config.def.h | 2 | ||||
| -rw-r--r-- | main.c | 12 | ||||
| -rw-r--r-- | text-motions.c | 8 | ||||
| -rw-r--r-- | text-motions.h | 2 | ||||
| -rw-r--r-- | vis-motions.c | 2 | ||||
| -rw-r--r-- | vis.h | 2 |
7 files changed, 30 insertions, 0 deletions
@@ -139,6 +139,8 @@ Operators can be forced to work line wise by specifying `V`. [] (previous end of C-like function) [{ (previous start of block) ]} (next start of block) + [( (previous start of parenthese pair) + ]) (next start of parenthese pair) { (previous paragraph) ( (previous sentence) [[ (previous start of C-like function) diff --git a/config.def.h b/config.def.h index ba27fec..7b75f2e 100644 --- a/config.def.h +++ b/config.def.h @@ -32,6 +32,8 @@ static const KeyBinding bindings_motions[] = { { "[[", ACTION(CURSOR_FUNCTION_START_PREV) }, { "[{", ACTION(CURSOR_BLOCK_START) }, { "]}", ACTION(CURSOR_BLOCK_END) }, + { "[(", ACTION(CURSOR_PARENTHESE_START) }, + { "])", ACTION(CURSOR_PARENTHESE_END) }, { "$", ACTION(CURSOR_LINE_LASTCHAR) }, { "^", ACTION(CURSOR_LINE_START) }, { "}", ACTION(CURSOR_PARAGRAPH_NEXT) }, @@ -161,6 +161,8 @@ enum { VIS_ACTION_CURSOR_FUNCTION_END_NEXT, VIS_ACTION_CURSOR_BLOCK_START, VIS_ACTION_CURSOR_BLOCK_END, + VIS_ACTION_CURSOR_PARENTHESE_START, + VIS_ACTION_CURSOR_PARENTHESE_END, VIS_ACTION_CURSOR_COLUMN, VIS_ACTION_CURSOR_LINE_FIRST, VIS_ACTION_CURSOR_LINE_LAST, @@ -477,6 +479,16 @@ static const KeyAction vis_action[] = { "Move cursor to the closing curly brace in a block", movement, { .i = VIS_MOVE_BLOCK_END } }, + [VIS_ACTION_CURSOR_PARENTHESE_START] = { + "cursor-parenthese-start", + "Move cursor to the opening parenthese inside a pair of parentheses", + movement, { .i = VIS_MOVE_PARENTHESE_START } + }, + [VIS_ACTION_CURSOR_PARENTHESE_END] = { + "cursor-parenthese-end", + "Move cursor to the closing parenthese inside a pair of parentheses", + movement, { .i = VIS_MOVE_PARENTHESE_END } + }, [VIS_ACTION_CURSOR_COLUMN] = { "cursor-column", "Move cursor to given column of current line", diff --git a/text-motions.c b/text-motions.c index e948fae..a25299b 100644 --- a/text-motions.c +++ b/text-motions.c @@ -612,6 +612,14 @@ size_t text_block_end(Text *txt, size_t pos) { return text_paren_start_end(txt, pos, +1, text_object_curly_bracket); } +size_t text_parenthese_start(Text *txt, size_t pos) { + return text_paren_start_end(txt, pos, -1, text_object_paranthese); +} + +size_t text_parenthese_end(Text *txt, size_t pos) { + return text_paren_start_end(txt, pos, +1, text_object_paranthese); +} + size_t text_bracket_match(Text *txt, size_t pos) { return text_bracket_match_symbol(txt, pos, NULL); } diff --git a/text-motions.h b/text-motions.h index 6066168..6a3c058 100644 --- a/text-motions.h +++ b/text-motions.h @@ -114,6 +114,8 @@ size_t text_section_prev(Text*, size_t pos); */ size_t text_block_start(Text*, size_t pos); size_t text_block_end(Text*, size_t pos); +size_t text_parenthese_start(Text*, size_t pos); +size_t text_parenthese_end(Text*, size_t pos); /* search coresponding '(', ')', '{', '}', '[', ']', '>', '<', '"', ''' */ size_t text_bracket_match(Text*, size_t pos); /* same as above but explicitly specify symbols to match */ diff --git a/vis-motions.c b/vis-motions.c index b89f94c..33784ff 100644 --- a/vis-motions.c +++ b/vis-motions.c @@ -368,6 +368,8 @@ const Movement vis_motions[] = { [VIS_MOVE_FUNCTION_END_NEXT] = { .txt = text_function_end_next, .type = LINEWISE|JUMP }, [VIS_MOVE_BLOCK_START] = { .txt = text_block_start, .type = JUMP }, [VIS_MOVE_BLOCK_END] = { .txt = text_block_end, .type = JUMP }, + [VIS_MOVE_PARENTHESE_START] = { .txt = text_parenthese_start, .type = JUMP }, + [VIS_MOVE_PARENTHESE_END] = { .txt = text_parenthese_end, .type = JUMP }, [VIS_MOVE_BRACKET_MATCH] = { .txt = bracket_match, .type = INCLUSIVE|JUMP }, [VIS_MOVE_FILE_BEGIN] = { .txt = text_begin, .type = LINEWISE|JUMP }, [VIS_MOVE_FILE_END] = { .txt = text_end, .type = LINEWISE|JUMP }, @@ -221,6 +221,8 @@ enum VisMotion { VIS_MOVE_FUNCTION_END_NEXT, VIS_MOVE_BLOCK_START, VIS_MOVE_BLOCK_END, + VIS_MOVE_PARENTHESE_START, + VIS_MOVE_PARENTHESE_END, VIS_MOVE_BRACKET_MATCH, VIS_MOVE_LEFT_TO, VIS_MOVE_RIGHT_TO, |
