We recommend that you log in before editing. This will allow other users to leave you a message about your edit, and will let you track edits via your Watchlist. Creating an account is quick and free. Anti-spam check. Do not fill this in!==Selections== A command like <code>:123,145s/old/new/g</code> substitutes in lines 123 to 145 inclusive, but what if you're not sure what the line numbers are? One method is to use ''marks'': Type <code>ma</code> in the first line, then type <code>mb</code> in the last line (to set marks <code>a</code> and <code>b</code>). Then enter command <code>:'a,'bs/old/new/g</code> to substitute in lines from mark <code>a</code> to <code>b</code>, inclusive. Another method is to visually select lines, then enter a colon command (for example, <code>:s/old/new/g</code>). Note that you do not enter a range. However, because the command was entered while lines were selected, Vim displays the command as: <pre> :'<,'>s/old/new/g </pre> The range <code>'<,'></code> is entered automatically to identify the lines that were last visually selected (they do not need to be visually selected now). For example, you might type <code>vip</code> to visually select "inner paragraph" (the paragraph holding the cursor). Then type <code>:s/old/new/g</code> to substitute in all lines in the selected paragraph. Summary: Please note that all contributions to the Vim Tips Wiki are considered to be released under the CC-BY-SA Cancel Editing help (opens in new window) Retrieved from "https://vim.fandom.com/wiki/Ranges"