how to split windows vertically and horizontally in emacs

emacs split windows

One of the most useful features of modern text editors and IDEs is the ability to split the screen into multiple windows and edit/view different files in them. Emacs is no exception and makes it easy to do so. split window horizontally In order to split the window horizontally, use the command split-window-horizontally. This will split the currently active buffer…

how to copy, cut and paste in emacs editor

display emacs line numbers

You cannot cut, copy or paste in emacs editor, instead you kill, kill-ring-save, yank and yank-pop. Emacs uses a different terminology for the actions commonly known as cut, copy and paste. There are slight variation in the functionality as well. For the sake of completeness, you should know how to select a region to perform the cut or copy on…

how to count words in vi or vim editor

vim count words lines and bytes

When editing text files, you might want to know the total number of words in the document. Sometimes you would want to count the number of a specific word. If you are using the vim or vi editor, then you can easily count the words using one of the following commands. count total number of words If you want to…

how to enable and disable syntax highlighting in emacs

emacs major minor mode

Emacs comes with syntax highlighting enabled out of the box for most modes or file types. So it should work just fine in most cases. The standard way that Emacs perform syntax highlighting is using the font-lock-mode function. It is turned on by default. enabling the syntax highlighting If for some reason you find that the buffer is not being…

how to find matching parenthesis or braces in emacs editor

display emacs line numbers

In Emacs, there are quite a few packages that allow you to match braces and brackets in the buffer. Some of these packages provide more functionality than others, but almost all them provide the matching functionality. Depending on the major mode of the buffer, different pairs of characters can be considered a matching parenthesis. Almost all modes support “()” as…

how to find matching braces in vi or vim editor

vim matching braces

If you are using the vi or vim editor to browse code (or any text for that matter), then quite often you would want to find the matching parenthesis to determine the scope of the enclosing brackets. Most modern editors such as gvim or vim has the ability to automatically highlight the matching parenthesis when the cursor is on a…

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…