diff options
author | Jason Downs <downsj@cvs.openbsd.org> | 1996-09-26 14:13:09 +0000 |
---|---|---|
committer | Jason Downs <downsj@cvs.openbsd.org> | 1996-09-26 14:13:09 +0000 |
commit | d659a0b36fb917c7fe036bb38072489f8f821cb7 (patch) | |
tree | ae203b3b383a90ac24d7f311ef8296e883562398 /usr.bin/vim | |
parent | 1f98c5e2381ad9dd2ba3bf3dfdb5db9b7b68ca13 (diff) |
Make cw handling an option.
Diffstat (limited to 'usr.bin/vim')
-rw-r--r-- | usr.bin/vim/normal.c | 52 | ||||
-rw-r--r-- | usr.bin/vim/option.h | 5 |
2 files changed, 42 insertions, 15 deletions
diff --git a/usr.bin/vim/normal.c b/usr.bin/vim/normal.c index 4a37eb6562a..9dfc5aa30ba 100644 --- a/usr.bin/vim/normal.c +++ b/usr.bin/vim/normal.c @@ -1,4 +1,4 @@ -/* $OpenBSD: normal.c,v 1.3 1996/09/22 01:18:06 downsj Exp $ */ +/* $OpenBSD: normal.c,v 1.4 1996/09/26 14:13:07 downsj Exp $ */ /* vi:set ts=4 sw=4: * * VIM - Vi IMproved by Bram Moolenaar @@ -948,21 +948,47 @@ lineop: case K_S_RIGHT: op_inclusive = FALSE; flag = TRUE; + /* - * This is a little strange. To match what the real vi does, we - * effectively map 'cw' to 'ce', and 'cW' to 'cE', provided that we - * are not on a space or a TAB. This seems impolite at first, but it's - * really more what we mean when we say 'cw'. - * Another strangeness: When standing on the end of a word "ce" will - * change until the end of the next wordt, but "cw" will change only - * one character! This is done by setting type to 2. + * "cw" and "cW" are a special case. */ - if (op_type == CHANGE && (n = gchar_cursor()) != ' ' && n != TAB && - n != NUL) + if (op_type == CHANGE) { - op_inclusive = TRUE; - flag = FALSE; - flag2 = TRUE; + n = gchar_cursor(); + if (n != NUL) /* not an empty line */ + { + op_inclusive = TRUE; + if (vim_iswhite(n)) + { + /* + * Reproduce a funny Vi behaviour: "cw" on a blank only + * changes one character, not all blanks until the start + * of the next word. Only do this when the 'w' flag is + * included in 'cpoptions'. + */ + if (Prenum1 == 1 && vim_strchr(p_cpo, CPO_CW) != NULL) + { + op_motion_type = MCHAR; + break; + } + } + else + { + /* + * This is a little strange. To match what the real vi + * does, we effectively map 'cw' to 'ce', and 'cW' to + * 'cE', provided that we are not on a space or a TAB. + * This seems impolite at first, but it's really more what + * we mean when we say 'cw'. + * Another strangeness: When standing on the end of a word + * "ce" will change until the end of the next wordt, but + * "cw" will change only one character! This is done by + * setting flag2. + */ + flag = FALSE; + flag2 = TRUE; + } + } } dowrdcmd: diff --git a/usr.bin/vim/option.h b/usr.bin/vim/option.h index 47d7578da73..192fceaf189 100644 --- a/usr.bin/vim/option.h +++ b/usr.bin/vim/option.h @@ -1,4 +1,4 @@ -/* $OpenBSD: option.h,v 1.2 1996/09/21 06:23:15 downsj Exp $ */ +/* $OpenBSD: option.h,v 1.3 1996/09/26 14:13:08 downsj Exp $ */ /* vi:set ts=4 sw=4: * * VIM - Vi IMproved by Bram Moolenaar @@ -51,13 +51,14 @@ #define CPO_BUFOPT 's' #define CPO_BUFOPTGLOB 'S' #define CPO_TAGPAT 't' +#define CPO_CW 'w' /* "cw" only changes one blank */ #define CPO_ESC 'x' #define CPO_DOLLAR '$' #define CPO_FILTER '!' #define CPO_MATCH '%' #define CPO_SPECI '<' /* don't recognize <> in mappings */ #define CPO_DEFAULT "BceFs" -#define CPO_ALL "bBcefFkmorsStx$!%<" +#define CPO_ALL "bBcefFkmorsStwx$!%<" /* characters for p_ww option: */ #define WW_ALL "bshl<>[]," |