WinVi

Package: WA2L/WinTools
Section: General Commands (1)
Updated: 30 May 2016
Index Return to Main Contents

Table of Contents

Compatibility with Notepad
vi - File and Display Commands
vi - Positioning
vi - Editing Text
vi - Insert Mode
vi - Cursor Movements
ex - Commands
ex - Options
Search Dialog
Settings
Settings - Profile
Settings - File Type
Settings - Display
Settings - Edit
Settings - Files
Settings - Keyboard Macros
Settings - Shell
Settings - Colors
Settings - Fonts
Settings - Print
Settings - Language


Compatibility with Notepad

WinVi handles files of (nearly) unlimited size without consuming lots of memory. There are a few special characteristics in order to offer maximum compatibility with Windows Notepad:

^ To table of contents

vi - File and Display Commands

These commands are used in command mode (edit mode). From insert, replace, and ex command mode, you enter this mode by typing the {Esc} button.

Optional input is denoted as text in square brackets (can be left away), curly brackets indicate special keys. Sometimes, identifiers for designated input are set in angle brackets for highlighting. Alternative input are separated by a bar, as in |.

Command   Function
^L   Refresh text display
^G   Display file name, current line and total number of lines (:={Enter} shows the current line number only)
^^   Open previously edited file
:args{Enter}   Show list of files to edit (argument list)
:n{Enter}   Open next file in the argument list ("next")
:n files{Enter}   Replace argument list by the specified files and opens the first one ("next"). Within the file list, the wildcard characters * and ? can be used.
:rew{Enter}   Jump back to first file of argument list ("rewind")
:e [{TAB}|file]{Enter}   Open file ("edit"); without specification of a file, the current file is read again from disk. The {Tab} key can be used to get a list of files ({Tab} = tabulator = {->|}); When dragging files from the Windows Explorer on a WinVi window, these files are appended to the argument list and the first one is opened.
  ! With :n!, :e!, or :q!, a warning will be suppressed noting that the working buffer has not been saved. Any changes will be lost and the requested file is opened immediately, for :q!, vi is closed immediately.
  %
#
In the filename part of the ex command line (after ":e", ":w", etc.), % is replaced by the name of the current file, # by the name of the file, which has been previously edited. In WinVi, the special meaning can be bypassed by doubling this character.
:[.]r {TAB}|file{Enter}   Reads the text of the file ("read") and inserts it behind the current line (".") or a specified line. When specifying line 0, the text is inserted at the beginning of the working buffer.
:f file{Enter}   "file" changes the current file name (saved in %), e. g. for :w or :e without an explicit file name.
:[1,$]w [>>][{TAB}|file]{Enter}   Writes lines of the working buffer into a file ("write"). The default line range is the entire file ($ means "the last line"). With >>, the text is appended to the file.
:[1,$]wq [>>][{TAB}|file]{Enter}   Same as :w, WinVi terminates after successfully writing the file.
:[1,$]x [>>][{TAB}|file]{Enter}   ("eXit") same as :wq, but the file will only be written if the working buffer has changed.
  ! Behind :w, :wq, or :x, any warnings about write protection or file existence are suppressed. The file is written in any case even if the read-only attribute is set.
:q   Close WinVi without saving ("quit")
ZZ   Shortcut for :x{Enter} - the working buffer will be written into the current file and WinVi will be closed
:cd [..\|{TAB}|dir]{Enter}   Changes the current working directory (.. is the next higher directory) or shows the current directory if used without parameter.
:vi [{TAB}|file]{Enter}   Opens a file in a new WinVi window. Without a parameter, an empty new window is created.
z[n]{Enter}   Changes the window height to the specified number of lines (alternative: :set lines=n{Enter})
:ve   Shows the vi Version
     
^]   Searches the word at the cursor position in the tags file and jumps to the appropriate file and position. "tags" is a text file consisting of lines each describing the definition of a word. Three tab-separated fields contain name, filename, and an ex command to locate the identifier within the file.
^T   Jumps to the previous position in the tags stack.

