1- *cmdline.txt* For Vim version 9.1. Last change: 2025 Sep 10
1+ *cmdline.txt* For Vim version 9.1. Last change: 2025 Sep 15
22
33
44 VIM REFERENCE MANUAL by Bram Moolenaar
@@ -745,16 +745,17 @@ Some Ex commands accept a line range in front of them. This is noted as
745745
746746The basics are explained in section | 10.3 | of the user manual.
747747
748- In | Vim9 | script a range needs to be prefixed with a colon to avoid ambiguity
748+ In | Vim9 | script, a range needs to be prefixed with a colon to avoid ambiguity
749749with continuation lines. For example, "+" can be used for a range but is also
750750a continuation of an expression: >
751751 var result = start
752752 + print
753- If the "+" is a range then it must be prefixed with a colon: >
754- var result = start
753+ < If the "+" is a range, as it is here, in Vim9 script it must be prefixed
754+ with a colon (otherwise you will get error | E1050 | ): >
755+ vim9script
755756 :+ print
756757<
757- *:,* *:;*
758+ *:,* *:;*
758759When separated with ';' the cursor position will be set to that line
759760before interpreting the next line specifier. This doesn't happen for ','.
760761Examples: >
@@ -764,36 +765,86 @@ Examples: >
764765< from line 5 till match with "that line" after line 5.
765766
766767The default line specifier for most commands is the cursor position, but the
767- commands ":write" and ":global" have the whole file (1,$) as default.
768-
769- If more line specifiers are given than required for the command, the first
770- one(s) will be ignored.
771-
768+ commands ":write" and ":global" have the whole buffer (1,$) as default.
769+
770+ If more line specifiers are given than required for the command, when comma
771+ separated, the leftmost one(s) will be ignored, e.g., the -2,+ in this: >
772+ :-2,+,-2,. print
773+ < When semicolon separated, the leftmost specifier to the penultimate one are
774+ summed, e.g., -4 + 3 - 1 = -2, in this: >
775+ :-4;+3;-1;+2 print
776+ <
772777Line numbers may be specified with: *:range* *{address}*
773778 {number} an absolute line number *E1247*
774- . the current line *:.*
775- $ the last line in the file *:$*
776- % equal to 1,$ (the entire file) *:%*
777- 't position of mark t (lowercase) *:'*
778- 'T position of mark T (uppercase); when the mark is in
779- another file it cannot be used in a range
780- /{pattern} [/] the next line where {pattern} matches *:/*
779+ . the current line *:.*
780+ $ the last line of the buffer *:$*
781+ % equal to 1,$ (the entire buffer) *:%*
782+ * equal to '<,'> (the lines of the last
783+ selected Visual area; see | :star | below)
784+ 'x the line of the position of mark x *:'x*
785+ (where x is any {a-z} mark)
786+ 'X the line of the position of mark X *:'X*
787+ (where X is any {A-Z0-9} mark, though
788+ when X is in another buffer it cannot
789+ be used in a range)
790+ '[ the first line of the most recent *:'[*
791+ change or yank
792+ '] the last line of the most recent *:']*
793+ change or yank
794+ '< the first line of the most recently *:'<*
795+ selected Visual area
796+ '> the last line of the most recently *:'>*
797+ selected Visual area
798+ '' the line of the position before the *:''*
799+ latest jump, or where the last "m'"/"m`"
800+ command was given (though '' is 1 if it
801+ isn't in the current buffer)
802+ '" the line of the cursor position when *:'quote*
803+ last exiting the buffer
804+ '^ the line of the cursor position the *:'^*
805+ last time Insert mode was stopped
806+ '. the line of the cursor position when the *:'.*
807+ buffer was last changed
808+ '( the line of the first character of the *:'(*
809+ current sentence
810+ ') the line of the first character after *:')*
811+ the end of the current sentence
812+ '{ the first empty line before the *:'{*
813+ paragraph containing the cursor
814+ '} the first empty line after the *:'}*
815+ paragraph containing the cursor
816+ /{pattern} [/] the next line where {pattern} matches *:/*
781817 also see | :range-pattern | below
782- ?{pattern} [?] the previous line where {pattern} matches *:?*
818+ ?{pattern} [?] the previous line where {pattern} matches *:?*
783819 also see | :range-pattern | below
784- \/ the next line where the previously used search
785- pattern matches
786- \? the previous line where the previously used search
787- pattern matches
788- \& the next line where the previously used substitute
789- pattern matches
820+ \/ the next line where the most recent
821+ search pattern matches
822+ \? the previous line where the most recent
823+ search pattern matches
824+ \& the next line where the most recent
825+ substitute pattern matches
826+
827+ Note: "next line" and "previous line" do not include matches appearing
828+ in the current line.
790829
791830 *:range-offset*
792- Each may be followed (several times) by '+' or '-' and an optional number.
793- This number is added or subtracted from the preceding line number. If the
794- number is omitted, 1 is used. If there is nothing before the '+' or '-' then
795- the current line is used.
796- *:range-closed-fold*
831+ Each line specifier may be followed by one or more '+' or '-' and an optional
832+ number. That value is added or subtracted from the preceding line number.
833+ So, for example, 'x+2 is two lines after the line containing mark x. If the
834+ number is omitted, +1 is used for each '+' and -1 for each '-' so, e.g., 'x++
835+ and 'x+2 are synonymous. If there is nothing before the '+' or '-', for the
836+ first line number in [range] the current line is used as the relative
837+ starting point. So, -,. means, "the line before the current line to the
838+ current line". The value of the second line number in [range] depends on
839+ whether a comma or semicolon separates the line numbers (see | :, | and | :; | ).
840+ Examples: If the cursor is within the line below this one, any of these
841+ commands will print the tag line ":range-offset" and the line, "Each...": >
842+ :-11;+1 print
843+ :-----------,-10 print
844+ :?Each line?-;+ print
845+ :'{+,'{+2 print
846+ :'{+1;')-1 print
847+ < *:range-closed-fold*
797848When a line number after the comma is in a closed fold it is adjusted to the
798849last line of the fold, thus the whole fold is included.
799850
0 commit comments