Coder Social home page Coder Social logo

nikarc / inline_edit.vim Goto Github PK

View Code? Open in Web Editor NEW

This project forked from andrewradev/inline_edit.vim

0.0 1.0 0.0 92 KB

Edit code that's embedded within other code

Home Page: http://www.vim.org/scripts/script.php?script_id=3829

Ruby 1.43% Shell 0.53% Vim Script 90.80% HTML 6.14% Vue 1.09%

inline_edit.vim's Introduction

Problem

Editing javascript within HTML is annoying. To generalize, editing code that's embedded in some different code is annoying.

Solution

Given the following example:

<script type="text/javascript">
  $(document).ready(function() {
    $('#foo').click(function() {
      alert('OK');
    });
  })
</script>

Execute :InlineEdit within the script tag. A proxy buffer is opened with only the javascript. Saving the proxy buffer updates the original one. You can reindent, lint, slice and dice as much as you like.

Check the docs for more information, see the examples directory for some example files to try it on.

If you like the plugin, consider rating it on vim.org.

What does it work for?

  • Javascript and CSS within HTML

    <head>
      <script type="text/javascript">
        $(document).ready(function() {
          $('#foo').click(function() {
            alert('OK');
          });
        })
      </script>
    
      <style>
        body {
          color: blue;
          background-color: red;
        }
      </style>
    </head>
  • SQL within ruby (matches "<<-SQL")

    def some_heavy_query
      execute <<-SQL
        SELECT * FROM users WHERE something = 'other';
      SQL
    end
  • Code within fenced markdown blocks

      Some text.
    
      ``` ruby
      def foo
        puts "OK"
      end
      ```
    
      ``` python
      def foo():
          print("OK")
      ```
    
      Some other text.
    
  • Django blocks in templates (Thanks to @Vladimiroff)

    {%  block content %}
    <h1>{{ section.title }}</h1>
    
    {% for story in story_list %}
    <h2>
      <a href="{{ story.get_absolute_url }}">
        {{ story.headline|upper }}
      </a>
    </h2>
    <p>{{ story.tease|truncatewords:"100" }}</p>
    {% endfor %}
    {% endblock %}
  • Heredocs in shellscript (Thanks to @fewaffles)

    cat <<-RUBY
      #! /usr/bin/env ruby
    
      puts "OK"
    RUBY
    
    cat <<PYTHON
      #! /usr/bin/env python3
    
      print("OK")
    PYTHON
    
  • Vue Single File Components

    <template>
      <p>{{ greeting }} World!</p>
    </template>
    
    <script>
    module.exports = {
      data: function () {
        return {
          greeting: 'Hello'
        }
      }
    }
    </script>
    
    <style scoped>
    p {
      font-size: 2em;
      text-align: center;
    }
    </style>
  • Visual mode - any area that you mark

inline_edit.vim's People

Contributors

andrewradev avatar blackheaven avatar fewaffles avatar fvictorio avatar idanarye avatar kusnier avatar nikarc avatar

Watchers

 avatar

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.