zed icon indicating copy to clipboard operation
zed copied to clipboard

Implement something like the VSCode TabOut extension

Open dodalovic opened this issue 1 year ago • 2 comments

Describe the feature

Functionality where pressing tab will auto complete closing brackets, braces, parens, and quotes. Like VSCode albert.TabOut extension

dodalovic avatar Dec 22 '24 10:12 dodalovic

An exploration of the current behavior of albert.TabOut:

Includes a list of bracket pairs (customizable):

[
{"open": "[", "close": "]"},
{"open": "{", "close": "}"},
{"open": "(", "close": ")"},
{"open": "'", "close": "'"},
{"open": "\"", "close": "\""},
{"open": ":", "close": ":"},
{"open": "=", "close": "="},
{"open": ">", "close": ">"},
{"open": "<", "close": "<"},
{"open": ".", "close": "."},
{"open": "`", "close": "`"},
{"open": ";", "close": ";"}
]

Behavior:

  1. If there is only whitespace to the left of your cursor (you are at the indent), tab behaves normally (indent normally).
  2. If you are at the end of a line, tab behaves normally (inserts tab/spaces)
  3. If you are immediately preceding a closing bracket, tab moves one column to the right
  4. If you are immediately preceding an opening bracket, tab moves one column to the right
  5. If you are immediately following an opening bracket, tab moves to the matching closing bracket character.

Notes:

  • All of this functions only apply on a single line
  • For bracket pairs where open/close are the same (:, ;) but since most languages don't use them as bracket pairs tab functions as a "skip forward".
  • If you are between two brackets (e.g. between these two chars: {") it just moves one column to the right (e.g. the order of that list matters)

Bugs:

  • Tab-out will stop at escaped quote chars inside strings "foo \"bar\" baz"

notpeter avatar Apr 16 '25 18:04 notpeter

Any updates on this?

viktaur avatar May 15 '25 15:05 viktaur

I don't get it, is the feature implemented already and I need to do something in the setting or is it being implemented. Can you please clarify.

awtawsif avatar Aug 11 '25 13:08 awtawsif

I don't get it, is the feature implemented already and I need to do something in the setting or is it being implemented. Can you please clarify.

@awtawsif This is a feature request. Please 👍 above to upvote and subscribe to be notified of updates.

notpeter avatar Aug 11 '25 14:08 notpeter

Is this something that makes sense to implement? @notpeter

dodalovicgran avatar Sep 10 '25 18:09 dodalovicgran

I'm working on implementing this feature by leveraging existing tree sitter functionality. Here is my fork if anyone would like to track the progress: https://github.com/vamsi10010/zed/tree/smart-tab

vamsi10010 avatar Oct 19 '25 20:10 vamsi10010