On 2022-10-29, Gary Johnson wrote:
> On 2022-10-29, Carl Ponder wrote:
> > Based on this posting
> > https://vim.fandom.com/wiki/Searching_for_expressions_which_include_slashes
> > I tried re-mapping the '/' in my ~/.vimrc
> > 
> > command! -nargs=1 / let @/ = <q-args>|set hlsearch
> > 
> > but it didn't work.
> 
> That won't work because user-defined commands must begin with an
> upper-case letter.  See
> 
>     :help user-commands
> 
> To remap a command such as /, you must use a mapping, such as this
> example:
> 
>     :cnoremap <CR> <C-\>eescape(getcmdline(), '/')<CR><CR>:cunmap <lt>CR><CR>
> 
> See
> 
>     :help map-overview
>     :help x_CTRL-\_e
>     :help getcmdline()
>     :helpgrep \cctrl-\\.\?e
> 
> and the mappings in the file
> 
>     $VIMRUNTIME/macros/less.vim
> 
> That mapping is probably too simple, but it worked in the few test
> cases I tried.

I got so involved in the problem of mapping <CR> that I forgot about
mapping /.  Here's a better example, again just fleshed out to the
point of working, but closer to a complete solution.

    :nnoremap / :call SlashEscape()<CR>/

    :function SlashEscape()
    :    cnoremap <CR> <C-\>eescape(getcmdline(), '/')<CR><CR>:cunmap 
<lt>CR><CR>
    :endfunction

Regards,
Gary

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20221030004548.GF14398%40phoenix.

Raspunde prin e-mail lui