📄 less.man
字号:
LESS(1) LESS(1) display at the specified line number (however, see the caveat under the "g" command above). If the option starts with ++, the initial command applies to every file being viewed, not just the first one. The + command described previously may also be used to set (or change) an initial command for every file.KKEEYY BBIINNDDIINNGGSS You may define your own _l_e_s_s commands by using the program _l_e_s_s_k_e_y (1) to create a file called ".less" in your home directory. This file specifies a set of command keys and an action associated with each key. See the _l_e_s_s_k_e_y man- ual page for more details.NNAATTIIOONNAALL CCHHAARRAACCTTEERR SSEETTSS There are three types of characters in the input file: normal characters can be displayed directly to the screen. control characters should not be displayed directly, but are expected to be found in ordinary text files (such as backspace and tab). binary characters cannot be displayed directly and are not expected to be found in text files. By default, _l_e_s_s uses the ASCII character set. In the ASCII character set, characters with values between 128 and 255 are treated as binary. The LESSCHARSET environ- ment variable may be used to select another character set. If it is set to the value "latin1", the ISO 8859/1 charac- ter set is assumed. Latin-1 is the same as ASCII, except characters between 128 and 255 are treated as normal char- acters. The only valid values for LESSCHARSET currently are "ascii" and "latin1". In special cases, it may be desired to tailor _l_e_s_s to use a character set other than the ones definable by LESS- CHARSET. In this case, the environment variable LESS- CHARDEF can be used to define a character set. It should be set to a string where each character in the string rep- resents one character in the character set. The character "." is used for a normal character, "c" for control, and "b" for binary. A decimal number may be used for repeti- tion. For example, "bccc4b." would mean character 0 is binary, 1, 2 and 3 are control, 4, 5, 6 and 7 are binary, and 8 is normal. All characters after the last are taken to be the same as the last, so characters 9 through 255 13LESS(1) LESS(1) would be normal. (This is an example, and does not neces- sarily represent any real character set.) Setting LESSCHARDEF to "8bcccbcc18b95.b" is the same as setting LESSCHARSET to "ascii". Setting LESSCHARDEF to "8bcccbcc18b95.33b." is the same as setting LESSCHARSET to "latin1". Control and binary characters are displayed in blinking mode. Each such character is displayed in caret notation if possible (e.g. ^A for control-A). Caret notation is used only if inverting the 0100 bit results in a normal printable character. Otherwise, the character is dis- played as an octal number preceded by a backslash. This octal format can be changed by setting the LESSBINFMT environment variable to a printf-style format string; the default is '\%o'. The blinking mode display of control and binary characters can be changed or disabled by pre- ceding the LESSBINFMT format string with a "*" and one character to select the mode: "*k" is blinking, "*d" is bold, "*u" is underlined, and "*n" is normal (no special display attribute). For example, if LESSBINFMT is "*u[%x]", binary characters are displayed in underlined hexadecimal surrounded by brackets.PPRROOMMPPTTSS The -P option allows you to tailor the prompt to your preference. The string given to the -P option replaces the specified prompt string. Certain characters in the string are interpreted specially. The prompt mechanism is rather complicated to provide flexibility, but the ordi- nary user need not understand the details of constructing personalized prompt strings. A percent sign followed by a single character is expanded according to what the following character is: %b_X Replaced by the byte offset into the current input file. The b is followed by a single character (shown as _X above) which specifies the line whose byte offset is to be used. If the character is a "t", the byte offset of the top line in the display is used, an "m" means use the middle line, a "b" means use the bottom line, a "B" means use the line just after the bottom line, and a "j" means use the "target" line, as specified by the -j option. %B Replaced by the size of the current input file. %E Replaced by the name of the editor (from the EDITOR environment variable). See the discussion of the LESSEDIT feature below. 14LESS(1) LESS(1) %f Replaced by the name of the current input file. %i Replaced by the index of the current file in the list of input files. %l_X Replaced by the line number of a line in the input file. The line to be used is determined by the _X, as with the %b option. %L Replaced by the line number of the last line in the input file. %m Replaced by the total number of input files. %p_X Replaced by the percent into the current input file. The line used is determined by the _X as with the %b option. %s Same as %B. %t Causes any trailing spaces to be removed. Usually used at the end of the string, but may appear any- where. %x Replaced by the name of the next input file in the list. If any item is unknown (for example, the file size if input is a pipe), a question mark is printed instead. The format of the prompt string can be changed depending on certain conditions. A question mark followed by a sin- gle character acts like an "IF": depending on the follow- ing character, a condition is evaluated. If the condition is true, any characters following the question mark and condition character, up to a period, are included in the prompt. If the condition is false, such characters are not included. A colon appearing between the question mark and the period can be used to establish an "ELSE": any characters between the colon and the period are included in the string if and only if the IF condition is false. Condition characters (which follow a question mark) may be: ?a True if any characters have been included in the prompt so far. ?b_X True if the byte offset of the specified line is known. ?B True if the size of current input file is known. ?e True if at end-of-file. 15LESS(1) LESS(1) ?f True if there is an input filename (that is, if input is not a pipe). ?l_X True if the line number of the specified line is known. ?L True if the line number of the last line in the file is known. ?m True if there is more than one input file. ?n True if this is the first prompt in a new input file. ?p_X True if the percent into the current input file of the specified line is known. ?s Same as "?B". ?x True if there is a next input file (that is, if the current input file is not the last one). Any characters other than the special ones (question mark, colon, period, percent, and backslash) become literally part of the prompt. Any of the special characters may be included in the prompt literally by preceding it with a backslash. Some examples: ?f%f:Standard input. This prompt prints the filename, if known; otherwise the string "Standard input". ?f%f .?ltLine %lt:?pt%pt\%:?btByte %bt:-... This prompt would print the filename, if known. The file- name is followed by the line number, if known, otherwise the percent if known, otherwise the byte offset if known. Otherwise, a dash is printed. Notice how each question mark has a matching period, and how the % after the %pt is included literally by escaping it with a backslash. ?n?f%f .?m(file %i of %m) ..?e(END) ?x- Next\: %x..%t This prints the filename if this is the first prompt in a file, followed by the "file N of N" message if there is more than one input file. Then, if we are at end-of-file, the string "(END)" is printed followed by the name of the next file, if there is one. Finally, any trailing spaces are truncated. This is the default prompt. For refer- ence, here are the defaults for the other two prompts (-m and -M respectively). Each is broken into two lines here 16LESS(1) LESS(1) for readability only. ?n?f%f .?m(file %i of %m) ..?e(END) ?x- Next\: %x.: ?pB%pB\%:byte %bB?s/%s...%t ?f%f .?n?m(file %i of %m) ..?ltline %lt?L/%L. :byte %bB?s/%s. . ?e(END) ?x- Next\: %x.:?pB%pB\%..%t And here is the default message produced by the = command: ?f%f .?m(file %i of %m) .?ltline %lt?L/%L. . byte %bB?s/%s. ?e(END) :?pB%pB\%..%t The prompt expansion features are also used for another purpose: if an environment variable LESSEDIT is defined, it is used as the command to be executed when the v com- mand is invoked. The LESSEDIT string is expanded in the same way as the prompt strings. The default value for LESSEDIT is: %E ?lm+%lm. %f Note that this expands to the editor name, followed by a + and the line number, followed by the file name. If your editor does not accept the "+linenumber" syntax, or has other differences in invocation syntax, the LESSEDIT vari- able can be changed to modify this default.EENNVVIIRROONNMMEENNTT VVAARRIIAABBLLEESS COLUMNS Sets the number of columns on the screen. Takes precedence over the number of columns specified by the TERM variable. EDITOR The name of the editor (used for the v command). HOME Name of the user's home directory (used to find a .less file). LESS Flags which are passed to _l_e_s_s automatically. LESSBINFMT Format for displaying non-printable, non-control characters. LESSCHARDEF Defines a character set. LESSCHARSET Selects a predefined character set. LESSEDIT Editor prototype string (used for the v command). 17LESS(1) LESS(1) See discussion under PROMPTS. LESSHELP Name of the help file. LINES Sets the number of lines on the screen. Takes precedence over the number of lines specified by the TERM variable. SHELL The shell used to execute the ! command, as well as to expand filenames. TERM The type of terminal on which _l_e_s_s is being run.SSEEEE AALLSSOO lesskey(1)WWAARRNNIINNGGSS The = command and prompts (unless changed by -P) report the line number of the line at the top of the screen, but the byte and percent of the line at the bottom of the screen. If the :e command is used to name more than one file, and one of the named files has been viewed previously, the new files may be entered into the list in an unexpected order. The handling of national character sets is nonstandard as well as insufficient for multibyte characters. It will probably change in a later release. 18
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -