how to change encoding of a buffer in emacs

emacs coding system for file encoding

Emacs is pretty good at determining the default encoding of the file or buffer that it displays. The encoding of the file is determined when the file is loaded and the same encoding is used to save the content back to the file. read file in a specific encoding You can specify the encoding to be used while opening a…

how to set the font and font size in emacs editor

Emacs set font using the menu-set-font

Everybody has a different preference for fonts, font size and the look and feel of the editor that they are using. Most modern editors allow you to customize every single aspect of the look and feel and emacs is no exception. As with almost everything in emacs, there are several different ways to set the font and the font size…

how to increase line spacing in emacs editor

emacs execute shell command

Depending on the font you are using, there are times when you would want to increase the spacing between the lines to make it more readable. The variable that controls the spacing between lines is line-spacing and can executed in the mini-buffer or added to the configuration file. (setq-default line-spacing 0.25) The value of the variable can be one of…

how to count words and lines in the emacs editor

emacs toolbar menubar tabbar scrollbar

One of the functionality you might want from a text editor is the ability to count words and lines in the current buffer. This is especially useful for writers, but can be useful for others a well. There are several different ways to count the words and lines in a buffer. Some of them are built-in to the emacs depending…

how to repeat the last or previous command in emacs editor

display emacs line numbers

One of the useful features of an editor is the ability repeat commands with minimal keystrokes. Many users find it useful when having to execute arduous long commands that require some typing. The emacs repeat command will repeat the last action that was performed while ignoring the input events like moving around in the buffer. M-x repeat It is bound…

how to rename a buffer and file in emacs editor

save file in emacs

One of the features you will need to use repeatedly while using a text editor is the ability to save the buffer or the file to the disk. In Emacs, saving the file or buffer to disk is easy enough but how do you rename the current buffer or save it to different file on the disk. save buffer to…

how to reverse lines and characters in the buffer in emacs editor

emacs execute shell command

There are several different commands to sort text in the buffer. Reversing lines, words or even paragraphs is just a variation of sorting text. Reverse Lines in buffer The command to reverse text is reverse-region, and as the command indicates works on the current active region of the buffer. M-x reverse-region The reverse-region command will reverse the order of the…

how to create a new file or buffer in emacs editor

save buffers and exit emacs

If you have been using emacs as your text editor then one of the first things you probably want to know is how to create a new file or buffer in the editor. As with many of the modern editors, emacs has the concept of a buffer and a file. A buffer is the “object” that the editor holds on…

how to enable and disable toolbar, menubar, tabbar and scrollbar in emacs

emacs toolbar menubar tabbar scrollbar

Most emacs distributions, at least the ones I have seen come with the toolbar and the menubar enabled. More often than not, it is a distraction and a waste of space. Also if you were planning to learn emacs the emacs way, then these definitely are not helpful. You can hide or disable both the toolbar and menubar in the…

how to show line numbers in emacs editor

display emacs line numbers

When editing a file in emacs, you can choose to display the line numbers just like the other text editors. show which line number First lets see how you can find the current line number that the point is in the buffer. This is useful if you don’t have line numbers enabled in the buffer. M-x what-line This will print…

how to abort, quit and exit emacs

save buffers and exit emacs

There is a long standing joke about the vim text editor which somehow depicts the complexity of the text editors when it comes to newbies……It usually goes something like this. “I have been using vi editor for two years….mostly because I cannot figure out how to exit.” Something that can be said about emacs as well, but it does have…

how to save a file or buffer in emacs editor

save file in emacs

If you have worked with emacs then you might be familiar with the concept of buffers. It is similar to what other editors might call tabs or files. In emacs, it refers to the contents of some file or directory that you had opened and it is a copy of the contents of those files. So the contents of the…