Table of Contents
Comment\Uncomment a Line
M-;Insert or realign comment on current line; if the region is active, comment or uncomment the region instead (comment-dwim).
C-u M-;Kill comment on current line (comment-kill).
C-x ;Set comment column (comment-set-column).
M-jLike RET followed by inserting and aligning a comment (comment-indent-new-line). See Multi-Line Comments.
Mastering this command takes me one step further into Emacs, as it used to be one of those funcionalities that keeped drawing me back to Sublime Text.
Quick reload of init.el file
init.elfile, but most of the configuration in a more literal way, in an org config file.
When I make changes to Emacs settings, I need to reload the init file activate the changes. So far, I typed
C-x C-f to find the init file and then
M-x [RET] eval-buffer to reload it. Repeating this flow hundreds of times became annoying.
A quick inquery in IRC, and now I know that I can call
load-file and give it the name of the file I would like to load. Having a function to load a file, means that I can wrap it with my own function, and reload my init file with a customized keybind.
And with the help of this answer at stack-overflow, I came up with the following shortcut to reload my Emacs configuration:
(global-set-key (kbd "<f6>") (lambda() (interactive)(load-file "~/.emacs.d/init.el")))
New line bellow
C-e C-m – go to the end of the line, create a new line and move the point to that line.
C-e C-j – same as the command above, only that the point will indent if neccessery.
There is also a keybind for creating a new line above the current line, and move the point to that line –
Quick Open a specific file
Google’s first search result was EmacsWiki. Again, it proved to be a great source of information, had I wanted to confuse myself. So I passed. The second result was from Emacs tutorial, which again proved to be clear, concise and informative.
Here are the commands for storing a filename in and loading it from a register:
(set-register r '(file . name))
(set-register ?r '(file . "~/Dropbox/Notes/posts/pages/posts_drafts.org"))
To load this file, I should type
C-x r j r
In the code examples above,
r is the name of the register. It can be replaced with any character.
And to see what’s stored in a specific register:
M-x view-register RET r
r is the register I’m querying.
||Convert following word to lower case (downcase-word).|
||Convert following word to upper case (upcase-word).|
||Capitalize the following word (capitalize-word).|
||Convert region to lower case (downcase-region).|
||Convert region to upper case (upcase-region).|