^ To table of contents

vi - Positioning

Command Function
[n]^E Scroll up the display by one line (n lines). The cursor remains in the current display line as long as scrolling can be performed.
[n]^Y Scroll down the display by one line (n lines). The cursor remains in the current display line as long as scrolling can be performed.
[n]^D Scroll up the display by half a window (n times). The cursor keeps its screen position.
[n]^U Scroll down the display by half a window (n times). The cursor keeps its screen position.
[n]^F Scroll up the display by a full window (n times / "forward"). The cursor keeps its screen position.
[n]^B Scroll down the display by a full window (n times / "back"). The cursor keeps its screen position.
z[n]{Enter} Move the current line and the cursor to the top. The window size can be set to n lines.
z[n]. Move the current line and the cursor to the center of the window. The window size can be set to n lines.
z[n]- Move the current line and the cursor to the bottom. The window size can be set to n lines.

^ To table of contents

vi - Editing Text

Command Function
[n]i[text]{ESC} text is inserted before the cursor position (n times) ("Insert mode" after i I a A s S)
[n]I[text]{ESC} text is inserted at the start of the current line (n times)
[n]a[text]{ESC} text is inserted behind the cursor position (n times)
[n]A[text]{ESC} text is inserted at the end if the current line (n times)
[n]x delete character at the cursor position on the current line (or n characters from the cursor position)
[n]X delete (n) character(s) left of the current cursor position
[n]J join n lines (default n = 2). A space is inserted at each former newline position if the preceding character is not one of ( { [ space or tab and the following character (after indenting tabs and spaces) is not ) } ] . , ; or :
["{x}][n]d<move> delete text up to the end of the (n-th) cursor movement <move> (and save it in the named buffer "x), if used with <move> w, W ("delete word") or `{x} the deleted text ends before the cursor movement; additionally, the previously deleted text is available in the unnamed buffer and can be inserted simply with P or p.
["{x}][n]D corresponds to d$ (delete to the end of line)
["{x}][n]dd delete entire line(s). This is also put into the named buffer "1, the old contents of buffer "1 are moved into buffer "2 etc. up to "9). If specified, the deleted text is also saved in the named buffer "x (see also copy text)
[n]r{x} replace one (or n) character(s) in the current line by the character "x", starting at the cursor position. If count exceeds the number of remaining characters on the line, further characters are appended.
[n]R[text]{ESC} replace (n times) the text in the current line at the cursor position by "text" (replace mode)
[n]~ change case (n times) within the current line starting at the cursor position. When used for non-ASCII characters, the result depends on the current character set.
[n]c<move>[text]{ESC} change text up to the end of the (n-th) cursor movement <move> to "text"; the specification of w or W is treated as ce or cE if the cursor is not positioned on a white space.
[n]C[text]{ESC} corresponds to c$ (change to the end of the line)
[n]!<move><cmd>{Enter} the text up to the end of the (n-th) cursor movement <move> is replaced by the output of the external command <cmd>, the selected text is sent as standard input to the started program <cmd> (e. g. sort or grep)
[n]s[text]{ESC} replace (n) character(s) within the current line by "text" ("substitute"); corresponds to cl
[n]S[text]{ESC} replace line(n) by "text"
[n]> <move> indent line(s) up to the cursor movement, all lines in between are indented by the number of spaces specified in shiftwidth= (default 4 spaces), if the resulting number of spaces reach the value of tabstop= setting, the spaces are replaces by the appropriate number of tabs.
[n]>> line(s) are indented.
[n]< <move> (n) line(s) up to the cursor movement <move> are unindented (by up to shiftwidth= spaces).
[n]<< unindent line(s).
Copy and Paste
["{x}][n]y<move> copy ("yank") the text up to the end of the (n-th) cursor movement <move> (into the named buffer "x). "x can be any letter, if uppercase letters are used (e.g. "Xy$), the text is appended to the previous contents of the buffer (also with d D). As with d and c, y`{x} yanks up to the position before the mark.
["{x}][n]Y save entire line(s)
["{x}][n]yy corresponds to Y
["{x}][n]p insert ("put") saved text (from buffer "x) behind the position (n times), entire lines are inserted behind the next line end.
["{x}][n]P insert text before the cursor or before the current line.
Undo and Repetitions
u undo last change
[n]. repeat last changing operation (with new repeat factor or line number n); WinVi can undo several changes by repeating u with ".". When typing u again, the last undo is reverted, i.e. the original change is done again ignoring any number specification before u.
"{m}[n]p insert the text of the m-th previous deletion or yanking of entire lines (n times) after the current line (P - before the current line).
& repeat the last substitute command (:s - see ex commands)

^ To table of contents

vi - Insert Mode

^H   or   {Bksp}
delete last typed character (within the current line only)
^W
delete last typed word
^D
unindent the current line by   shiftwidth=   character positions
0^D
unindent current line as far as possible
^T
indent current line by   shiftwidth=   character positions
{Esc}
exit insert mode, continue in command mode

^ To table of contents

vi - Cursor Movements

[n]k or {Up} or ^P
(n lines) up
[n]h or {<-}
(n characters) to the left
[n]l or {->} or {Space}
(n characters) to the right
[n]j or {Down} or ^N
(n lines) down
[n]-
position to the first printable character (i.e. the first non-space character) of the preceding (n-th) line
[n]+ or {Enter}
position to the first printable character of the (n-th) following line

0
(zero) start of line
[n]^
first printable character behind the (n-th) preceding start of line
[n]| first (n-th) character column
[n]$ (n-th) following end of line

[n]G
last (n-th) line of file, first printable character
``
jump back to the position before the previous jump with absolute address
''
jump back to the start of the line of the previous absolute jump
[n]H
top (n-th) screen line, first printable character
M
center screen line, first printable character
[n]L
bottom (n-th) screen line, first printable character

Searching Specific Characters
[n]f{x} skip to the (n-th) following occurrence of character "x" on the current line ("find")
[n]F{x} skip to the preceding (n-th) occurrence of character "x" on the current line
[n]t{x} position before the (n-th) following occurrence of "x" on the current line ('till x)
[n]T{x} position behind the (n-th) preceding occurrence of "x" on the current line
[n]; repeat the previous f F t T positioning (n times)
[n],
repeat the previous f F t T positioning (n times), but in opposite direction
%
search for the opposite brace, parenthesis, or square bracket { ( [ ] ) }

Word Boundaries
[n]w
(n-th) following start of a word ( = sequence of letters, digits, underline or sequence of printable characters not of this group)
[n]W
(n-th) following start of a word behind a space, tab, or line separator
[n]e (n-th) following end of a word
[n]E (n-th) following end of a word behind a space, tab, or line separator
[n]b (n-th) preceding start of a word
[n]B (n-th) preceding start of a word behind a space, tab, or line separator

Position Markers
m{x} mark the current position with letter "x"
`{x} jump to marked position "x"
'{x} jump to the first printable character of the line containing mark "x"
`` jump back to the previous jump position (before entering `x, 'x, ``, or '')
'' jump to the first printable character of the line of the previous jump position

Search for Character Strings
[n]/[expr][/]{Enter} search for the (n-th) following occurrence of a character string, matching <expr> ("RE" - "regular expression"). If <expr> is left empty, the previously specified expression is used again.
[n]?[expr][?]{Enter} search for the (n-th) preceding occurrence
[n]n search for the (n-th) occurrence of the previously searched expression ("next") in the original direction
[n]N search for the (n-th) occurrence of the previously searched expression in the opposite original direction
`` jump back to the position where the last search started
'' jump back to the first printable character of the line where the last search started

Elements for Regular Expressions
^ start of line
$ end of line
. match any character except end-of-line characters (CR-LF, CR, LF, RS, NUL)
\ "quotes" the following character (disables or enables the special meaning of it). The affected characters are ^ $ . * [ ] \ and / ? for search operations.
\< start of word (see word boundaries)
\> end of word
[list] a character of the list
[^list] a character not being part of the list
[x-y] a character within the range from "x" to "y" (Example: [0-9A-Za-z_])
* defines a sequence of any length of the preceding character (e. g. ".*"=any sequence of any non-newline characters including the empty string)
\(expr[\|expr]\)
(search for one of the alternative expressions), select the matched string for reference in substitution strings in :s
\x
WinVi-specific: match the letter x exactly as typed disregarding the current ignorecase setting (see ex - Options)
\%hh
WinVi-specific: the character with the specified hexadecimal encoding <hh> (also matches end-of-line characters)

^ To table of contents

ex - Commands

In WinVi, a list of available ex commands can be requested by typing the tab key after the initial colon. Generally, the tab key can be used to automatically complete the current argument on the ex command line. This is especially useful for expanding file names.

File commands have been discussed earlier and will not repeated here.

Command   Function
:[.[,.]]s/expr[/rep[/[g][c]]]{Enter}
Substitution - replace (between lines m and n, default is current line) the first (or all if g is specified - "global") <expr> matching string by <rep> (empty string if not specified). Instead of "/", any other special character can be used as separator.
c requests a confirmation before each substitution.
:[.[,.]]s [g][c]{Enter}
Repeat the last substitution with the previous values for <expr> and <rep>
Line numbers: . current line

+|- [n]
each specified line number can be incremented or decremented by appending   +|- [n]  , if n is missing, an increment/decrement value of 1 is assumed

n n-th line

$ last line of file (use shortcut % for 1,$)

'{x} line containing marker "x"

/expr/ next line matching <expr> starting the search at the following line

?expr? next preceding line matching <expr> starting the search at the preceding line
<rep> (replacement string): & the string matched with <expl>

\n the string matching the n-th with  \( \)  surrounded search pattern (number between 1 and 9)
Control codes:
^V
disables the special behaviour of the following control key and prompts the hexadecimal special notation in the ex command line. Example for the replacement of all Unix end-of-lines by Windows line ends in WinVi: When typing :%s/^.*{^V}{^J}/&{^V}{^M}{^V}{^J}/{Enter}, the command :%s/^.*\%0a/&\%0d\%0a/ is executed.
:[.[,.]]d{Enter}
delete the specified line(s) (corresponds to  dd)
:.{Enter}
place the cursor on the first printable character of the specified line

^ To table of contents

ex - Options

Boolean values are changed with the command   :set <option>{Enter}   for activating and   :set no<option>{Enter}   for deactivating the specified flag, other options (denoted with  = ) expect numerical or string values. Many options can be abbreviated.

In WinVi, a list of available options is displayed when typing   :set{Space}{Tab}  .


all
display of all options and its current settings. In WinVi, the Settings dialog is opened.
ai autoindent 0 automatic indenting as in the preceding line, after O (Open) as in the following line
aw autowrite 0 automatic save of changes in the current file when opening another file
ic ignorecase 1 ignore upper or lower case when searching (also applies to national special characters like accented vowels)

magic 1 special handling of   . * ? [ ]   when searching (if nomagic is set, the special meaning is activated by a preceding \)

list 0 display of tab characters as   ^I   and unconditional display of end-of-line codes
nu number 0 display of line numbers
ro readonly 0 display a warning when trying to save the current file
sm showmatch 0 when inserting a closing parenthesis, brace or square bracket, the corresponding opening parenthesis is highlighted for one second,
when positioning the cursor in command mode on any parenthesis, brace or square bracket, the corresponding one is highlighted for one second.

terse 0 some status messages are displayed in short form
vo viewonly 0 prevents changing the current buffer (in WinVi only)
ws wrapscan 1 searching wraps around end/start of file
am ansimode 1 WinVi-specific: treating the current file as ANSI text
dm dosmode 0 WinVi-specific: treating the current file as DOS text with OEM character set
hm hexmode 0 WinVi-specific: display in hexadecimal mode
co= columns=
set width of window to specified number of characters

lines=
set the window height to the specified number of lines
scroll= 0 maximum number of line scroll operations used for positioning, the value 0 is replaced by the number of visible lines - 2
sw= shiftwidth= 4 number of space positions inserted or deleted when indenting/unindenting with   > < ^T ^D   at the start of a line
ts= tabstop= 8 number of character positions used for displaying a tab

tags=
list of file names used for the  :tag  command

tmpdirectory=
directory used for temporary files (default: system TEMP folder)





ansicodepage=
name of the Windows NLS resource used for display and input in the corresponding mode (default is depending on the Windows system or the regional settings), see also Character Tables in section Settings - File Type

oemcodepage=
see above

^ To table of contents

Search Dialog

This dialog appears when typing {Alt+F3} or when choosing the corresponding toolbar button or menu entry. The search dialog contains the following fields:

^ To table of contents

Settings

The contents of the tab sheets is described in the following sections. Outside of the tab sheets, there is a Profile selection dropdown box at the upper border of the dialog for file specific settings. When selecting a different profile, all settings are changed as previously saved for that profile. Creating and automatic selection of profiles is described in the next chapter. At the bottom of the dialog, there are selection controls for permanently saving the current settings and the usual buttons for Apply, OK and Cancel.

Settings - Profile

Profiles can be set up if different settings should be applied to files with different extensions or paths.
The settings of a particular profile are automatically loaded when a file with a corresponding path or extension is opened or when the path or name of the current file changes and relates to a different profile afterwards.
File name comparison is case insensitive. For yet unnamed files or files without a full path, the current working folder is used to select an appropriate profile.

If several profiles can be found for the current file, the best matching profile will be used. This search determines the first profile out of the following list:

  1. first profile with empty extension field and a longest possible match of the path, if there is no other profile matching at least the same path length and at least one extension, otherwise
  2. first profile matching the path as far as possible and matching one extension, otherwise
  3. first profile with empty extension and matching the path as far as possible, otherwise
  4. first profile with an empty path matching one extension, otherwise
  5. first profile except "(default)" with empty path and extension fields, otherwise
  6. the Default profile.
The steps for creating a new profile are:
  1. First, select a profile with the settings that are most in common with the new profile settings. This prevents exhausting adopting the same settings again. When creating your first profile, only the "(default)" profile is available. When selecting another profile, the relating settings are loaded immediately.
  2. Push button "Create new profile..." in the profile tab sheet of the settings dialog and
  3. enter a name for identifying the new profile, then push "OK".
  4. Now you can enter paths and/or file name extensions into the two fields, which should be used to select the new profile. Multiple specifications should be separated by comma or semicolon.
  5. The checkbox "Permanent setting as default for this dialog box" specifies if the bottom "Permanent setting" option is activated by default. This can also be set for the Default profile.
  6. The current settings in the other tab sheets still contain the values of the previously loaded profile. You can change them now as desired.
  7. Finally, the new settings are saved and applied by selecting "Permanent setting" and clicking the "OK" button.

^ To table of contents

Settings - File Type

This dialog affects the procedure for opening a file. These options do not change the current operating mode.

^ To table of contents

Settings - Display

In this dialog, the visual appearance can be modified.

^ To table of contents

Settings - Edit

In this dialog, you can change settings for editing.

^ To table of contents

Settings - Files

This dialog offers file specific settings.

^ To table of contents

Settings - Keyboard Macros

In this dialog you can change the keyboard settings.

^ To table of contents

Settings - Shell

In this dialog you can change the settings for external shell commands.

^ To table of contents

Settings - Colors

In this dialog you can change the colors used for the text presentation in the main window.

^ To table of contents

Settings - Fonts

In this dialog you can choose the fonts used for text display in the main window area.

^ To table of contents

Settings - Print

This dialog contains all settings for printing.

^ To table of contents

Settings - Language

Select the language used for menus, dialog boxes, and other messages in the status bar.
The 32-bit version of WinVi sometimes shows messages provided by the system. These messages are not translated.

^ To table of contents