Vim: Make hlsearch work with :s, :g, :v, ...

Created on 9 Jun 2020  路  4Comments  路  Source: VSCodeVim/Vim

Describe the bug
If you enable hlsearch and use the / command, it will highlight the matches of your search as you type.

With actual Vim, this also works with the search query of the :g/, :v/ and :s// commands (and maybe some other ones that I missed?). VsCodeVim does not support hlsearch for these commands.

To Reproduce
Steps to reproduce the behaviour:

  1. In settings.json, set the vim.hlsearch option to true.
  2. Enter the following text into an empty document:
    ```
    foo
    bar
    foobar
  3. Type the following in command mode: :s/foo

Expected behaviour
The matches in the document get highlighted as you type, same as if you typed /foo.

Screenshots
N/A

Environment (please complete the following information):

  • Extension (VsCodeVim) version: 1.14.5
  • VSCode version: 1.45.1
  • OS: macOS Mojave 10.14.6

Additional context
N/A

arecommandline aresearch kinenhancement

Most helpful comment

Ah, of course it only highlights those within the line range specified (so :%s/... will highlight all occurrences). Yeah this would be a great feature to implement.

All 4 comments

What version of vim can you reproduce this on, and with what settings?

It seems that both hlsearch and incsearch need to be enabled for Vim to exhibit this exact behaviour.

I can get it to reproduce in Vim (with vim -u NONE) just by setting :set hlsearch and :set incsearch.

:version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Apr 12 2020 00:47:07)
macOS version
Included patches: 1-539
Compiled by [email protected]
Huge version with MacVim GUI.  Features included (+) or not (-):
+acl               +cindent           +cursorshape       +file_in_path      +job               +menu              +mouse_urxvt       +persistent_undo   +scrollbind        -tag_any_white     +transparency      +windows
+arabic            +clientserver      +dialog_con_gui    +find_in_path      +jumplist          +mksession         +mouse_xterm       +popupwin          +signs             -tcl               +user_commands     +writebackup
+autocmd           +clipboard         +diff              +float             +keymap            +modify_fname      +multi_byte        +postscript        +smartindent       +termguicolors     +vartabs           -X11
+autochdir         +cmdline_compl     +digraphs          +folding           +lambda            +mouse             +multi_lang        +printer           -sound             +terminal          +vertsplit         -xfontset
-autoservername    +cmdline_hist      +dnd               -footer            +langmap           +mouseshape        -mzscheme          +profile           +spell             +terminfo          +virtualedit       +xim
+balloon_eval      +cmdline_info      -ebcdic            +fork()            +libcall           +mouse_dec         +netbeans_intg     +python/dyn        +startuptime       +termresponse      +visual            -xpm
+balloon_eval_term +comments          +emacs_tags        +fullscreen        +linebreak         -mouse_gpm         +num64             +python3/dyn       +statusline        +textobjects       +visualextra       -xsmp
+browse            +conceal           +eval              -gettext           +lispindent        -mouse_jsbterm     +odbeditor         +quickfix          -sun_workshop      +textprop          +viminfo           -xterm_clipboard
++builtin_terms    +cryptv            +ex_extra          -hangul_input      +listcmds          +mouse_netterm     +packages          +reltime           +syntax            +timers            +vreplace          -xterm_save
+byte_offset       +cscope            +extra_search      +iconv             +localmap          +mouse_sgr         +path_extra        +rightleft         +tag_binary        +title             +wildignore
+channel           +cursorbind        -farsi             +insert_expand     +lua/dyn           -mouse_sysmouse    +perl/dyn          +ruby/dyn          -tag_old_static    +toolbar           +wildmenu
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/Applications/MacVim.app/Contents/Resources/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe  -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang   -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/[email protected]/lib -L/usr/local/opt/readline/lib -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/l
ocal/opt/[email protected]/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o Vim -framework Cocoa -framework Carbon       -lm  -lncurses -liconv -framework AppKit   -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-multi-2level/
CORE

Ah, of course it only highlights those within the line range specified (so :%s/... will highlight all occurrences). Yeah this would be a great feature to implement.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

WangRongda picture WangRongda  路  3Comments

triztian picture triztian  路  3Comments

typeoneerror picture typeoneerror  路  3Comments

spinningarrow picture spinningarrow  路  3Comments

AndersenJ picture AndersenJ  路  3Comments