mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-02-03 23:40:14 +08:00
[手动选题][tech]: 20230401.3 ⭐️⭐️ 10 Tweaks to Supercharge Gedit as Code Editor.md
This commit is contained in:
parent
ed74d71b7c
commit
5a9bdd0889
@ -0,0 +1,239 @@
|
||||
[#]: subject: "10 Tweaks to Supercharge Gedit as Code Editor"
|
||||
[#]: via: "https://itsfoss.com/gedit-tweaks/"
|
||||
[#]: author: "Abhishek Prakash https://itsfoss.com/author/abhishek/"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: " "
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
10 Tweaks to Supercharge Gedit as Code Editor
|
||||
======
|
||||
|
||||
![][1]
|
||||
|
||||
GNOME may have ditched Gedit as the default text editor but it is still a favorite of long-time Linux users.
|
||||
|
||||
It is primarily a text editor, but with some tweaks, it can work as a lightweight code editor.
|
||||
|
||||
Yeah! Why use VS Code or other dedicated code editors for writing Bash scripts or simple programs in other languages? Gedit saves the day.
|
||||
|
||||
I'll share some of my favorite Gedit tips and tricks in this article. While most of the tweaks are beneficial for writing codes, some could be helpful for general text writing as well.
|
||||
|
||||
### 1. Install plugins
|
||||
|
||||
Few people don't even know that Gedit has a robust plugin feature. You can install plugins to get additional features.
|
||||
|
||||
There are two kinds of plugins:
|
||||
|
||||
- Official Gedit plugins that are accessible from the editor menu
|
||||
- Third-party plugins that can be downloaded from the project websites and placed into the plugins directory (discussed below)
|
||||
|
||||
The Gedit plugins can be located in `/usr/share/gedit/plugins` or `~/.local/share/gedit/plugins` directories.
|
||||
|
||||
![][2]
|
||||
|
||||
You can access the available and installed plugins by clicking the Hamburger menu and then opening the Preference window,
|
||||
|
||||
![][3]
|
||||
|
||||
The Preferences window has the Plugins tab and you can see all the plugins available to you. You can use the checkbox to enable and disable the plugins.
|
||||
|
||||
![][4]
|
||||
|
||||
### 2. Show file browser in the side panel
|
||||
|
||||
If you are working on a project that has multiple files and folders, getting the file browser to see all the available files in the sidebar is quite helpful.
|
||||
|
||||
Go to **Preferences -> Plugins** and enable the **File Browser Panel**.
|
||||
|
||||
![][5]
|
||||
|
||||
After that, click on the hamburger menu at top right and enable the Side Panel View from Menu **View -> Side Panel**
|
||||
|
||||
Now change the side panel view to file browser, if not already.
|
||||
|
||||
![][6]
|
||||
|
||||
### 3. Embed a terminal
|
||||
|
||||
Yes! You can embed a terminal right into the Gedit text editor.
|
||||
|
||||
What's the point? Well, if you are writing programs or scripts, an embed terminal helps you run the script and check the code changes right there in the editor.
|
||||
|
||||
![][7]
|
||||
|
||||
To get this, first install the plugin (for Ubuntu):
|
||||
|
||||
```
|
||||
sudo apt install gedit-plugin-terminal
|
||||
```
|
||||
|
||||
Once the plugin is installed, enable it from Preferences->Plugin.
|
||||
|
||||
![][8]
|
||||
|
||||
Mow, enable bottom panel from hamburger menu -> **View -> Bottom Panel**
|
||||
|
||||
![][9]
|
||||
|
||||
### 4. Markdown preview
|
||||
|
||||
Love Markdown? Me too!
|
||||
|
||||
There are several Markdown editors available for Linux but you don't have to install another application just to use Markdown.
|
||||
|
||||
With the help of a plugin, unsurprisingly called [Gedit Markdown Preview][10], Gedit is perfectly capable of rendering Markdown code.
|
||||
|
||||
Arch users can find it in the AUR as gedit-plugin-markdown_preview package.
|
||||
|
||||
Other Linux users can find the [installation instructions on the project webpage][11].
|
||||
|
||||
Once it is installed, enable it in plugins. You must enable the side panel view from the hamburger menu --> View > Side panel
|
||||
|
||||
![][12]
|
||||
|
||||
With that, it starts showing rendered text for Markdown text in the side or bottom pane.
|
||||
|
||||
![][13]
|
||||
|
||||
### 5. Create snippets
|
||||
|
||||
_Good coders code. Better coders reuse._
|
||||
|
||||
If you find yourself reusing same piece of code or text, you can save it as snippet and insert it when needed. This will save you some time (and frustration).
|
||||
|
||||
Enable the Snippet plugin first.
|
||||
|
||||
![][14]
|
||||
|
||||
Now you can access the snippets from **Hamburger Menu -> Manage Snippets**
|
||||
|
||||
![][15]
|
||||
|
||||
You'll find that it already has several snippets added for various programming languages.
|
||||
|
||||
![][16]
|
||||
|
||||
You can also add your snippets in the desired folder by clicking the + sign on the bottom left. You may also assign a shortcut key to snippets to insert them even more quickly.
|
||||
|
||||
![][17]
|
||||
|
||||
For example, I added a new snippet for [adding a Markdown table][18] and assigned a keyboard shortcut and tab trigger to it (as seen in the above image). Now, if I press **CTRL + Alt + S** in a Markdown document, a table is added. Alternatively, typing **table** and pressing the TAB key also adds the Markdown table.
|
||||
|
||||
> 💡 Usually, the snippets are saved in `/usr/share/gedit/plugins/snippet` folder as XM docs, but I could not find where the newly added snippets are saved.
|
||||
|
||||
### 6. Fix the dark mode problem
|
||||
|
||||
Coders love dark mode. Gedit adheres to the system theme, and if you switch to dark mode at the OS level, it also switches to dark mode.
|
||||
|
||||
The one major problem is that you cannot read anything on the currently selected line because both text and line highlights are white colored.
|
||||
|
||||
![][19]
|
||||
|
||||
There is no fix for this. However, a workaround is to either disable highlighting the current line or use a different color scheme.I prefer choosing a different color scheme.
|
||||
|
||||
Go to Preferences -> Font & Colors and then select a dark color scheme like Oblivion. It will change the color scheme a little but at least you will be able to see the text on the highlighted lines.
|
||||
|
||||
![][20]
|
||||
|
||||
### 7. Quick highlight selected text
|
||||
|
||||
Double-click a word and Gedit highlights all the occurrences of the same word in the entire document.
|
||||
|
||||
![][21]
|
||||
|
||||
This feature is not enabled by default though an official plugin is available.
|
||||
|
||||
Go to Preferences -> Plugins and enable the Quick Highlight option.
|
||||
|
||||
![][22]
|
||||
|
||||
### 8. Show line numbers
|
||||
|
||||
Many code editors show the line numbers by default. It helps you quickly go to the line when you see a 'syntax error at line X'.
|
||||
|
||||
You can enable line numbers by going to **Preferences -> View -> Display Line Numbers:**
|
||||
|
||||
![][23]
|
||||
|
||||
You may also enable or disable it from the bottom.
|
||||
|
||||
![][24]
|
||||
|
||||
### 9. Save a version
|
||||
|
||||
If you are modifying a file, perhaps it would be better to create a backup copy? Gedit can do this automatically.
|
||||
|
||||
Enable this feature in **preferences -> Editor -> Create a Backup copy**.
|
||||
|
||||
![][25]
|
||||
|
||||
A file with the name of the original file appended with a `~` symbol will appear as the backup file.
|
||||
|
||||
![][26]
|
||||
|
||||
### 10. Autosave files
|
||||
|
||||
Since we are talking about versions and backups, how about [enabling autosave in Gedit][27]? This way, if you are working on a document and forgot to save it using Ctrl+S manually, the changes get saved automatically.
|
||||
|
||||
> 🚧 This feature does NOT work on a completely new document that has never been saved on the disk.
|
||||
|
||||
From **Preferences -> Editor**, you can enable the Autosave feature. By default, it autosaves every 10 minutes but you can change the duration to your liking.
|
||||
|
||||
![][28]
|
||||
|
||||
There is also a third-party [smart-auto-save extension][29] that autosaves the document as soon as you stop typing it.
|
||||
|
||||
![][30]
|
||||
|
||||
### Know more Gedit tricks?
|
||||
|
||||
One of the joys of using any piece of software is discovering it's not-so-obvious features.
|
||||
|
||||
Which Gedit tweaks you liked the most here? Do you know a killer Gedit feature that not many people are aware of? Share it with us in the comments?
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/gedit-tweaks/
|
||||
|
||||
作者:[Abhishek Prakash][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/abhishek/
|
||||
[b]: https://github.com/lkxed/
|
||||
[1]: https://itsfoss.com/content/images/2023/03/linux-mega-packt.webp
|
||||
[2]: https://itsfoss.com/content/images/2023/03/PLUGIN-INSTALL-gedit-plugin-saved-to-the-directory.png
|
||||
[3]: https://itsfoss.com/content/images/2023/03/ACCESS-PREFERENCES.png
|
||||
[4]: https://itsfoss.com/content/images/2023/03/PLUGIN-INSTALL-plugins-in-prefereneces.png
|
||||
[5]: https://itsfoss.com/content/images/2023/03/FILE-BROWSER-file-browser-plugin-in-preferences.png
|
||||
[6]: https://itsfoss.com/content/images/2023/03/FILE-BROWSER-file-browser-as-a-side-pane.png
|
||||
[7]: https://itsfoss.com/content/images/2023/03/TERMINAL-gedit-embedded-terminal.png
|
||||
[8]: https://itsfoss.com/content/images/2023/03/TERMINAL-embedded-terminal-plugin-in-plugins-tab.png
|
||||
[9]: https://itsfoss.com/content/images/2023/03/TERMINAL-enable-bottom-panel-for-embedded-terminal.png
|
||||
[10]: https://github.com/maoschanz/gedit-plugin-markdown_preview?ref=itsfoss.com
|
||||
[11]: https://github.com/maoschanz/gedit-plugin-markdown_preview?ref=itsfoss.com#installation
|
||||
[12]: https://itsfoss.com/content/images/2023/03/ENABLE-SIDE-PANEL.png
|
||||
[13]: https://itsfoss.com/content/images/2023/03/MARKDOWN-PREVIEW-markdown-preview.png
|
||||
[14]: https://itsfoss.com/content/images/2023/03/ENABLE-SNIPPET-PLUGLIN.png
|
||||
[15]: https://itsfoss.com/content/images/2023/03/ACCESS-MANAGE-SNIPPET.png
|
||||
[16]: https://itsfoss.com/content/images/2023/03/SNIPPET-pre-created-snippets-in-gedit-showing-cpp-main-snippet.png
|
||||
[17]: https://itsfoss.com/content/images/2023/03/adding-a-custom-markdown-table-snippet.png
|
||||
[18]: https://itsfoss.com/markdown-table/
|
||||
[19]: https://itsfoss.com/content/images/2023/03/DARK-MODE-ISSUE-text-not-visible-in-highlight-line.png
|
||||
[20]: https://itsfoss.com/content/images/2023/03/DARK-MODE-ISSUE-settting-a-new-clor-scheme-to-the-dark-mode-font-issue.png
|
||||
[21]: https://itsfoss.com/content/images/2023/03/QUICK-HIGHLIGHT-result.png
|
||||
[22]: https://itsfoss.com/content/images/2023/03/QUICK-HIGHLIGHT-already-available-plugin-no-external-needed.png
|
||||
[23]: https://itsfoss.com/content/images/2023/03/LINE-NUMBER-display-line-numbers-in-gedit.png
|
||||
[24]: https://itsfoss.com/content/images/2023/03/SHOW-LINE-NUMBERS.png
|
||||
[25]: https://itsfoss.com/content/images/2023/03/SAVE-BACKUP.png
|
||||
[26]: https://itsfoss.com/content/images/2023/03/VERSION-in-file-manager.png
|
||||
[27]: https://itsfoss.com/how-to-enable-auto-save-feature-in-gedit/
|
||||
[28]: https://itsfoss.com/content/images/2023/03/AUTO-SAVE-files-the-built-in-save-function-that-saves-the-document-after-some-time.png
|
||||
[29]: https://github.com/seanh/gedit-smart-autosave/?ref=itsfoss.com
|
||||
[30]: https://itsfoss.com/content/images/2023/03/AUTO-SAVE-Smart-auto-save.png
|
||||
[31]: https://itsfoss.com/flatpak-tips-tweaks/
|
Loading…
Reference in New Issue
Block a user