1
0
forked from aniani/vim

updated for version 7.4.530

Problem:    Many commands take a count or range that is not using line
            numbers.
Solution:   For each command specify what kind of count it uses.  For windows,
            buffers and arguments have "$" and "." have a relevant meaning.
            (Marcin Szamotulski)
This commit is contained in:
Bram Moolenaar
2014-11-27 16:22:48 +01:00
parent baf0344ed7
commit b96a7f325c
13 changed files with 1662 additions and 702 deletions

View File

@@ -61,16 +61,25 @@ In the GUI tab pages line you can use the right mouse button to open menu.
:[count]tabe[dit] *:tabe* *:tabedit* *:tabnew* :[count]tabe[dit] *:tabe* *:tabedit* *:tabnew*
:[count]tabnew :[count]tabnew
Open a new tab page with an empty window, after the current Open a new tab page with an empty window, after the current
tab page. For [count] see |:tab| below. tab page. If [count] is given the new tab page appears after
the tab page [count] otherwise the new tab page will appear
after the current one. >
:tabnew " opens tabpage after the current one
:.tabnew " as above
:+tabnew " opens tabpage after the next tab page
" note: it is one further than :tabnew
:-tabnew " opens tabpage before the current one
:0tabnew " opens tabpage before the first one
:$tabnew " opens tabpage after the last one
:[count]tabe[dit] [++opt] [+cmd] {file} :[count]tabe[dit] [++opt] [+cmd] {file}
:[count]tabnew [++opt] [+cmd] {file} :[count]tabnew [++opt] [+cmd] {file}
Open a new tab page and edit {file}, like with |:edit|. Open a new tab page and edit {file}, like with |:edit|.
For [count] see |:tab| below. For [count] see |:tabnew| above.
:[count]tabf[ind] [++opt] [+cmd] {file} *:tabf* *:tabfind* :[count]tabf[ind] [++opt] [+cmd] {file} *:tabf* *:tabfind*
Open a new tab page and edit {file} in 'path', like with Open a new tab page and edit {file} in 'path', like with
|:find|. For [count] see |:tab| below. |:find|. For [count] see |:tabnew| above.
{not available when the |+file_in_path| feature was disabled {not available when the |+file_in_path| feature was disabled
at compile time} at compile time}
@@ -110,12 +119,18 @@ something else.
- When 'hidden' is not set, [!] is not used, a buffer has - When 'hidden' is not set, [!] is not used, a buffer has
changes, and there is no other window on this buffer. changes, and there is no other window on this buffer.
Changes to the buffer are not written and won't get lost, so Changes to the buffer are not written and won't get lost, so
this is a "safe" command. this is a "safe" command. >
:tabclose " close the current tab page
:{count}tabc[lose][!]
:tabc[lose][!] {count} :tabc[lose][!] {count}
Close tab page {count}. Fails in the same way as `:tabclose` Close tab page {count}. Fails in the same way as `:tabclose`
above. above. >
:-tabclose " close the previous tab page
:+tabclose " close the next tab page
:1tabclose " close the first tab page
:$tabclose " close the last tab page
<
*:tabo* *:tabonly* *:tabo* *:tabonly*
:tabo[nly][!] Close all other tab pages. :tabo[nly][!] Close all other tab pages.
When the 'hidden' option is set, all buffers in closed windows When the 'hidden' option is set, all buffers in closed windows
@@ -124,7 +139,17 @@ something else.
modified buffers are written. Otherwise, windows that have modified buffers are written. Otherwise, windows that have
buffers that are modified are not removed, unless the [!] is buffers that are modified are not removed, unless the [!] is
given, then they become hidden. But modified buffers are given, then they become hidden. But modified buffers are
never abandoned, so changes cannot get lost. never abandoned, so changes cannot get lost. >
:tabonly " close all tab pages except the current
:{count}tabo[nly][!]
Close all tab pages except the {count}th one. >
:.tabonly " one
:-tabonly " close all tab pages except the previous
" one
:+tabonly " close all tab pages except the next one
:1tabonly " close all tab pages except the first one
:$tabonly " close all tab pages except the last one
SWITCHING TO ANOTHER TAB PAGE: SWITCHING TO ANOTHER TAB PAGE:
@@ -176,7 +201,15 @@ REORDERING TAB PAGES:
:[N]tabm[ove] :[N]tabm[ove]
Move the current tab page to after tab page N. Use zero to Move the current tab page to after tab page N. Use zero to
make the current tab page the first one. Without N the tab make the current tab page the first one. Without N the tab
page is made the last one. page is made the last one. >
:-tabmove " move the tab page to the left
:tabmove " move the tab page to the right
:.tabmove " as above
:+tabmove " as above
:0tabmove " move the tab page to the begining of the tab
" list
:$tabmove " move the tab page to the end of the tab list
<
:tabm[ove] +[N] :tabm[ove] +[N]
:tabm[ove] -[N] :tabm[ove] -[N]

View File

@@ -263,28 +263,56 @@ left of the Vim window.
Closing a window Closing a window
---------------- ----------------
:q[uit]
:{count}q[uit]
CTRL-W q *CTRL-W_q* CTRL-W q *CTRL-W_q*
CTRL-W CTRL-Q *CTRL-W_CTRL-Q* CTRL-W CTRL-Q *CTRL-W_CTRL-Q*
:q[uit] Quit current window. When quitting the last window (not Without {count}: Quit the current window. If {count} is
counting a help window), exit Vim. given quit the {count} window.
When quitting the last window (not counting a help window),
exit Vim.
When 'hidden' is set, and there is only one window for the When 'hidden' is set, and there is only one window for the
current buffer, it becomes hidden. current buffer, it becomes hidden. When 'hidden' is not set,
When 'hidden' is not set, and there is only one window for the and there is only one window for the current buffer, and the
current buffer, and the buffer was changed, the command fails. buffer was changed, the command fails.
(Note: CTRL-Q does not work on all terminals)
(Note: CTRL-Q does not
work on all terminals). If [count] is greater than
the last window number the last window will be closed: >
:1quit " quit the first window
:$quit " quit the last window
:9quit " quit the last window
" if there are less than 9 windows opened
:-quit " quit the previews window
:+quit " quit the next window
:+2quit " will also work as expected
<
:q[uit]!
:{count}q[uit]!
Without {count}: Quit the current window. If {count} is
given quit the {count} window.
:q[uit]! Quit current window. If this was the last window for a buffer, If this was the last window for a buffer, any changes to that
any changes to that buffer are lost. When quitting the last buffer are lost. When quitting the last window (not counting
window (not counting help windows), exit Vim. The contents of help windows), exit Vim. The contents of the buffer are lost,
the buffer are lost, even when 'hidden' is set. even when 'hidden' is set.
:clo[se][!]
:{count}clo[se][!]
CTRL-W c *CTRL-W_c* *:clo* *:close* CTRL-W c *CTRL-W_c* *:clo* *:close*
:clo[se][!] Close current window. When the 'hidden' option is set, or Without {count}: Close the current window. If {count} is
when the buffer was changed and the [!] is used, the buffer given close the {count} window.
becomes hidden (unless there is another window editing it).
When the 'hidden' option is set, or when the buffer was
changed and the [!] is used, the buffer becomes hidden (unless
there is another window editing it).
When there is only one window in the current tab page and When there is only one window in the current tab page and
there is another tab page, this closes the current tab page. there is another tab page, this closes the current tab page.
|tab-page|. |tab-page|.
This command fails when: *E444* This command fails when: *E444*
- There is only one window on the screen. - There is only one window on the screen.
- When 'hidden' is not set, [!] is not used, the buffer has - When 'hidden' is not set, [!] is not used, the buffer has
@@ -298,14 +326,19 @@ CTRL-W CTRL-C *CTRL-W_CTRL-C*
command. command.
*:hide* *:hide*
:hid[e] Quit current window, unless it is the last window on the :hid[e]
screen. The buffer becomes hidden (unless there is another :{count}hid[e]
window editing it or 'bufhidden' is "unload" or "delete"). Quit the current window, unless it is the last window on the
If the window is the last one in the current tab page the tab screen. For {count} see |:quit| command.
page is closed. |tab-page|
The value of 'hidden' is irrelevant for this command. The buffer becomes hidden (unless there is another window
Changes to the buffer are not written and won't get lost, so editing it or 'bufhidden' is "unload" or "delete"). If the
this is a "safe" command. window is the last one in the current tab page the tab page is
closed. |tab-page|
The value of 'hidden' is irrelevant for this command. Changes
to the buffer are not written and won't get lost, so this is a
"safe" command.
:hid[e] {cmd} Execute {cmd} with 'hidden' is set. The previous value of :hid[e] {cmd} Execute {cmd} with 'hidden' is set. The previous value of
'hidden' is restored after {cmd} has been executed. 'hidden' is restored after {cmd} has been executed.
@@ -314,12 +347,16 @@ CTRL-W CTRL-C *CTRL-W_CTRL-C*
< This will edit "Makefile", and hide the current buffer if it < This will edit "Makefile", and hide the current buffer if it
has any changes. has any changes.
:on[ly][!]
:{count}on[ly][!]
CTRL-W o *CTRL-W_o* *E445* CTRL-W o *CTRL-W_o* *E445*
CTRL-W CTRL-O *CTRL-W_CTRL-O* *:on* *:only* CTRL-W CTRL-O *CTRL-W_CTRL-O* *:on* *:only*
:on[ly][!] Make the current window the only one on the screen. All other Make the current window the only one on the screen. All other
windows are closed. windows are closed. For {count} see |:quit| command.
When the 'hidden' option is set, all buffers in closed windows When the 'hidden' option is set, all buffers in closed windows
become hidden. become hidden.
When 'hidden' is not set, and the 'autowrite' option is set, When 'hidden' is not set, and the 'autowrite' option is set,
modified buffers are written. Otherwise, windows that have modified buffers are written. Otherwise, windows that have
buffers that are modified are not removed, unless the [!] is buffers that are modified are not removed, unless the [!] is

View File

@@ -1890,10 +1890,12 @@ unittest unittests: $(UNITTEST_TARGETS)
done done
# Run individual test, assuming that Vim was already compiled. # Run individual test, assuming that Vim was already compiled.
test1 test2 test3 test4 test5 test6 test7 test8 test9 \ test1 \
test_argument_count \
test_autoformat_join \ test_autoformat_join \
test_breakindent \ test_breakindent \
test_changelist \ test_changelist \
test_close_count \
test_eval \ test_eval \
test_insertcount \ test_insertcount \
test_listlbr \ test_listlbr \
@@ -1904,6 +1906,7 @@ test1 test2 test3 test4 test5 test6 test7 test8 test9 \
test_signs \ test_signs \
test_utf8 \ test_utf8 \
test_writefile \ test_writefile \
test2 test3 test4 test5 test6 test7 test8 test9 \
test10 test11 test12 test13 test14 test15 test16 test17 test18 test19 \ test10 test11 test12 test13 test14 test15 test16 test17 test18 test19 \
test20 test21 test22 test23 test24 test25 test26 test27 test28 test29 \ test20 test21 test22 test23 test24 test25 test26 test27 test28 test29 \
test30 test31 test32 test33 test34 test35 test36 test37 test38 test39 \ test30 test31 test32 test33 test34 test35 test36 test37 test38 test39 \

File diff suppressed because it is too large Load Diff

View File

@@ -60,6 +60,7 @@ static char_u *get_user_command_name __ARGS((int idx));
# define IS_USER_CMDIDX(idx) (FALSE) # define IS_USER_CMDIDX(idx) (FALSE)
#endif #endif
static int compute_buffer_local_count __ARGS((int addr_type, int lnum, int local));
#ifdef FEAT_EVAL #ifdef FEAT_EVAL
static char_u *do_one_cmd __ARGS((char_u **, int, struct condstack *, char_u *(*fgetline)(int, void *, int), void *cookie)); static char_u *do_one_cmd __ARGS((char_u **, int, struct condstack *, char_u *(*fgetline)(int, void *, int), void *cookie));
#else #else
@@ -133,7 +134,7 @@ static int getargopt __ARGS((exarg_T *eap));
#endif #endif
static int check_more __ARGS((int, int)); static int check_more __ARGS((int, int));
static linenr_T get_address __ARGS((char_u **, int skip, int to_other_file)); static linenr_T get_address __ARGS((char_u **, int addr_type, int skip, int to_other_file));
static void get_flags __ARGS((exarg_T *eap)); static void get_flags __ARGS((exarg_T *eap));
#if !defined(FEAT_PERL) \ #if !defined(FEAT_PERL) \
|| !defined(FEAT_PYTHON) || !defined(FEAT_PYTHON3) \ || !defined(FEAT_PYTHON) || !defined(FEAT_PYTHON3) \
@@ -1680,6 +1681,39 @@ getline_cookie(fgetline, cookie)
} }
#endif #endif
/*
* Helper function to apply an offset for buffer commands, i.e. ":bdelete",
* ":bwipeout", etc.
* Returns the buffer number.
*/
static int
compute_buffer_local_count(addr_type, lnum, offset)
int addr_type;
int lnum;
int offset;
{
buf_T *buf;
int count = offset;
buf = firstbuf;
while (buf->b_next != NULL && buf->b_fnum < lnum)
buf = buf->b_next;
while (count != 0)
{
count += (count < 0) ? 1 : -1;
if (buf->b_prev == NULL)
break;
buf = (count < 0) ? buf->b_prev : buf->b_next;
if (addr_type == ADDR_LOADED_BUFFERS)
/* skip over unloaded buffers */
while (buf->b_prev != NULL && buf->b_ml.ml_mfp == NULL)
buf = (count < 0) ? buf->b_prev : buf->b_next;
}
return buf->b_fnum;
}
/* /*
* Execute one Ex command. * Execute one Ex command.
* *
@@ -1687,10 +1721,10 @@ getline_cookie(fgetline, cookie)
* *
* 1. skip comment lines and leading space * 1. skip comment lines and leading space
* 2. handle command modifiers * 2. handle command modifiers
* 3. parse range * 3. parse command
* 4. parse command * 4. parse range
* 5. parse arguments * 6. parse arguments
* 6. switch on command name * 7. switch on command name
* *
* Note: "fgetline" can be NULL. * Note: "fgetline" can be NULL.
* *
@@ -1730,6 +1764,9 @@ do_one_cmd(cmdlinep, sourcing,
#endif #endif
cmdmod_T save_cmdmod; cmdmod_T save_cmdmod;
int ni; /* set when Not Implemented */ int ni; /* set when Not Implemented */
win_T *wp;
tabpage_T *tp;
char_u *cmd;
vim_memset(&ea, 0, sizeof(ea)); vim_memset(&ea, 0, sizeof(ea));
ea.line1 = 1; ea.line1 = 1;
@@ -1769,7 +1806,7 @@ do_one_cmd(cmdlinep, sourcing,
for (;;) for (;;)
{ {
/* /*
* 1. skip comment lines and leading white space and colons * 1. Skip comment lines and leading white space and colons.
*/ */
while (*ea.cmd == ' ' || *ea.cmd == '\t' || *ea.cmd == ':') while (*ea.cmd == ' ' || *ea.cmd == '\t' || *ea.cmd == ':')
++ea.cmd; ++ea.cmd;
@@ -1794,7 +1831,7 @@ do_one_cmd(cmdlinep, sourcing,
} }
/* /*
* 2. handle command modifiers. * 2. Handle command modifiers.
*/ */
p = ea.cmd; p = ea.cmd;
if (VIM_ISDIGIT(*ea.cmd)) if (VIM_ISDIGIT(*ea.cmd))
@@ -2003,7 +2040,18 @@ do_one_cmd(cmdlinep, sourcing,
#endif #endif
/* /*
* 3. parse a range specifier of the form: addr [,addr] [;addr] .. * 3. Skip over the range to find the command. Let "p" point to after it.
*
* We need the command to know what kind of range it uses.
*/
cmd = ea.cmd;
ea.cmd = skip_range(ea.cmd, NULL);
if (*ea.cmd == '*' && vim_strchr(p_cpo, CPO_STAR) == NULL)
ea.cmd = skipwhite(ea.cmd + 1);
p = find_command(&ea, NULL);
/*
* 4. parse a range specifier of the form: addr [,addr] [;addr] ..
* *
* where 'addr' is: * where 'addr' is:
* *
@@ -2019,13 +2067,52 @@ do_one_cmd(cmdlinep, sourcing,
* is equal to the lower. * is equal to the lower.
*/ */
if (ea.cmdidx != CMD_SIZE)
ea.addr_type = cmdnames[(int)ea.cmdidx].cmd_addr_type;
else
ea.addr_type = ADDR_LINES;
ea.cmd = cmd;
/* repeat for all ',' or ';' separated addresses */ /* repeat for all ',' or ';' separated addresses */
for (;;) for (;;)
{ {
ea.line1 = ea.line2; ea.line1 = ea.line2;
ea.line2 = curwin->w_cursor.lnum; /* default is current line number */ switch (ea.addr_type)
{
case ADDR_LINES:
/* default is current line number */
ea.line2 = curwin->w_cursor.lnum;
break;
case ADDR_WINDOWS:
lnum = 0;
for (wp = firstwin; wp != NULL; wp = wp->w_next)
{
lnum++;
if (wp == curwin)
break;
}
ea.line2 = lnum;
break;
case ADDR_ARGUMENTS:
ea.line2 = curwin->w_arg_idx + 1;
break;
case ADDR_LOADED_BUFFERS:
case ADDR_UNLOADED_BUFFERS:
ea.line2 = curbuf->b_fnum;
break;
case ADDR_TABS:
lnum = 0;
for(tp = first_tabpage; tp != NULL; tp = tp->tp_next)
{
lnum++;
if (tp == curtab)
break;
}
ea.line2 = lnum;
break;
}
ea.cmd = skipwhite(ea.cmd); ea.cmd = skipwhite(ea.cmd);
lnum = get_address(&ea.cmd, ea.skip, ea.addr_count == 0); lnum = get_address(&ea.cmd, ea.addr_type, ea.skip, ea.addr_count == 0);
if (ea.cmd == NULL) /* error detected */ if (ea.cmd == NULL) /* error detected */
goto doend; goto doend;
if (lnum == MAXLNUM) if (lnum == MAXLNUM)
@@ -2033,8 +2120,24 @@ do_one_cmd(cmdlinep, sourcing,
if (*ea.cmd == '%') /* '%' - all lines */ if (*ea.cmd == '%') /* '%' - all lines */
{ {
++ea.cmd; ++ea.cmd;
ea.line1 = 1; switch (ea.addr_type)
ea.line2 = curbuf->b_ml.ml_line_count; {
case ADDR_LINES:
ea.line1 = 1;
ea.line2 = curbuf->b_ml.ml_line_count;
break;
case ADDR_WINDOWS:
case ADDR_LOADED_BUFFERS:
case ADDR_UNLOADED_BUFFERS:
case ADDR_TABS:
errormsg = (char_u *)_(e_invrange);
goto doend;
break;
case ADDR_ARGUMENTS:
ea.line1 = 1;
ea.line2 = ARGCOUNT;
break;
}
++ea.addr_count; ++ea.addr_count;
} }
/* '*' - visual area */ /* '*' - visual area */
@@ -2042,6 +2145,12 @@ do_one_cmd(cmdlinep, sourcing,
{ {
pos_T *fp; pos_T *fp;
if (ea.addr_type != ADDR_LINES)
{
errormsg = (char_u *)_(e_invrange);
goto doend;
}
++ea.cmd; ++ea.cmd;
if (!ea.skip) if (!ea.skip)
{ {
@@ -2084,7 +2193,7 @@ do_one_cmd(cmdlinep, sourcing,
check_cursor_lnum(); check_cursor_lnum();
/* /*
* 4. parse command * 5. Parse the command.
*/ */
/* /*
@@ -2098,8 +2207,8 @@ do_one_cmd(cmdlinep, sourcing,
* If we got a line, but no command, then go to the line. * If we got a line, but no command, then go to the line.
* If we find a '|' or '\n' we set ea.nextcmd. * If we find a '|' or '\n' we set ea.nextcmd.
*/ */
if (*ea.cmd == NUL || *ea.cmd == '"' || if (*ea.cmd == NUL || *ea.cmd == '"'
(ea.nextcmd = check_nextcmd(ea.cmd)) != NULL) || (ea.nextcmd = check_nextcmd(ea.cmd)) != NULL)
{ {
/* /*
* strange vi behaviour: * strange vi behaviour:
@@ -2145,9 +2254,6 @@ do_one_cmd(cmdlinep, sourcing,
goto doend; goto doend;
} }
/* Find the command and let "p" point to after it. */
p = find_command(&ea, NULL);
#ifdef FEAT_AUTOCMD #ifdef FEAT_AUTOCMD
/* If this looks like an undefined user command and there are CmdUndefined /* If this looks like an undefined user command and there are CmdUndefined
* autocommands defined, trigger the matching autocommands. */ * autocommands defined, trigger the matching autocommands. */
@@ -2229,7 +2335,7 @@ do_one_cmd(cmdlinep, sourcing,
ea.forceit = FALSE; ea.forceit = FALSE;
/* /*
* 5. parse arguments * 5. Parse arguments.
*/ */
if (!IS_USER_CMDIDX(ea.cmdidx)) if (!IS_USER_CMDIDX(ea.cmdidx))
ea.argt = (long)cmdnames[(int)ea.cmdidx].cmd_argt; ea.argt = (long)cmdnames[(int)ea.cmdidx].cmd_argt;
@@ -2676,7 +2782,7 @@ do_one_cmd(cmdlinep, sourcing,
#endif #endif
/* /*
* 6. switch on command name * 6. Switch on command name.
* *
* The "ea" structure holds the arguments that can be used. * The "ea" structure holds the arguments that can be used.
*/ */
@@ -4082,8 +4188,9 @@ skip_range(cmd, ctx)
* Return MAXLNUM when no Ex address was found. * Return MAXLNUM when no Ex address was found.
*/ */
static linenr_T static linenr_T
get_address(ptr, skip, to_other_file) get_address(ptr, addr_type, skip, to_other_file)
char_u **ptr; char_u **ptr;
int addr_type; /* flag: one of ADDR_LINES, ... */
int skip; /* only skip the address, don't use it */ int skip; /* only skip the address, don't use it */
int to_other_file; /* flag: may jump to other file */ int to_other_file; /* flag: may jump to other file */
{ {
@@ -4094,6 +4201,8 @@ get_address(ptr, skip, to_other_file)
pos_T pos; pos_T pos;
pos_T *fp; pos_T *fp;
linenr_T lnum; linenr_T lnum;
win_T *wp;
tabpage_T *tp;
cmd = skipwhite(*ptr); cmd = skipwhite(*ptr);
lnum = MAXLNUM; lnum = MAXLNUM;
@@ -4102,137 +4211,204 @@ get_address(ptr, skip, to_other_file)
switch (*cmd) switch (*cmd)
{ {
case '.': /* '.' - Cursor position */ case '.': /* '.' - Cursor position */
++cmd; ++cmd;
switch (addr_type)
{
case ADDR_LINES:
lnum = curwin->w_cursor.lnum; lnum = curwin->w_cursor.lnum;
break; break;
case ADDR_WINDOWS:
lnum = 0;
for (wp = firstwin; wp != NULL; wp = wp->w_next)
{
lnum++;
if (wp == curwin)
break;
}
break;
case ADDR_ARGUMENTS:
lnum = curwin->w_arg_idx + 1;
break;
case ADDR_LOADED_BUFFERS:
case ADDR_UNLOADED_BUFFERS:
lnum = curbuf->b_fnum;
break;
case ADDR_TABS:
lnum = 0;
for(tp = first_tabpage; tp != NULL; tp = tp->tp_next)
{
lnum++;
if (tp == curtab)
break;
}
break;
}
break;
case '$': /* '$' - last line */ case '$': /* '$' - last line */
++cmd; ++cmd;
switch (addr_type)
{
case ADDR_LINES:
lnum = curbuf->b_ml.ml_line_count; lnum = curbuf->b_ml.ml_line_count;
break; break;
case ADDR_WINDOWS:
lnum = 0;
for (wp = firstwin; wp != NULL; wp = wp->w_next)
lnum++;
break;
case ADDR_ARGUMENTS:
lnum = ARGCOUNT;
break;
case ADDR_LOADED_BUFFERS:
case ADDR_UNLOADED_BUFFERS:
lnum = lastbuf->b_fnum;
break;
case ADDR_TABS:
lnum = 0;
for(tp = first_tabpage; tp != NULL; tp = tp->tp_next)
lnum++;
break;
}
break;
case '\'': /* ''' - mark */ case '\'': /* ''' - mark */
if (*++cmd == NUL) if (*++cmd == NUL)
{
cmd = NULL;
goto error;
}
if (addr_type != ADDR_LINES)
{
EMSG(_(e_invaddr));
goto error;
}
if (skip)
++cmd;
else
{
/* Only accept a mark in another file when it is
* used by itself: ":'M". */
fp = getmark(*cmd, to_other_file && cmd[1] == NUL);
++cmd;
if (fp == (pos_T *)-1)
/* Jumped to another file. */
lnum = curwin->w_cursor.lnum;
else
{
if (check_mark(fp) == FAIL)
{ {
cmd = NULL; cmd = NULL;
goto error; goto error;
} }
if (skip) lnum = fp->lnum;
++cmd; }
else }
{ break;
/* Only accept a mark in another file when it is
* used by itself: ":'M". */
fp = getmark(*cmd, to_other_file && cmd[1] == NUL);
++cmd;
if (fp == (pos_T *)-1)
/* Jumped to another file. */
lnum = curwin->w_cursor.lnum;
else
{
if (check_mark(fp) == FAIL)
{
cmd = NULL;
goto error;
}
lnum = fp->lnum;
}
}
break;
case '/': case '/':
case '?': /* '/' or '?' - search */ case '?': /* '/' or '?' - search */
c = *cmd++; c = *cmd++;
if (skip) /* skip "/pat/" */ if (addr_type != ADDR_LINES)
{ {
cmd = skip_regexp(cmd, c, (int)p_magic, NULL); EMSG(_(e_invaddr));
if (*cmd == c) goto error;
++cmd; }
} if (skip) /* skip "/pat/" */
else {
{ cmd = skip_regexp(cmd, c, (int)p_magic, NULL);
pos = curwin->w_cursor; /* save curwin->w_cursor */ if (*cmd == c)
/* ++cmd;
* When '/' or '?' follows another address, start }
* from there. else
*/ {
if (lnum != MAXLNUM) pos = curwin->w_cursor; /* save curwin->w_cursor */
curwin->w_cursor.lnum = lnum; /*
/* * When '/' or '?' follows another address, start
* Start a forward search at the end of the line. * from there.
* Start a backward search at the start of the line. */
* This makes sure we never match in the current if (lnum != MAXLNUM)
* line, and can match anywhere in the curwin->w_cursor.lnum = lnum;
* next/previous line. /*
*/ * Start a forward search at the end of the line.
if (c == '/') * Start a backward search at the start of the line.
curwin->w_cursor.col = MAXCOL; * This makes sure we never match in the current
else * line, and can match anywhere in the
curwin->w_cursor.col = 0; * next/previous line.
searchcmdlen = 0; */
if (!do_search(NULL, c, cmd, 1L, if (c == '/')
SEARCH_HIS | SEARCH_MSG, NULL)) curwin->w_cursor.col = MAXCOL;
{ else
curwin->w_cursor = pos; curwin->w_cursor.col = 0;
cmd = NULL; searchcmdlen = 0;
goto error; if (!do_search(NULL, c, cmd, 1L,
} SEARCH_HIS | SEARCH_MSG, NULL))
lnum = curwin->w_cursor.lnum; {
curwin->w_cursor = pos; curwin->w_cursor = pos;
/* adjust command string pointer */ cmd = NULL;
cmd += searchcmdlen; goto error;
} }
break; lnum = curwin->w_cursor.lnum;
curwin->w_cursor = pos;
/* adjust command string pointer */
cmd += searchcmdlen;
}
break;
case '\\': /* "\?", "\/" or "\&", repeat search */ case '\\': /* "\?", "\/" or "\&", repeat search */
++cmd; ++cmd;
if (*cmd == '&') if (addr_type != ADDR_LINES)
i = RE_SUBST; {
else if (*cmd == '?' || *cmd == '/') EMSG(_(e_invaddr));
i = RE_SEARCH; goto error;
else }
{ if (*cmd == '&')
EMSG(_(e_backslash)); i = RE_SUBST;
cmd = NULL; else if (*cmd == '?' || *cmd == '/')
goto error; i = RE_SEARCH;
} else
{
EMSG(_(e_backslash));
cmd = NULL;
goto error;
}
if (!skip) if (!skip)
{ {
/* /*
* When search follows another address, start from * When search follows another address, start from
* there. * there.
*/ */
if (lnum != MAXLNUM) if (lnum != MAXLNUM)
pos.lnum = lnum; pos.lnum = lnum;
else else
pos.lnum = curwin->w_cursor.lnum; pos.lnum = curwin->w_cursor.lnum;
/* /*
* Start the search just like for the above * Start the search just like for the above
* do_search(). * do_search().
*/ */
if (*cmd != '?') if (*cmd != '?')
pos.col = MAXCOL; pos.col = MAXCOL;
else else
pos.col = 0; pos.col = 0;
if (searchit(curwin, curbuf, &pos, if (searchit(curwin, curbuf, &pos,
*cmd == '?' ? BACKWARD : FORWARD, *cmd == '?' ? BACKWARD : FORWARD,
(char_u *)"", 1L, SEARCH_MSG, (char_u *)"", 1L, SEARCH_MSG,
i, (linenr_T)0, NULL) != FAIL) i, (linenr_T)0, NULL) != FAIL)
lnum = pos.lnum; lnum = pos.lnum;
else else
{ {
cmd = NULL; cmd = NULL;
goto error; goto error;
} }
} }
++cmd; ++cmd;
break; break;
default: default:
if (VIM_ISDIGIT(*cmd)) /* absolute line number */ if (VIM_ISDIGIT(*cmd)) /* absolute line number */
lnum = getdigits(&cmd); lnum = getdigits(&cmd);
} }
for (;;) for (;;)
@@ -4242,7 +4418,40 @@ get_address(ptr, skip, to_other_file)
break; break;
if (lnum == MAXLNUM) if (lnum == MAXLNUM)
lnum = curwin->w_cursor.lnum; /* "+1" is same as ".+1" */ {
switch (addr_type)
{
case ADDR_LINES:
lnum = curwin->w_cursor.lnum; /* "+1" is same as ".+1" */
break;
case ADDR_WINDOWS:
lnum = 0;
for (wp = firstwin; wp != NULL; wp = wp->w_next)
{
lnum++;
if (wp == curwin)
break;
}
break;
case ADDR_ARGUMENTS:
lnum = curwin->w_arg_idx + 1;
break;
case ADDR_LOADED_BUFFERS:
case ADDR_UNLOADED_BUFFERS:
lnum = curbuf->b_fnum;
break;
case ADDR_TABS:
lnum = 0;
for(tp = first_tabpage; tp != NULL; tp = tp->tp_next)
{
lnum++;
if (tp == curtab)
break;
}
break;
}
}
if (VIM_ISDIGIT(*cmd)) if (VIM_ISDIGIT(*cmd))
i = '+'; /* "number" is same as "+number" */ i = '+'; /* "number" is same as "+number" */
else else
@@ -4251,10 +4460,59 @@ get_address(ptr, skip, to_other_file)
n = 1; n = 1;
else else
n = getdigits(&cmd); n = getdigits(&cmd);
if (i == '-') if (addr_type == ADDR_LOADED_BUFFERS
|| addr_type == ADDR_UNLOADED_BUFFERS)
lnum = compute_buffer_local_count(addr_type, lnum, n);
else if (i == '-')
lnum -= n; lnum -= n;
else else
lnum += n; lnum += n;
switch (addr_type)
{
case ADDR_LINES:
break;
case ADDR_ARGUMENTS:
if (lnum < 0)
lnum = 0;
else if (lnum >= ARGCOUNT)
lnum = ARGCOUNT;
break;
case ADDR_TABS:
if (lnum < 0)
{
lnum = 0;
break;
}
c = 0;
for (tp = first_tabpage; tp != NULL; tp = tp->tp_next)
c++;
if (lnum >= c)
lnum = c;
break;
case ADDR_WINDOWS:
if (lnum < 0)
{
lnum = 0;
break;
}
c = 0;
for (wp = firstwin; wp != NULL; wp = wp->w_next)
c++;
if (lnum > c)
lnum = c;
break;
case ADDR_LOADED_BUFFERS:
case ADDR_UNLOADED_BUFFERS:
if (lnum < firstbuf->b_fnum)
{
lnum = firstbuf->b_fnum;
break;
}
if (lnum > lastbuf->b_fnum)
lnum = lastbuf->b_fnum;
break;
}
} }
} while (*cmd == '/' || *cmd == '?'); } while (*cmd == '/' || *cmd == '?');
@@ -6556,6 +6814,10 @@ not_exiting()
ex_quit(eap) ex_quit(eap)
exarg_T *eap; exarg_T *eap;
{ {
win_T *wp;
buf_T *buf;
int wnr;
#ifdef FEAT_CMDWIN #ifdef FEAT_CMDWIN
if (cmdwin_type != 0) if (cmdwin_type != 0)
{ {
@@ -6569,11 +6831,28 @@ ex_quit(eap)
text_locked_msg(); text_locked_msg();
return; return;
} }
if (eap->addr_count > 0)
{
wnr = eap->line2;
for (wp = firstwin; --wnr > 0; )
{
if (wp->w_next == NULL)
break;
else
wp = wp->w_next;
}
buf = wp->w_buffer;
}
else
{
wp = curwin;
buf = curbuf;
}
#ifdef FEAT_AUTOCMD #ifdef FEAT_AUTOCMD
apply_autocmds(EVENT_QUITPRE, NULL, NULL, FALSE, curbuf); apply_autocmds(EVENT_QUITPRE, NULL, NULL, FALSE, curbuf);
/* Refuse to quit when locked or when the buffer in the last window is /* Refuse to quit when locked or when the buffer in the last window is
* being closed (can only happen in autocommands). */ * being closed (can only happen in autocommands). */
if (curbuf_locked() || (curbuf->b_nwindows == 1 && curbuf->b_closing)) if (curbuf_locked() || (buf->b_nwindows == 1 && buf->b_closing))
return; return;
#endif #endif
@@ -6606,7 +6885,7 @@ ex_quit(eap)
need_mouse_correct = TRUE; need_mouse_correct = TRUE;
# endif # endif
/* close window; may free buffer */ /* close window; may free buffer */
win_close(curwin, !P_HID(curwin->w_buffer) || eap->forceit); win_close(wp, !P_HID(wp->w_buffer) || eap->forceit);
#endif #endif
} }
} }
@@ -6668,6 +6947,8 @@ ex_quit_all(eap)
ex_close(eap) ex_close(eap)
exarg_T *eap; exarg_T *eap;
{ {
win_T *win;
int winnr = 0;
# ifdef FEAT_CMDWIN # ifdef FEAT_CMDWIN
if (cmdwin_type != 0) if (cmdwin_type != 0)
cmdwin_result = Ctrl_C; cmdwin_result = Ctrl_C;
@@ -6678,7 +6959,21 @@ ex_close(eap)
&& !curbuf_locked() && !curbuf_locked()
#endif #endif
) )
ex_win_close(eap->forceit, curwin, NULL); {
if (eap->addr_count == 0)
ex_win_close(eap->forceit, curwin, NULL);
else {
for (win = firstwin; win != NULL; win = win->w_next)
{
winnr++;
if (winnr == eap->line2)
break;
}
if (win == NULL)
win = lastwin;
ex_win_close(eap->forceit, win, NULL);
}
}
} }
# ifdef FEAT_QUICKFIX # ifdef FEAT_QUICKFIX
@@ -6804,6 +7099,8 @@ ex_tabonly(eap)
MSG(_("Already only one tab page")); MSG(_("Already only one tab page"));
else else
{ {
if (eap->addr_count > 0)
goto_tabpage(eap->line2);
/* Repeat this up to a 1000 times, because autocommands may mess /* Repeat this up to a 1000 times, because autocommands may mess
* up the lists. */ * up the lists. */
for (done = 0; done < 1000; ++done) for (done = 0; done < 1000; ++done)
@@ -6882,9 +7179,23 @@ tabpage_close_other(tp, forceit)
ex_only(eap) ex_only(eap)
exarg_T *eap; exarg_T *eap;
{ {
win_T *wp;
int wnr;
# ifdef FEAT_GUI # ifdef FEAT_GUI
need_mouse_correct = TRUE; need_mouse_correct = TRUE;
# endif # endif
if (eap->addr_count > 0)
{
wnr = eap->line2;
for (wp = firstwin; --wnr > 0; )
{
if (wp->w_next == NULL)
break;
else
wp = wp->w_next;
}
win_goto(wp);
}
close_others(TRUE, eap->forceit); close_others(TRUE, eap->forceit);
} }
@@ -6906,6 +7217,9 @@ ex_all(eap)
ex_hide(eap) ex_hide(eap)
exarg_T *eap; exarg_T *eap;
{ {
win_T *win;
int winnr = 0;
if (*eap->arg != NUL && check_nextcmd(eap->arg) == NULL) if (*eap->arg != NUL && check_nextcmd(eap->arg) == NULL)
eap->errmsg = e_invarg; eap->errmsg = e_invarg;
else else
@@ -6918,7 +7232,19 @@ ex_hide(eap)
# ifdef FEAT_GUI # ifdef FEAT_GUI
need_mouse_correct = TRUE; need_mouse_correct = TRUE;
# endif # endif
win_close(curwin, FALSE); /* don't free buffer */ if (eap->addr_count == 0)
win_close(curwin, FALSE); /* don't free buffer */
else {
for (win = firstwin; win != NULL; win = win->w_next)
{
winnr++;
if (winnr == eap->line2)
break;
}
if (win == NULL)
win = lastwin;
win_close(win, FALSE);
}
} }
#endif #endif
} }
@@ -8652,7 +8978,7 @@ ex_copymove(eap)
{ {
long n; long n;
n = get_address(&eap->arg, FALSE, FALSE); n = get_address(&eap->arg, eap->addr_type, FALSE, FALSE);
if (eap->arg == NULL) /* error detected */ if (eap->arg == NULL) /* error detected */
{ {
eap->nextcmd = NULL; eap->nextcmd = NULL;

View File

@@ -36,9 +36,11 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
test94.out test95.out test96.out test97.out test98.out \ test94.out test95.out test96.out test97.out test98.out \
test99.out test100.out test101.out test102.out test103.out \ test99.out test100.out test101.out test102.out test103.out \
test104.out test105.out test106.out test107.out \ test104.out test105.out test106.out test107.out \
test_argument_count.out \
test_autoformat_join.out \ test_autoformat_join.out \
test_breakindent.out \ test_breakindent.out \
test_changelist.out \ test_changelist.out \
test_close_count.out \
test_eval.out \ test_eval.out \
test_insertcount.out \ test_insertcount.out \
test_listlbr.out \ test_listlbr.out \
@@ -171,9 +173,11 @@ test104.out: test104.in
test105.out: test105.in test105.out: test105.in
test106.out: test106.in test106.out: test106.in
test107.out: test107.in test107.out: test107.in
test_argument_count.out: test_argument_count.in
test_autoformat_join.out: test_autoformat_join.in test_autoformat_join.out: test_autoformat_join.in
test_breakindent.out: test_breakindent.in test_breakindent.out: test_breakindent.in
test_changelist.out: test_changelist.in test_changelist.out: test_changelist.in
test_close_count.out: test_close_count.in
test_eval.out: test_eval.in test_eval.out: test_eval.in
test_insertcount.out: test_insertcount.in test_insertcount.out: test_insertcount.in
test_listlbr.out: test_listlbr.in test_listlbr.out: test_listlbr.in

View File

@@ -35,9 +35,11 @@ SCRIPTS = test3.out test4.out test5.out test6.out test7.out \
test94.out test95.out test96.out test98.out test99.out \ test94.out test95.out test96.out test98.out test99.out \
test100.out test101.out test102.out test103.out test104.out \ test100.out test101.out test102.out test103.out test104.out \
test105.out test106.out test107.out\ test105.out test106.out test107.out\
test_argument_count.out \
test_autoformat_join.out \ test_autoformat_join.out \
test_breakindent.out \ test_breakindent.out \
test_changelist.out \ test_changelist.out \
test_close_count.out \
test_eval.out \ test_eval.out \
test_insertcount.out \ test_insertcount.out \
test_listlbr.out \ test_listlbr.out \

View File

@@ -57,9 +57,11 @@ SCRIPTS = test3.out test4.out test5.out test6.out test7.out \
test94.out test95.out test96.out test98.out test99.out \ test94.out test95.out test96.out test98.out test99.out \
test100.out test101.out test102.out test103.out test104.out \ test100.out test101.out test102.out test103.out test104.out \
test105.out test106.out test107.out \ test105.out test106.out test107.out \
test_argument_count.out \
test_autoformat_join.out \ test_autoformat_join.out \
test_breakindent.out \ test_breakindent.out \
test_changelist.out \ test_changelist.out \
test_close_count.out \
test_eval.out \ test_eval.out \
test_insertcount.out \ test_insertcount.out \
test_listlbr.out \ test_listlbr.out \

View File

@@ -37,9 +37,11 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
test94.out test95.out test96.out test98.out test99.out \ test94.out test95.out test96.out test98.out test99.out \
test100.out test101.out test102.out test103.out test104.out \ test100.out test101.out test102.out test103.out test104.out \
test105.out test106.out test107.out \ test105.out test106.out test107.out \
test_argument_count.out \
test_autoformat_join.out \ test_autoformat_join.out \
test_breakindent.out \ test_breakindent.out \
test_changelist.out \ test_changelist.out \
test_close_count.out \
test_eval.out \ test_eval.out \
test_insertcount.out \ test_insertcount.out \
test_listlbr.out \ test_listlbr.out \

View File

@@ -4,7 +4,7 @@
# Authors: Zoltan Arpadffy, <arpadffy@polarhome.com> # Authors: Zoltan Arpadffy, <arpadffy@polarhome.com>
# Sandor Kopanyi, <sandor.kopanyi@mailbox.hu> # Sandor Kopanyi, <sandor.kopanyi@mailbox.hu>
# #
# Last change: 2014 Aug 16 # Last change: 2014 Nov 27
# #
# This has been tested on VMS 6.2 to 8.3 on DEC Alpha, VAX and IA64. # This has been tested on VMS 6.2 to 8.3 on DEC Alpha, VAX and IA64.
# Edit the lines in the Configuration section below to select. # Edit the lines in the Configuration section below to select.
@@ -45,7 +45,7 @@
# It fails because VMS does not support this feature yet. # It fails because VMS does not support this feature yet.
# WANT_MZSCH = YES # WANT_MZSCH = YES
# Comment out if you have ODS-5 file system # Comment out if you have ODS-5 file system
# HAVE_ODS5 = YES # HAVE_ODS5 = YES
# Comment out if you have gzip on your system # Comment out if you have gzip on your system
@@ -54,10 +54,10 @@
# Comment out if you have GNU compatible diff on your system # Comment out if you have GNU compatible diff on your system
# HAVE_GDIFF = YES # HAVE_GDIFF = YES
# Comment out if you have GNU compatible cksum on your system # Comment out if you have GNU compatible cksum on your system
# HAVE_CKSUM = YES # HAVE_CKSUM = YES
# Comment out if you have ICONV support # Comment out if you have ICONV support
# HAVE_ICONV = YES # HAVE_ICONV = YES
# Comment out if you have LUA support # Comment out if you have LUA support
@@ -96,9 +96,11 @@ SCRIPT = test1.out test2.out test3.out test4.out test5.out \
test95.out test96.out test98.out test99.out \ test95.out test96.out test98.out test99.out \
test100.out test101.out test103.out test104.out \ test100.out test101.out test103.out test104.out \
test105.out test106.out test107.out \ test105.out test106.out test107.out \
test_argument_count.out \
test_autoformat_join.out \ test_autoformat_join.out \
test_breakindent.out \ test_breakindent.out \
test_changelist.out \ test_changelist.out \
test_close_count.out \
test_eval.out \ test_eval.out \
test_insertcount.out \ test_insertcount.out \
test_listlbr.out \ test_listlbr.out \

View File

@@ -33,9 +33,11 @@ SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \
test94.out test95.out test96.out test97.out test98.out \ test94.out test95.out test96.out test97.out test98.out \
test99.out test100.out test101.out test102.out test103.out \ test99.out test100.out test101.out test102.out test103.out \
test104.out test105.out test106.out test107.out \ test104.out test105.out test106.out test107.out \
test_argument_count.out \
test_autoformat_join.out \ test_autoformat_join.out \
test_breakindent.out \ test_breakindent.out \
test_changelist.out \ test_changelist.out \
test_close_count.out \
test_eval.out \ test_eval.out \
test_insertcount.out \ test_insertcount.out \
test_listlbr.out \ test_listlbr.out \

View File

@@ -741,6 +741,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
530,
/**/ /**/
529, 529,
/**/ /**/

View File

@@ -199,14 +199,22 @@ newwindow:
case Ctrl_Q: case Ctrl_Q:
case 'q': case 'q':
reset_VIsual_and_resel(); /* stop Visual mode */ reset_VIsual_and_resel(); /* stop Visual mode */
do_cmdline_cmd((char_u *)"quit"); STRCPY(cbuf, "quit");
if (Prenum)
vim_snprintf((char *)cbuf + 4, sizeof(cbuf) - 5,
"%ld", Prenum);
do_cmdline_cmd(cbuf);
break; break;
/* close current window */ /* close current window */
case Ctrl_C: case Ctrl_C:
case 'c': case 'c':
reset_VIsual_and_resel(); /* stop Visual mode */ reset_VIsual_and_resel(); /* stop Visual mode */
do_cmdline_cmd((char_u *)"close"); STRCPY(cbuf, "close");
if (Prenum)
vim_snprintf((char *)cbuf + 5, sizeof(cbuf) - 5,
"%ld", Prenum);
do_cmdline_cmd(cbuf);
break; break;
#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
@@ -235,7 +243,11 @@ newwindow:
case 'o': case 'o':
CHECK_CMDWIN CHECK_CMDWIN
reset_VIsual_and_resel(); /* stop Visual mode */ reset_VIsual_and_resel(); /* stop Visual mode */
do_cmdline_cmd((char_u *)"only"); STRCPY(cbuf, "only");
if (Prenum > 0)
vim_snprintf((char *)cbuf + 4, sizeof(cbuf) - 4,
"%ld", Prenum);
do_cmdline_cmd(cbuf);
break; break;
/* cursor to next window with wrap around */ /* cursor to next window with wrap around */