![]() ![]() Note:: You should enclose the word with, which will force the substitution to search only for the full word and not any partial match.Įxample 7. Whole Word Subsitution Original Text: This is his idea Standard Subsitution Original Text: This is his idea If you do the standard substitution, apart from changing his to her, it will also change This to Ther as shown below. Let us assume that you want to change only the whole word ‘his’ to ‘her’ in the original text mentioned below. Substitute only the whole word and not partial match do substitution in 4 lines from the current line. Using count in substitution, If you specify the count N in the substitution then it means do substitution in N lines from the current position of the cursor. Substitution of a text with another text only the 1st X number of lines Press ‘:’ which will automatically formed as :' Then you can use the normal substitute as ![]() Press CTRL + V in command mode, use navigation keys to select the part of the file you want to be substituted. You can also select a specific lines by visually selecting those lines. Substitution of a text with another text by visual selection of lines Specifying 1, 10 as range means, do substitution only in the lines 1 – 10. With the range, you can make only a range of line to be affected in the substitution. Substitution of a text with another text within a range of lines With the ‘i’ flag, you can make the substitute search text to be case insensitive. Specifying no range means, do substitution in the current line only. When you want a specific text to be replaced with another text within a single line in a case insensitive manner. Substitution of a text with another text within a single line If this ‘g’ flag is not used then only first occurrence in the line only will be substituted.Įxample 2. With the ‘g’ flag, you can make the whole line to be substituted. g – specifies all occurrences in the line.Specifying the range as ‘%’ means do substitution in the entire file. When you want a specific text to be replaced with another text in the entire file then you can use the following sequence. This is the basic fundamental usage of the text substitution inside Vi editor. ![]() Substitute all occurrences of a text with another text in the whole file
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |