16

Some programs require tab characters to work, e.g. make requires tabs in Makefiles. If gedit is configured to replace tabs with spaces, it's painful to change the settings every time or copy a character from another document.

I'm using 3.10.4 on Ubuntu 15.04.

5 Answers 5

15

You can insert a literal Tab character in gedit by using the GNOME Unicode input mode:

Ctrl + Shift + U

and then enter 9 followed by Enter. The horizontal tab character is Unicode code point U+0009. This will insert a tab regardless of your preferences to expand tabs or not.

1
  • The most suitable answer for me. Also, if gedit has automatic indentation enabled this should be done once per block, as subsequent lines will inherit TAB as indentation symbol(s).
    – dess
    Oct 3, 2021 at 10:11
6

You can create shortcuts to quickly change this setting:

gsettings set org.gnome.gedit.preferences.editor insert-spaces false
1
  • 1
    Good idea. I Would remove the hint that it's possible to use another program because people might see a reason to not upvote because the title indicates that the question is about gedit. Sep 2, 2015 at 9:00
4

Install a plugin for gedit

  1. Clone the repository git://git.gitano.org.uk/personal/liw/makefiletab3.git

    mkdir -p ~/src
    cd src
    git clone git://git.gitano.org.uk/personal/liw/makefiletab3.git
    
  2. Create the plugin folder for gedit

    mkdir -p ~/.local/share/gedit/plugins
    
  3. Create a symbolic link

    ln -s ~/src/makefiletab3 ~/.local/share/gedit/plugins/makefiletab3
    
  4. Change the Python version in makefiletab3.plugin

    Open the file

    nano ~/.local/share/gedit/plugins/makefiletab3/makefiletab3.plugin
    

    and replace

    Loader=python
    

    with

    Loader=python3
    
  5. Restart gedit and activate the plugin

    enter image description here

3
1

If you wanted to insert a number of tabs into a script or document without changing the tab configuration in gedit:

  • Wherever a tab is required enter a unique string of characters (e.g. tab!) to be used as a replace token when needed.
  • When you need the actual tabs, use Find and Replace (CTRL+H) to find the tab! and replace with \t
0

Whenever you need to use a tab character instead of space characters, click on "Tab Width" in Gedit's bottom bar, and uncheck "Use Spaces" check box.

When you are done inserting your tab character(s), simply click on "Tab Width" again, and reset the number of spaces (2, 4, or 8) that represent a tab. Obviously, this only works if you are using one of the default values of 2, 4, or 8 spaces. enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .