

The unnamed register ( is saved and later restored. : enters command mode and deletes (Ctrl-u) the ' range automatically inserted due to the visual selection. When in visual mode, pressing * will then perform these commands: \gV:call setreg('"', old_reg, old_regtype) Nmap VLToggle :let g:VeryLiteral = !g:VeryLiteral

\gVzv:call setreg('"', old_reg, old_regtype)

" Search for selected text, forwards or backwards. Place the following mappings in your vimrc: Each search is placed in the search history allowing you to easily repeat previous searches.Whitespace in the selection matches any whitespace when searching (searching for "hello world" will also find "hello" at the end of a line, with "world" at the start of the next line).Handles multiline selection and search.As normal, press n for next search, or N for previous.Press * to search forwards for selected text, or # to search backwards.The following is a more advanced implementation, with more robust functionality than the above map. The search uses \V ( :help /\V) for "very no-magic" mode, and escape() ( :help ) to escape / and \ characters (the only ones that aren't literals with \V). represents Ctrl-R and represents carriage return (Enter). The :vnoremap () command maps // in visual mode to copy the visually selected text into the " buffer, then start a search command and paste an escaped version of the copied text into the line. Then press n to search for the next occurrence. Vnoremap // use the mapping, visually select the characters that are wanted in the search, then type // to search for the next occurrence of the selected text. To search for visually selected text, put this line in your vimrc: Nothing is needed if you want to search for the word under the cursor, just press *.
