I work on an open source project where the creator sets his tab-indents to 2 spaces.
I'd like to just enable it on the fly for the one file I work on and not other files of the same type. There must be something like M-x set-tab-indent
. It is a JavaScript file ending in .js
.
I know I can use:
(setq-default tab-width int)
inside my .emacs
file, but I rather just call an M-x command
to set it and forget it during my duration of working on this file. I tried M-x apropos
and Google but couldn't find the specific command.
Thanks.
To delete just the indentation of a line, go to the beginning of the line and use M-\ ( delete-horizontal-space ), which deletes all spaces and tabs around the cursor. If you have a fill prefix, M-^ deletes the fill prefix if it appears after the newline that is deleted.
Just change the value of indent-line-function to the insert-tab function and configure tab insertion as 4 spaces.
You can make the variable js-indent-level
local to the buffer using:
M-x make-variable-buffer-local <RET> js-indent-level <RET>
Then you can set that variable in the buffer using:
M-x set-variable <RET> js-indent-level <RET> 2
The easiest way to do this for a single buffer is to use M-x set-variable
.
M-x set-variable
and press entertab-width
then press enterSet tab-width (buffer-local) to value:
. Put the value you want, then hit enterThe buffer should instantly be updated with the new value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With