D:\JavaFrameworks\InsuranceFramework\src\java\unix_code\VI_EDITOR.properties |
1 VI EDITOR 2 3 VI (short for Visual Editor) is an editor used in the UNIX environment to create text files and edit text. 4 The following is the listing of commands within VI. 5 ************************************************************************* 6 FILE: 7 8 After you log in and enter your password a $ appears on the screen with the cursor waiting for input as follows: 9 10 $_ 11 12 $vi file_name.ext<CR> /* edit a file */ 13 Example: $vi my_program.c<CR> 14 15 <ESCAPE> /* To get to command mod */ 16 :q<CR> /* To quit vi & exit to UNIX shell */ 17 18 <ESC> /* To get to command mod */ 19 :w<CR> /* Save file & still within vi */ 20 21 <ESC> /* To save & quit vi editor. */ 22 :wq<CR> or ZZ<CR> 23 24 :w! file_name<CR> /* To over write an exiting file. */ 25 26 :q! /* Quit the editor WITHOUT save if you changed file. */ 27 28 <:> colon /* To return to vi file commands mode */ 29 30 :sh /* Temporary return to the UNIX shell. It is the same as :! but behaves differently on the 31 screen. To exit either press ^d(control d) or exit. You can change directory also. */ 32 33 :! /* Escape the editor command and return to shell command without write(save) the buffer. */ 34 35 :.w new_file<CR> /* To write the current line to the file (new_file). 36 "." (period) is used as an address. 37 A file named new_file is created that has the current line only. */ 38 39 :23,55 w my_file<CR> /* Create a new file called my_file with line 23 through 55 written to it. */ 40 41 :.=<CR> /* To find the line number of the current line. */ 42 43 :n<CR> /* Move the cursor to line number n. */ 44 45 :.,$d<CR> /* Delete all lines from the current line to the end of the buffer. */ 46 47 48 TEXT: 49 50 Insert Command (i,I): ******************************************* 51 52 <i> /* To insert text at the cursor position you press <i> (small i) and you will be in the insert 53 mode. ESC to exit insert mode */ 54 55 <I> /* To insert text at the beginning of the line you press <I> (capital I) and you will be in the 56 insert mode and text is inserted at beginning of the line and not at the cursor position. */ 57 /* ESC to exit insert mode */ 58 59 60 Append Command (a, A): ****************************************** 61 62 <a> /* To insert text after the character the cursor is at press <a> (small a) and you will be in 63 the append mode and text is inserted after the character the cursor is at. ESC to exit append 64 mode.*/ 65 66 <A> /* To insert text at end of the line press <A> (capital A) and you will be in the append mode 67 and text is inserted at the end of the line. */ 68 /* ESC to exit append mode */ 69 70 Delete Command(x): ********************************************** 71 72 <x> /* By pressing x, the character at the cursor will be deleted. No need to press ESC. Pressing 73 x several times delete one character each x is pressed */ 74 75 <nx> /* Enter a number (n) before x, an n number of characters will be deleted. No need to press 76 ESC */ 77 78 Deleting Using Backspace: *************************************** 79 80 <BACKSPACE> <ESC> /* BACKSPACE deletes the current character, but characters will be still 81 showing. ESC deletes this characters from the screen. */ 82 83 84 Replacing Command (r): ****************************************** 85 86 <r> /* Replace the current character with input character */ 87 88 <nr> /* Replace n number of characters by input characters. Only the input character is written n 89 times. */ 90 91 Substitute Commands (s, S): ************************************* 92 93 <s> /* Delete the current character and append mode is set on. ESC is necessary to exit the append 94 mode. A $ character shows at the end of n characters your are replacing. */ 95 96 <ns> /* Delete n number of characters starting with current character and append mode is set on. 97 ESC is necessary to exit the append mode. */ 98 99 <S> /* Replace all the characters in the line. ESC is ???? */ 100 101 Changing Text Command (c): ************************************** 102 103 <cw> /* Replace a word or the remaining characters within a word with a new text. VI editor prints 104 "$" to show the last character to be changed. ESC is needed to exit. Append mode is on. */ 105 106 <ncw> /* Replace n number of words with input text. ESC is needed to exit. Append mode is on. */ 107 108 109 Copy Commands (p): ********************************************** 110 111 <p> /* Place the content of temporary buffer after the cursor (see yank commands). 112 Temporary Buffer can have the following: 113 1) part of a line <d> 114 2) an entire line <dd> 115 3) a block (a number of lines) <ndd> 116 4) a number of characters <nx> 117 118 Yank Command (y): *********************************************** 119 120 <nyw> /* Yank (save) a copy of a n number of words from the cursor into a temporary buffer to 121 be copied later. */ 122 123 <y)> /* Yank a sentence. */ 124 125 <"xyn> /* Place a copy of a text object type n in a register named by the letter x. */ 126 127 <"xp> /* Place the content of the register x after the cursor. */ 128 129 CURSOR: 130 131 <h> /* Move the cursor to the left one space. */ 132 133 <k> /* Move the cursor up one line. */ 134 135 <j> /* Move the cursor down one line. */ 136 137 <l> /* Move the cursor to the right one space. */ 138 139 <nk> /* Move the cursor up n number of lines. */ 140 141 <nj> /* Move the cursor down n number of lines. */ 142 143 144 <BACKSPACE> /* Move the cursor to the left one space. */ 145 146 <nBACKSPACE> /* Move the cursor n number of space to the left. */ 147 148 <SPACEBAR> /* Move the cursor to the right one space. */ 149 150 <nSPACEBAR> /* Move the cursor to the right n number of spaces. */ 151 152 <CR> /* Move the cursor down one line. */ 153 154 <nCR> /* Move the cursor to line number in the file. */ 155 156 <$> /* Move the cursor to end of the current line. */ 157 158 <0> (zero) /* Move the cursor to beginning of the line. */ 159 160 <^> (circumflex) /* Puts the cursor on the first nonblank character of the line. */ 161 162 <+> /* Move the cursor down one line. */ 163 164 <n+> /* Move the cursor down n number of lines. */ 165 166 167 < > /* Move the cursor up one line. */ 168 169 <n > /* Move the cursor up n number of lines. */ 170 171 LINE: /* Also see cursor section */ 172 173 <d> /* Delete the characters right of the cursor to end of line. */ 174 175 <dd> /* Delete the entire line put in the temporary buffer */ 176 177 <ndd> /* delete n number of lines starting with current line. Put the line in the temporary buffer.*/ 178 179 <cc> /* Replace all the characters in the line and set the append mode. ESC is needed to exit. */ 180 181 <ncc> /* Replace all the characters in the current line up to n number of lines following the current 182 line. Set append mode. ESC is needed to exit. */ 183 184 <C> /* Replace the characters right of the cursor to the end of the line and set append mode on. 185 ESC is needed to exit. */ 186 187 <nC> /* Replace the characters of n number of lines and set the append mode on. ESC is needed 188 to exit. */ 189 190 <yy> /* Yank (save a copy) the current line in temporary buffer. */ 191 192 <nyy> /* Yank a number of line in the temporary buffer. */ 193 194 <p> /* Insert the copy of the temporary buffer where the cursor is. */ 195 196 <J> /* Join two lines. */ 197 198 <G> /* Go to the last line in the file. */ 199 200 <1G> /* Go to the first line in the file. */ 201 202 <nG> /* Go to the nth line in the file. */ 203 204 <^g> /* Give the status notice at the bottom of the screen. 205 The status has the following: 206 1) file name. 207 2) if the file has been modified. 208 3) the current line number. 209 4) total number of lines. 210 5) % of total lines in the buffer represented by the 211 current line. */ 212 213 <o> (small o) /* Create a new line below the current line and append. */ 214 215 <O> (capital) /* Create a new line above the current line and append */ 216 217 218 PAGE: 219 220 <H> (capital) /* Move the cursor to the first line on the screen. */ 221 222 <M> (capital) /* Move the cursor to the middle line on the screen. */ 223 224 <L> (capital) /* Move the cursor to the last line on the screen. */ 225 226 <^f> (control f) /* Page down. */ 227 228 <^d> (control d) /* Get to half page down. */ 229 230 <^b> (control b) /* Page up. */ 231 232 <^u> (control u) /* Get to half page down. */ 233 234 <u> /* Undo the last command. */ 235 236 ********************************************************************** 237 BLOCKS: 238 239 <y}> /* Put a copy of a paragraph into a temporary buffer that can be copied with the "p" 240 command. */ 241 242 <nyy> /* Yank or put a n number of lines starting from the current line into a temporary buffer to 243 be copied with the "p" command. */ 244 245 *************************************************************************** 246 SEARCH: 247 248 <fx> /* Move cursor to right of the character "x". */ 249 250 <Fx> /* Move cursor to left of the character "x". */ 251 252 <tx> /* Move cursor to the character right of the character "x". */ 253 254 <Tx> /* Move cursor to the character left of the character "x". */ 255 256 <;> /* Continue the search that was specified in the last command in the same direction. */ 257 258 259 <;> /* Continue the search that was specified in the last command in the opposite direction. */ 260 261 <w> /* Move cursor forward to the first character in the next word. */ 262 263 264 <nw> /* Move cursor forward n number of words to the first character in that word (punctuation 265 is considered a word. */ 266 267 <W> /* Ignore all punctuations above and move the cursor forward to the word after the next 268 blank. */ 269 <e> /* Move cursor forward (in the same line) to the last character of the next word. */ 270 271 <ne> /* Move cursor forward n number of words (in the same line) to the last character of that 272 word. */ 273 274 <E> /* Move cursor forward (in the same line) to the last character of the next word (all 275 punctuations are ignored). */ 276 277 <b> /* Move cursor backward (in the same line) to the first character of the previous word. */ 278 279 <nb> /* Move the cursor backward n number of words (in the same line) to the first character of 280 nth word. */ 281 282 283 <B> /* Move the cursor backward n number of words (in the same line) to the first character of 284 nth word (blanks and new line are delimiters. */ 285 286 <(> /* Move cursor to the beginning of the current sentence. */ 287 288 <n(> /* Move cursor to beginning of the nth sentence above the current sentence. */ 289 290 <)> /* Move cursor to the beginning of next sentence. */ 291 292 <n)> /* Move cursor to the beginning of nth sentence below the current sentence (delimiters are 2 293 blanks or period "."). */ 294 295 <{> /* Move cursor to the beginning of the current paragraph.*/ 296 297 <}> /* move cursor to the beginning of the next paragraph. */ 298 299 </pattern> /* Search forward in the buffer for the next occurrence of pattern (after the cursor position). 300 The cursor stops at the first character. */ 301 302 303 <?pattern> /* Search backward in the buffer for the next occurrence of pattern (after the cursor position). 304 The cursor stops at the first character. */ 305 306 **** NOTE ***** 307 308 1) "/" & "?" start at the cursor position reaches the end of the buffer and continue to starting position. 309 310 2) If the pattern is split between two lines it will not be recognized. 311 312 313 <n> /* Repeat the last command forward. */ 314 315 <N> /* Repeat the last command backward. */ 316 317