Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/AndrewRadev/inline_edit.vim
Edit code that's embedded within other code
https://github.com/AndrewRadev/inline_edit.vim
filetypes narrow-reg nested-buffers vim-plugin
Last synced: 3 months ago
JSON representation
Edit code that's embedded within other code
- Host: GitHub
- URL: https://github.com/AndrewRadev/inline_edit.vim
- Owner: AndrewRadev
- Created: 2011-11-13T19:59:31.000Z (almost 13 years ago)
- Default Branch: main
- Last Pushed: 2024-05-19T16:28:50.000Z (6 months ago)
- Last Synced: 2024-06-18T10:33:48.518Z (5 months ago)
- Topics: filetypes, narrow-reg, nested-buffers, vim-plugin
- Language: Vim Script
- Homepage: http://www.vim.org/scripts/script.php?script_id=3829
- Size: 142 KB
- Stars: 147
- Watchers: 3
- Forks: 13
- Open Issues: 1
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
## 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:
``` html
$(document).ready(function() {
$('#foo').click(function() {
alert('OK');
});
})```
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](http://www.vim.org/scripts/script.php?script_id=3829).
## What does it work for?
- Javascript and CSS within HTML
``` html
$(document).ready(function() {
$('#foo').click(function() {
alert('OK');
});
})
body {
color: blue;
background-color: red;
}
```- SQL within ruby (matches "<<-SQL")
``` ruby
def some_heavy_query
execute <<-SQL
SELECT * FROM users WHERE something = 'other';
SQL
end
```- Python multiline strings (tries to guess SQL syntax) (Thanks to [@thalesmello](https://github.com/thalesmello))
``` python
sql_query = """
SELECT name
FROM "Students"
WHERE age > 10
"""print("""
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat.Duis aute irure dolor in reprehenderit in voluptate velit esse cillum
dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
""")
```- 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](https://github.com/Vladimiroff))
``` htmldjango
{% block content %}
{{ section.title }}
{% for story in story_list %}
{{ story.headline|upper }}
{{ story.tease|truncatewords:"100" }}
{% endfor %}
{% endblock %}
```- Heredocs in shellscript (Thanks to [@fewaffles](https://github.com/fewaffles))
```
cat <<-RUBY
#! /usr/bin/env rubyputs "OK"
RUBYcat <
{{ greeting }} World!
module.exports = {
data: function () {
return {
greeting: 'Hello'
}
}
}
p {
font-size: 2em;
text-align: center;
}
```- Angular components' CSS and templates (Thanks to [@MartinAskestad](https://github.com/MartinAskestad))
``` typescript
@Component({
selector: 'my-component',
template: `
My component works!
`,
styles: [
`
.my-p {
color: orange;
}
`,
],
})
```- Visual mode - any area that you mark