Monday, June 3, 2013

Re: How to fix <h1> id strings?

On Mon, June 3, 2013 13:44, David Fishburn wrote:
> On Mon, Jun 3, 2013 at 3:52 AM, Steve Litt
> <slitt@troubleshooters.com>wrote:
>
>> Hi all,
>>
>> Using snipMate, <h1> items have id strings that are the same as their
>> text, meaning the id string has spaces.
>>
>> <h1 id="My h1 item">My h1 item</h1>
>>
>> This is an HTML4 no-no, so I want to create a Vim something or other so
>> that, when my cursor is between the quotes delineating the id's value,
>> it replaces all spaces with underscores.
>>
>>
> Since you are new to Vim, it is best to start learning some of Vim's
> motion
> commands.
> :h motion.txt
> And read through the entire thing.
> Find a couple that you might think, start using them regularly.
> Then read it again, find another one and start using them.
>
> To answer your question, in Vim, you can do this:
> <h1 id="My h1 item">My h1 item</h1>
> ^ Cursor is here
> vi"
> v - start character-wise visual mode.
> i" - select the text between the quotes (not including the quotes)
>

That doesn't work, because the :s command only accepts a linewise
address and does not care about the start/end of the visual selection.

For that we have the \%V atom (which is a little bit buggy).

regards,
Christian

> Then you can operate on that visual selection.
> :'<,'>s/ /_/g
>
>
> Another, possibly more useful thing I could do, would be to modify
>> snipMate's <h1> snippet so I type the visible text and the id follows,
>> instead of vice versa. I know how to do that. But then I'd need to have
>> the id replace the spaces with underscores realtime, and I don't know
>> how to do that.
>>
>> Haven't used snipMate.
> Did spend some time on UltiSnips, which apparently can also use snipMates
> templates.
>
> HTH,
> David
>
> --
> --
> You received this message from the "vim_use" 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_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to vim_use+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment