I recently started using Emacs and encountered a problem - the tab is too small (2 spaces). Looking for info, I read that in emacs you need to set setq-default tab-width 4 in order to change the tabulation from two to four spaces. But I did not understand how and where to write it. Where and how to write?

    2 answers 2

    This you need to specify in the configuration file, which is located in the user directory

    / home / <username> /. emacs

    The default file may not be. To execute commands in emacs, use the alt + x combination to invoke the command line.

    For a bit of emacs, check out help .

    • To set a variable in the current session, you can use the * scratch * buffer or even the current buffer (of course, if it is modified, enter directly in the text (setq variable value) ^ X ^ E ^ Xu) - avp

    Each command (for example, find-file or next-line ) in Emacs is an Emacs Lisp function. But besides commands (which may or may not be tied to keyboard shortcuts), there are many other functions. Emacs Lisp has an interpreter built into Emacs, which means you can perform every function at any time. uvlad has already shown how to make a function run every time Emacs starts.

    But if you need to perform the function temporarily - i.e. when Emacs restarts, the change made by the function will be reset — you can press Alt + Shift +; . In the minibuffer you can enter (setq-default tab-width 4) . The brackets are required because this is the Lisp syntax: (название-функции аргумент1 аргумент2 ...) .

    If you want to call a full-fledged interpreter to enter perform different functions of Emacs Lisp, then it is called IELM, and you can call it by pressing Alt + x and entering ielm .

    Not all functions can be called through Alt + x , only interactive, but since there are a lot of them, I recommend reading the manual about invoking interactive commands: Running Commands by Name @ GNU Emacs Manual .

    • one
      I would add - you can start learning emacs from the built-in interactive guide by typing a combination of a pair of characters - Ctrl-h Ctrl-t in any window. If you read carefully, then everything is just unwound (with the help of quite detailed documentation built into emacs). - avp