Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7687251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:39:45+00:00 2026-05-31T19:39:45+00:00

I am trying to select an entire XML CDATA section with VIM. For those

  • 0

I am trying to select an entire XML CDATA section with VIM. For those unfamiliar with XML, a CDATA section looks like this:

<someTag><![CDATA[
This text is escaped in a Character Data section!
Look, I can use < and > characters freely!
]]></someTag>

<anotherTag><![CDATA[More escaped text!]]></anotherTag>

I tried this mapping to visually select and yank the text inside the CDATA section, but it appears that the call function disables visual selection:

inoremap <F9> <Esc>:call searchpair('<!\[CDATA\[', '', ']]>', 'b')v:call searchpair('<!\[CDATA\[', '', ']]>')y

Is there any way to select the entire CDATA section? This is what I use to select methods in C-based languages, for reference:

inoremap <F7> <Esc><C-V>aBy

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T19:39:47+00:00Added an answer on May 31, 2026 at 7:39 pm

    This fixed version works for me

     :inoremap <F9> <Esc>:call searchpair('<!\[CDATA\[', '', ']]>', 'b')<CR>
          v:<C-u>call searchpair('<!\[CDATA\[', '', ']]>')<CR>v`<o
    

    (no linebreak in real life)

    Tricks:

    • <CR> for the necessary Enter keys
    • <C-u> to clear the range on the commandline
    • v` to reselect to the start of the visual selection
    • o to move cursor to end of visual selection

    I’m surprised that this would be an insert mode mapping, I’m assuming you have normal mode mappings too.

    By the way, perhaps you’d be interested in operator pending mode mappings for ‘proper’ text-object semantics too:

    • vim: select inside dots
    • vim call a function from inside a vmap

    Edit Update in response to comment:

    The following appears to work (judicious use of \zs and \ze in the search pattern). You might want to back-track one position (add <BS> to the end of the mapping). Also, by now, the operator-pending type mapping seems to get more attractive.

    :inoremap <F9> <Esc>:call searchpair('<!\[CDATA\[\zs', '', '\ze]]>', 'b')<CR>
        v:<C-u>call searchpair('<!\[CDATA\[\zs', '', '\ze]]>')<CR>v`<o
    

    PS.: You may want to apply an explicit magic-level (e.g. \V) inside your search patterns as well

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to build a list that parses my entire xml document. I
I am trying to programatically select an entire column in a WPF DataGrid. My
I am trying to select a specified text in TinyMCE editor using JavaScript in
I'm trying to make the text in a UITextField select when the user taps
Trying to select anchor tags that are a descendants of a div with a
In trying to select elements that have any attributes, the following throws a jQuery
I'm trying to select data from a table defined similar to the following :
I'm trying to select a random 10% sampling from a small table. I thought
I'm trying to select a column from a single table (no joins) and I
I'm trying to select the used range. I get the worksheet's UsedRange, then I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.