GithubHelp home page GithubHelp logo

whatyouhide / vim-textobj-xmlattr Goto Github PK

View Code? Open in Web Editor NEW
73.0 4.0 6.0 10 KB

A vim text object for XML/HTML attributes.

License: Do What The F*ck You Want To Public License

Ruby 13.99% Vim Script 86.01%

vim-textobj-xmlattr's Introduction

vim-textobj-xmlattr

Build Status

This vim plugin provides two text objects: ax and ix.
They represent XML/HTML attributes.

It's based on (and requires) vim-textobj-user.

These attributes will work:

<div class="box" id=footer data-updatable data-content="everything"></div>

ix works with the inner attribute, with no surrounding whitespace. ax works like aw does: it includes the whitespace before the attribute. I know that aw includes the whitespace after/before or whatever it finds more fitty, but XML/HTML attributes always include whitespace before them, while they do not always include whitespace after:

<some-tag with-only="one attribute"/>

When I dix, I want to be left with a valid XML/HTML tag, that's why I didn't consider leading and trailing whitespaces.

Installation

I'm a recent vim-plug convert, and I'm super happy with this plugin manager. Check out its page, you will be amazed too (Vundle will look way less appealing!).

" vim-plug
Plug 'kana/vim-textobj-user' | Plug 'whatyouhide/vim-textobj-xmlattr'
" NeoBundle
NeoBundle 'kana/vim-textobj-user'
NeoBundle 'whatyouhide/vim-textobj-xmlattr'
" Vundle
Plugin 'kana/vim-textobj-user'
Plugin 'whatyouhide/vim-textobj-xmlattr'

Out-of-touch people that still use Pathogen can just clone the repository:

git clone https://github.com/whatyouhide/vim-textobj-xmlattr ~/.vim/bundle

Contributing

Fork the repository, commit your changes, and send a Pull Request. I'm more than happy to get help!

License

© Andrea Leopardi

vim-textobj-xmlattr's People

Contributors

gosukiwi avatar pocke avatar whatyouhide avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vim-textobj-xmlattr's Issues

The line with the only attribute is not deleted

Suppose we have the tag from the example in README.md, but the attributes are separated by line breaks (sometimes linters do this when the allowed line length is exceeded):

<div
  class="box"
  id=footer
  data-updatable
  data-content="everything"
></div>

After the dax operation on any attribute (for example, let it be on the first one), an empty string remains:

<div
  
  id=footer
  data-updatable
  data-content="everything"
></div>

It seems to me that the separator in the form of a line break, as well as in the form of a whitespace, should also be removed.

Question about jsx attributes

Hi,

I use this plugin everyday for html editing and also more and more jsx. Do you think it would make sense to add jsx attributes support?

As mentionned is this vim reddit thread, it doesn't work all the time with jsx attributes.

Best,

Does not work with XML attribute names containing colons.

First things first: awesome plugin, great job!

I'm doing Android development, and I work with a lot of XML like this:

<uses-permission android:name="android.permission.INTERNET" />

If I dix at the beginning of android:name, I get this result:

<uses-permission :name="android.permission.INTERNET" />

Make it work with numbered motions

AFAICT numbered versions of the key combinations are not implemented, e..g., using d2ix to remove two consecutive xml attributes or d3ix to remove 3, etc.

Is this something that can be potentially supported?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.