Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    VIM visual block search and replace

    Hi all,

    I'm trying to do a search and replace inside a visual block as shown below

    but it gives an error - Invalid character after \%

    Obviously, this happens in search too.

    But the same works in another machine. So I doubt I'm missing some configuration in VIM or some VIM package needs to be installed. Please help.

    Subith Premdas

  2. #2
    Linux Enthusiast meton_magis's Avatar
    Join Date
    Oct 2006
    Can you give us the text you have, and what you want it changed to?

    If you only give us your command, we can only assume what you want based on what is not working.
    New to the internet, technical forums, or the hacker / open source community??
    Read this to learn good posting habits

    RHCE for RHEL version 5
    RHCT for RHEL version 4

  3. #3
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Seattle, WA, USA
    I suspect that the problem has to do wit the magic settings on the two machines. The magic settings control when you need to provide \ certain search commands:

                                                    'magic' 'nomagic'
    'magic'                 boolean (default on)
            Changes the special characters that can be used in search patterns.
            See pattern.
            NOTE: To avoid portability problems with using patterns, always keep
            this option at the default "on".  Only switch it off when working with
            old Vi scripts.  In any other situation write patterns that work when
            'magic' is on.  Include "\M" when you want to /\M.
    You might try this:
    Here the pattern is explicitly given a magic setting (with \v), meaning that the % does not require an escape, and that the values of 'magic' will be ignored.

  4. $spacer_open
  5. #4
    Hi Cabhan,

    Thanks for the reply. But this too didn't work.
    I get this error E71: Invalid character after \%

    Could you please help me how to set this magic settings, or how to check what setting do i currently have so that i can compare two machines and make changes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts