Indentation with space in codemirror

i want to use tab key to insert 4 spaces but all 4 spaces get deleted at once when i press backspaces.
and all four space behave like a tab key and when i insert four space somewhere they automatically behave like a tab key.

That’s because tab actually inserts a tab. You can bind it to the insertSoftTab command to insert spaces instead.

but when i use insertSoftTab and try to delete space all space gets removed one by one and i want that all four spaces gets removed at once. How can i do this???

Ah, I see, that’s not a feature the core library has, but you could write your own code that does it (bind something to backspace that, if there’s spaces before the cursor, computes the next tab stop and deletes up to that).

can you give me some idea how it’s code look like??