Search the Community
Showing results for tags 'editors'.
-
Vim is a popular text editor designed for efficient text editing right from the terminal. It is an advanced version of the Vi editor and is supported on different operating systems, such as macOS, BSD, Windows, and Linux. Vim is mainly known as the programmer’s tool, as it has many features that allow quick text editing. The Vim editor community has many plugins to improve its capabilities. Many users prefer the Vim editor because of its flexibility and various features. However, there are basic Vim editor commands that everyone must know. So, let’s look at these commands and keyboard shortcuts you can use to work on the Vim editor efficiently. Basic Shortcuts of Vim Editor Remember, the Vim editor isn’t a pre-installed utility. Hence, we recommend reading this guide to install the Vim editor before proceeding to the next step. Now, let’s start by creating the “example.txt” file using the following command: vim example.txt Here, you can add the text and navigate to the lines through the below-given keys: Keys Description H Move left L Move right K Move up J Move down W Go forward to the start of any word B Go backward to the start of any word E Go forward to the end of any word O Move to the start of a line $ Move to the end of a line G Move to the last line of the whole text gg Go to the first line of the whole text Once you know how to navigate between lines, characters, and words, it is time to understand the keyboard shortcuts to edit the text. So here is the complete cheat sheet to edit the text using simple shortcuts in the Vim editor: I Key: If you want to enter text before your cursor, press the I button on the keyboard, and you will see “Insert” in the window. For example, let’s add “Important” word before the paragraph, so we have to press the I key and start typing the text: After inserting the text, please press Escape (Esc) key to exit the Insert mode. O Key: By simply pressing the O key, you can efficiently open a new line below the current line. Shift + O Keys: It will open the new line above the current line. A Key: Press the A key to access the Insert mode and add the text after the cursor. Shift + A Keys: Press the Shift plus A keys to insert the text at the end of a line. Shift/CTRL + R Keys: The R key shortcut only replaces a single character, but if you want to replace multiple characters, press the Shift or CTRL + R keys. CW Shortcut: Press the C and then W keys to delete the entire word. After pressing these keys, you can enter the Insert mode to replace the whole word. CC Shortcut: The CC shortcut is similar to CW but will delete the entire line and let you add a new one. X Key: You can press the X key to delete a specific character at the cursor. However, make sure you are not in the Insert mode. Shift + X Keys: You can press the Shift and X keys to delete a specific line at the cursor. DD Shortcut: This shortcut will delete the entire line. Furthermore, if you want to delete multiple lines, press the number on the keyboard in the correct order. For example, if you want to delete five lines, press D, 5, and D in the same order. DW Shortcut: The DW shortcut will delete the entire word. YW Shortcut: This shortcut is called Yank, and it copies a word. YY Shortcut: This shortcut will copy a line. P Key: It will paste the text at the end of the particular paragraph. Shift + P Keys: The text will be pasted into the paragraph above. Essential Commands of Vim Editor :set nu: You can use this command to display the line number in the editor: :set nu!: Similarly, you can remove the line numbers. :{line number}: Use this command when you want to go to a specific line number. For instance, type 17 to redirect to the 17th line. :set mouse=a: This command will enable the mouse, and you can use it to copy and paste text. Moreover, you can also select the specific text and replace it with something else: :%s/old/new/g: You can use this command to replace a specific word with another. For example, let’s replace the word “Linux” with “OS” using the following command: :%s/Linux/OS/g In the above command, s stands for “substitute,” and % specifies the number of lines the command should implement the change. That’s why, if you want to replace the word in all the lines, use % or specify the line number instead. Moreover, g is “global.” which replaces all occurrences of old in the complete document. Additional Shortcuts Now, you can use a few additional shortcuts to find the texts and save the text file in the Vim text editor. /<text>: Press the / key and enter the text you want to search. This command will perform the forward search. ?<text>: Similarly, you can use ?<text> to perform a backward search. :w: You can use this command to write or save the file without exiting the Vim editor. :wq: If you want to save and quit the file in the Vim editor, please use the :wq command. :q: If you want to quit the text editor, please use the :q command, but save the file first, or it will show you the error. :q!: Finally, if you want to force quit and discard unsaved changes, please use :q! command. Wrapping Up So this was the complete guide about the basic vim editor commands you need to know to become an expert. You can use the Vim text editor to perform editing tasks and enhance productivity efficiently. Hence, we recommend learning these shortcuts and commands if you frequently use the Vim editor in terminal environments. View the full article
-
The post Get Started with Emacs: Mastering Text Editing in Linux first appeared on Tecmint: Linux Howtos, Tutorials & Guides .GNU Emacs is one of the oldest text editors. It was created by Richard Stallman, the founder of the Free Software movement and GNU project. The post Get Started with Emacs: Mastering Text Editing in Linux first appeared on Tecmint: Linux Howtos, Tutorials & Guides.View the full article
-
- editors
- linux editors
-
(and 1 more)
Tagged with:
-
We all appreciate the high customization and extensible nature of the Emacs text editor. Emacs offers powerful features coupled with the intensive use of keyboard shortcuts, providing the users with quick access and a workaround. If you are new to Emacs, these keyboard shortcuts can be challenging to master, especially when you are unsure of what the different commands do and the various keyboard shortcuts that you can use. To help clear the confusion, this post focuses on the Emacs key bindings. We will discuss the commonly used keys while giving examples whenever applicable. Different Categories and Examples of Emacs Key Bindings At first, Emacs can seem more complicated than the other text editors. With Emacs, everything can be done using key bindings, and mastering your way of using the keys is stressful. However, we curated the most common keys that you should know and arrange them based on their functionality. This breakdown will give you comfort and ease as you get started with Emacs. 1. Modifier Keys Emacs uses two modifier keys. The first is the Ctrl (control). The other is the Meta key (Alt/Esc). The “Ctrl” key is used with basic commands to trigger an event. For instance, you can trigger the search feature by pressing “C-x x-f”. In such a case, you press the “Ctrl + x” keys simultaneously, then release and press the “Ctrl + f” keys to bring up the search prompt. You will get an output like the one in the following: The “Meta” key is combined with other keys to trigger the commands. For instance, you can use the Emacs command prompt by pressing “M-x”. Press the “Alt + x” keys simultaneously and then type your command. 2. Basic Movements Using the control/Ctrl and Meta (Alt) keys, you can quickly navigate a buffer. C-p – It moves the cursor up. C-n – It moves the cursor down. C-b – It moves the cursor left. C-f – It moves the cursor right. C-a – It moves to the start of the line. C-e – It moves to the end of the line. M-f – It moves the cursor forward one word. M-b – It moves the cursor back one word. 3. Text Keys You can quickly select, copy, cut, and paste the texts with the following keys: C-SPC (Ctrl + Space) – Start selecting the text. You will get an output that the mark has been set. M-w – Copy the selected text C-w – Cut the selected text C-y – Paste the text from the clipboard 4. Search Features Emacs lets you search within the text. You can also search for files when opening them. C-s – Increments a search forward C-r – Increments a search backward C-x C-f – It lets you search and open a file. 5. Working with the Buffer Emacs works with buffers and windows, and you can have multiple open buffers. Such a case requires you to know what keys to use. C-x b – Switch between open buffers C-x 1 – Close all open windows except the active one C-x 2 – Split a window horizontally C-x 3 – Split a window vertically C-x C-s – Save the changes made to the current buffer C-x C-c – Exit Emacs. If any buffer is open, it prompts you whether to save it before exiting. 6. Customization and Commands You can customize Emacs using the configuration file. The configuration file is either “.emacs” or “.emacs.d/init.el”. To invoke a command such as the “text-scale-adjust”, press the “M-x”. Then, type the command’s name. Press the Enter/RET key to run the command. You can kill the current command by pressing the “C-g” keys. To undo the changes, use the “C-x u” keys. Conclusion Emacs is a powerful text editor, thanks to the numerous key bindings that you can utilize to perform the operations quickly. We discussed the commonly used Emacs key bindings to get you up-to-speed using the Emacs text editor. With that, you are ready to use and level up your usage and experience. Feel free to practice more key bindings; there are tons of them. Happy editing! View the full article
-
Whether you are a pro or a novice Emacs user, there are some basic things that are worth knowing such as how to highlight the current line. By default, Emacs doesn’t highlight the current line. You might have been used to highlighting the current line for quick access and better user experience when coming from other text editors. Even in Emacs, it’s possible to customize it to highlight the current line to increase the visibility. When defining how to highlight the current line, you can specify what color to use for the background and foreground of the highlighted current line. Why Highlight the Current Line in Emacs? Knowing how to highlight the current line in Emacs offers you the following benefits: Better Navigation and Visual Clarity – Quickly noticing the current line improves your navigation of the opened file. That way, you will have a better focus when scrolling through the Emacs file. Better Readability – Your overall readability in Emacs will improve once you enable highlighting the current line. For instance, if in the programming mode, you can easily read the current line as it stands out over the others. Moreover, it reduces eye strain. How to Highlight the Current Line in Emacs When you open an Emacs file, the current line as you scroll doesn’t get highlighted which limits the visual clarity. We can see no highlight of the current file in the following Emacs file: To change this, let’s start by accessing the Emacs config file. Open your “.emacs” or “.emacs.d/init.el” file. Emacs offers the “global-hl-line-mode” feature which allows the users to activate the highlighting of the current line. Once your Emacs config file opens, add the following line to activate the line highlighting: (global-hl-line-mode 1) Save the configuration file by pressing the “C-x c-s” keys. You will get an output showing that the file has been written which means that it has been saved. Restart Emacs or close the buffer and open Emacs again for the changes to apply. By reopening the previous file on Emacs, we can now notice that the current line is highlighted. With this option, we can navigate the file and we have a better visual of the current line. Change the Background and Foreground Colors of the Highlighted Line The default background and foreground colors for the currently highlighted line in Emacs can be changed. If you do not feel okay with the background color, use the “set-face-background” attribute and add the color code that you prefer. Open your Emacs again and add the following line: (set-face-background ‘hl-line “#00FF00”) For our case, we are using the #00FF00 color code for the green color. Change it to suit your preference. Save the configuration file by pressing “c-x c-s” and restart Emacs. Notice how we now have a new background color for the currently highlighted line in Emacs. You can also change the foreground color by adding the “set-face-foreground” attribute and specifying the color code to use. For instance, to set the foreground to red, add the following line: (set-face-foreground ‘hl-line “#FF0000”) Similarly, you must save the configuration file and restart Emacs for the changes to apply. We now have red as our foreground color for the currently highlighted line in Emacs. You can change the color code and use any supported color that you are comfortable with. The aim is to get better visuals when using Emacs, and the choice of color is individual. Feel free to try out different colors and see how they appear. That way, you will make a better choice of which color to use. Conclusion Emacs only highlights the current line if you enable the feature. The “global-hl-line-mode” enables the line highlighting. Once you activate it, you can also specify what color to use as the background and foreground of the highlighted line. We discussed about highlighting the current line in Emacs and provided the steps to follow to activate and customize it. Enjoy! View the full article
-
When working with Emacs, there are different instances when you need to select all the text in your buffer. Maybe you want to cut the entire text or paste it elsewhere. As a text editor, Emacs offers different ways to select all the text in your buffer. This guide focuses on the two main ways of selecting all in Emacs. Moreover, we will give the steps and commands on what to do after selecting all the text. For instance, we will see how to copy or cut the selected area. Let’s begin! Two Ways on How to Select All Texts in Emacs When you want to select all in Emacs, the goal is to mark a “region” that you want to select. In this case, the region is the entire text in your buffer. For instance, if you want to cut/delete all the text inside your buffer, selecting it all is the easiest option instead of deleting character by character. Let’s cover two methods of implementing the Emacs “select all”. Method 1: Using the Keyboard Shortcuts Like most things in Emacs, you can select all using the keyboard shortcuts. With this method, you must define the start and end area for the target region. Since our goal is to select all, the start mark is the start of the buffer and the end mark is the end of the buffer. To mark the start of the buffer, ensure that your cursor position is at the start or where you want to start selecting from. Next, press the “C-space” or the “Ctrl + Space” keyboard shortcut to mark the start position. You will get an output that shows “Mark activated” to confirm that the start area has been marked. The next step is to select the last mark which is the buffer’s end. Move the cursor to the end of the buffer using the “M ->” command which is the “Alt+Shift+ >” keyboard shortcut. Doing so will select the marked region, similar to selecting everything inside your Emacs buffer. You will notice how the background color will change to confirm the selected buffer region. You are now ready for the next task which is to cut the selected region or perform other formatting options. Method 2: Using the “Mark-Whole-Buffer” Command Suppose you feel that setting the start and end of the target region is such a hassle. There is an easy way out. For this second method, we will use the “mark-whole-buffer” command. Open your buffer that contains the text that you want to select. To select it all, press the “C-x h” command which means pressing “Ctrl +x then h”. The region inside your buffer will be selected and the background color will change to confirm that you managed to select it. You will get an output that shows “Mark set” which confirms that the target region has been selected. Working on the Selected Region We’ve seen the two methods that you can use to select all in Emacs. After selecting the region, there are different operations that you can perform. For instance, you can copy, cut, or paste the text. Let’s go through each of it. Copying You can only copy a selected item. To copy the selected region inside a buffer, ensure that you selected it using either of the methods that were covered earlier. Then, press the “M-w” command which is the “Alt + w” keyboard shortcut to copy the text. Cutting the Text You can delete all the selected text inside your buffer using the “cut” option. Select the region, then press the “C-w” command which is “Ctrl + w” and all the text/region will be deleted from your buffer. Paste the Text If you want to copy-paste the selected text, start by selecting it and copying it. Lastly, press the “C-y” command, the “Ctrl + y”, to paste the copied text where the cursor is. We pasted the text in our following example to duplicate it. Conclusion Emacs allows you to select all the text inside your buffer for different operations. Whether you want to copy or cut the text inside the buffer, this post has presented two methods to select all the contents inside your buffer by marking the region. Lastly, we provided three operations on what to do with the selected region including copying, cutting, and pasting the text. View the full article
-
When working with an Emacs file, you can make changes and revert to the previous state. Such a situation is what reloading a file means. It allows you to discard all changes you made in your buffer and have the initial state of the buffer. The reloaded file will open the version that is stored in your discard. Reloading a file is a neat way of undoing all the changes you made to your file, and Emacs offers different ways of reloading the current file. This post covers two methods on how to reload the current file. First, we will talk about a revert method. Then, we will create a shortcut for implementing the “reload” command. Let’s get started! Two Methods to Reload the Current File in Emacs Emacs treats the reloading of the current file as a request to discard all unsaved changes. Doing so retrieves the version of the file that is stored on the disk and all the changes will be discarded. Opening a file in Emacs implies loading it into an Emacs buffer. When you alter the file, the changes won’t affect the version that is stored on the disk until you save the file. However, if you change your mind, you can always reload the current file to discard the changes and use the version that is stored on the disk. Emacs will prompt you when reloading the file whether to save or discard the changes. Method 1: Using the Reload Command Emacs has the “revert-buffer” command in which you run whenever you want to reload a file. For this example, we will work with the following file. We loaded it into Emacs and added one line: Suppose we want to discard the changes and remove the added line. Reloading the file will do the trick. Press “M-x'” (Alt + x) on your Emacs and type “revert-buffer” in the command prompt. Once you press the RET/Enter keyboard key, the command will execute and you will be prompted to confirm that you want to revert the buffer which discards all the unsaved changes. To reload the file, type “yes” and press the RET key. Immediately after doing it, the file will be reloaded and all the unsaved changes we had will be discarded. We now have the file that was stored on the disk, and it doesn’t contain the last line that we added earlier. That’s how you quickly discard the changes in your Emacs file. Method 2: Binding the Reload Command Instead of typing the “revert-buffer” command whenever you want to reload the current file, you can bind the command to a key. That way, pressing the binded key does the same task as the “revert-buffer” command. The first step is to open up your Emacs config file. The config file can be “.emacs” or “.emacs.d/init.el”. Once you open it, we must bind the key to the “reload” command. Use the “global-set-key” attribute and specify what key to bind and to what command. We are using the “f8” key for this case and our bind statement is as follows: Save the configuration file by pressing “c-x c-s”. To apply our changes, restart your Emacs or reopen it. Now, we go back to our initial file that we loaded into an Emacs buffer. Instead of typing the “revert-buffer” command like in the first method, we only press the “f8” key here. Doing so brings up a prompt to confirm that we want to reload the file and discard all the changes. Once you confirm that you want to reload the file, all the changes will be discarded, and you will have the file version that was stored on the disk. That’s how you reload the current file in Emacs. Conclusion Reloading a file in Emacs implies reverting to the version of the file that is stored on the disk. It’s a way of discarding all the unsaved changes on the file that is loaded into Emacs. You can reload a file in two methods. The first method is using the “revert-buffer” command and confirming the prompt. The second method is binding the “revert-buffer” command to a key and pressing the key whenever you want to reload the current file. Both options are discussed in this post. View the full article
-
The post 15 Best Markdown Editors for Linux first appeared on Tecmint: Linux Howtos, Tutorials & Guides .For starters, Markdown is a simple and lightweight tool written in Perl, that enables users to write plain text format and convert it to valid The post 15 Best Markdown Editors for Linux first appeared on Tecmint: Linux Howtos, Tutorials & Guides.View the full article
-
Computer Science is one of the hottest prospects these days. With the world around us relying heavily on technology, this comes off as no surprise as everything is gradually becoming digitized and the demand for people skilled in this field keeps on increasing. The Internet has also exploded in the last couple of years and this has in turn led to an increase in the market for computers and devices related to it. However, the beauty of Computer Science isn’t only in its high success in the industry but also in how it is structured. It offers the best blend of mathematics and engineering, along with providing a platform where programmers can create and develop things simple with just a computer, similar to how an artist does with a paintbrush. Since Computer Science itself is composed of multiple subfields, there have been various programming languages developed each of which has been specifically designed for certain tasks. One such programming language that is immensely popular and lies at the crux of game development, animations, and operating systems is C++ which shall also be the topic of our discussion in this article where we would be looking at the best editors that are available for C++ programming. 1) VS Code The first name to appear on this list has to be VS Code, the powerful, open-source code editor designed by Microsoft that is available on all major platforms including Windows, Linux, and Mac OS. Although VS Code does not fall under the category of IDEs, it offers much more than what a traditional code editor does and is jam-packed with features that make it an excellent choice for writing and editing C++ programs. VS Code is well-known for its fluidity and flexibility, offering an interface that is extremely fast and easily customizable. Features like auto-completion, code refactoring color highlighting, and having support for multiple extensions make it an excellent choice for C++ programming. Editor Features: Extensions: VS Code also comes with a built-in command-line interface as well as an integrated source control from where users can perform version control tasks such as pulling and pushing data, making commits, creating branches, and so on. Preview of Source Control: 2) Sublime Text Another great option available for C++ programming is Sublime Text, the simple, cross-platform text editor. Although Sublime Text is closed source and not free, it still has one of the largest communities to back it and is well regarded mainly due to its speed and efficiency. Sublime Text has one of the slickest and sleek user interface that is bundled with a large set of features such as having multiple cursors, an innovative command palette, and an extremely customizable interface, and this can further be topped with by using its wide variety of plugins. Editing Tools: Snippets from Command Palette: Another awesome feature of Sublime is its unique search function which allows you to search and replace regular expressions, numbers, text, or case sensitive words. It also has the GoTo Anywhere Function, with which you can jump to any words, lines, or symbols that are specified instantly. 3) Atom Atom is an Electron-based free and open-source, cross-platform code editor that has risen in popularity among developers. What makes Atom so good is the fact that it has support from thousands of packages each of which offers different functionalities. It even allows users to create their own packages which they can then provide it to the Atom community. Atom is extremely customizable and is built with numerous excellent features such as auto-completion, providing multiple panes to split your screen into, and a very powerful search feature. Editing features: Multiple Panes: Split Left Pane: Another excellent feature that comes along with Atom is its integration with GitHub and thus, you can perform all operations of it such as creating new branches, pushing, and pulling, and making commits. 4) Brackets Brackets is a cross-platform and open-source code editor developed by Adobe that falls under the MIT License and is, therefore, free to use. Brackets is well-known for being lightweight and providing an immaculate performance while not comprising any of its features which clearly indicates its powerful nature. Brackets are extremely customizable, and you can quickly change the UI of its interface according to your interests. For example, if you just want the editor to appear in your workspace, you can easily hide the sidebar. Similarly, if you are working with numerous files and want to check the differences between them, you can split your window into vertical or horizontal splits. Horizontal split: Vertical Split: It also allows users to add extensions inside of it which provides more power to this simple-looking editor and allows users to manage their projects much more efficiently. 5) Geany Geany is another powerful text editor whose name deserves a mention in this list. It is an extremely lightweight and cross-platform text editor that makes use of GTK and Scintilla and provides a variety of features to its users without putting a strain on their systems. Features like auto-completion, syntax highlighting, and code navigation are some of its key highlights. In addition to this, it also has a built-in terminal along with a build system that allows it to compile and execute your programs which often leads to people calling it a small IDE. Geany also provides snippets to C++ Headers which can help users in writing their code in a much more efficient manner. Which are the Best Editors for C++ Programming? C++ is one of the most popular programming languages and is widely used in all sorts of areas of Computer Science. With so much importance being given to it, it is imperative to choose an editor that provides the best features and eases the work of the developer. All five editors mentioned above are excellent choices for writing and editing C++ code and are worth considering. View the full article
-
Forum Statistics
63.6k
Total Topics61.7k
Total Posts