How to get gedit for auto-indented code

I am trying to get gedit to automatically enter my code. The "Auto-indent" checkbox in the settings does not work. Is there a way to get gedit for auto-indented code? (By the way, I really care a lot about the release of C ++. I don't need an indent for any other language.)

+42
gedit auto-indent
Nov 23 '11 at 16:33
source share
4 answers

The smart text completion plugin for gedit does exactly what you describe: https://github.com/nymanjens/gedit-intelligent-text-completion

For those trying to figure out how to copy the intelligent_text_completion.plugin and intelligent_text_completion.py files to .local/share/gedit/plugins , follow these steps:

 user@example:~/.local/share$ cd ~/.local/share/ user@example:~/.local/share$ mkdir gedit user@example:~/.local/share$ cd gedit/ user@example:~/.local/share/gedit$ mkdir plugins user@example:~$ cp intelligent_text_completion.plugin intelligent_text_completion.py ~/.local/share/gedit/plugins/ 
+23
Feb 18 '12 at 15:00
source share

gedit has auto-indent function, go to

Edit -> Preferences -> Editor -> Third line

+24
Nov 06 '12 at 20:00
source share

Here is another workaround: you can use vim to indent automatically and automatically format your code from within Gedit.

First make sure vim is installed. Then add the β€œexternal tool” to Gedit from the β€œtools” menu and use the following code:

 #!/bin/sh CMD_FILE_NAME=.formatcommand; TMP_FILE_NAME=.tempvimfile; touch $CMD_FILE_NAME&&echo "gg=G :wq! "$TMP_FILE_NAME > $CMD_FILE_NAME&&(vim $GEDIT_CURRENT_DOCUMENT_NAME -s $CMD_FILE_NAME > /dev/null 2>/dev/null)&&rm $CMD_FILE_NAME; cat $TMP_FILE_NAME rm $TMP_FILE_NAME 

Also make sure that:

  • "Save" is set to "Current Document".
  • Input is set to Nothing.
  • "Exit" is set to "Replace current document."

You can also customize the hotkey, I prefer Alt + Shift + F, like Netbeans. Now, when you press the hot key, the current file will be saved and automatically formatted.

This will work in any programming language / script, given the correct file extension

If you don't get the indent, insert filetype indent on in your ~/.vimrc file and it will work.

For more details see my personal blog.

+18
Jun 07 2018-12-06T00:
source share

Ubuntu 16.04 and Gedit

  • Activate External Tools Plugin

    Edit β†’ Preferences β†’ Plugins β†’ External Tools

  • External Tool Management

    Tools β†’ Manage External Tools

  • Add tool

    • Click the + button in the lower left corner of Office External Tools
    • You can rename the new tool at any time convenient for you, for example JSON Formatter
    • Refer to the image below and adjust it accordingly.

    Managing snapshots of external tools

0
Feb 25 '17 at 7:51 on
source share



All Articles