vamolessa / pepper

simple and opinionated modal code editor for your terminal
https://vamolessa.github.io/pepper/
372 stars 17 forks source link

[Plugin] Support auto close and rename tag #47

Open NNBnh opened 2 years ago

NNBnh commented 2 years ago

Following issue #46:

Pepper would be great if it have the quality-of-life-improvement features from two of the most popular VScode plugins: Auto Close Tag and Auto Rename Tag:

Auto Close Tag

From the "Auto Rename Tag" VScode plugin:

Automatically add HTML/XML close tag, same as Visual Studio IDE or Sublime Text does:

  • Automatically add closing tag when you type in the closing bracket of the opening tag
  • After closing tag is inserted, the cursor is between the opening and closing tag
  • Set the tag list that would not be auto closed
  • Automatically close self-closing tag
  • Support auto close tag as Sublime Text 3
  • Use Keyboard Shortcut or Command Palette to add close tag manually

usage

Auto Rename Tag:

From the "Auto Rename Tag" VScode plugin:

When you rename one HTML/XML tag, automatically rename the paired HTML/XML tag

usage

If you find this suggestion it's suitable to be built-in with the editor, feel free to label this issue with "Plugin" or "Plugin Idea".

vamolessa commented 2 years ago

I feel like auto-close could be implemented through a plugin: It would override the on_keys and watches for a > key event. Then it would check if the current buffer's path has a html or xml extension. If it does, it'd check for each cursor if it's at the end of a tag and, if it is, it would insert the corresponding text right after it.

The auto rename also could be made via a plugin that watches the on_keys event. However, you could also achieve a similar result by using multiple cursors: