Skip to content
Edit code that's embedded within other code
VimL Ruby Shell
Find file
Latest commit 4a2ad9a Jan 27, 2015 @AndrewRadev inline_edit 0.2.1
Failed to load latest commit information.
autoload Remove unused function Jul 7, 2013
doc Fix documentation errors Dec 30, 2013
example Implement "scratch" and "tempfile" proxy types Sep 2, 2012
plugin inline_edit 0.2.1 Jan 27, 2015
README.markdown
Rakefile Rake task for easy archiving Jan 27, 2015
_project.vim Blank project file Nov 22, 2011

README.markdown

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
    
  • Visual mode - any area that you mark

Something went wrong with that request. Please try again.