Bug 145664 - RFE: (KatePart trunk) Add option to insert tab with tab key even when indenting with spaces
Summary: RFE: (KatePart trunk) Add option to insert tab with tab key even when indenti...
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
: 172950 184260 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-05-19 09:15 UTC by Kevin Kofler
Modified: 2015-08-11 11:16 UTC (History)
9 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Kofler 2007-05-19 09:15:11 UTC
Version:           KDE 3.90.1 (using KDE Devel)
Installed from:    Compiled sources
Compiler:          g++ 4.1.1-51.fc6 
OS:                Linux

I normally indent with spaces, so I want to have the indentation mode set to spaces, however when I press the TAB key, I really really want a tab, not a bunch of spaces, I'd have pressed the space key if I wanted that! ;-)

I don't think I'm the only one who wants that, thus this RFE.

Note that I can get the KDE 3.5 KatePart to mostly do what I want by disabling "use spaces instead of tabs" under Editing and enabling it under Indentation (and also disabling the "Emacs-style" option, which isn't there in KDE 3.90.1 anymore either), but the fact that this works is probably more accidental than intentional. :-)

Speaking of that "Emacs-style" option which can't be disabled anymore, I think that's a horrible way to do indentation. For example, the following code:
[TAB]if (foo
[TAB]____&& bar)
will only align correctly independently of the tabstop setting (which is something the user should be able to set, otherwise what's the point of using tabs at all?) if tabs are used where I used [TAB] and spaces where I used _. The "Emacs-style" indentation breaks that (try it with 4-space tabs and it will change the spaces to a tab, then try switching to 8-space tabs and look at the resulting mess!).

But that's a separate issue, the fact that the tab key can't be configured to simply insert a tab without setting the indentation mode to tabs throughout is much worse.
Comment 1 Dominik Haumann 2007-05-19 11:35:32 UTC
Switch to Command Line (F7), type 'char 9' and a tab is inserted
Comment 2 Kevin Kofler 2007-05-19 22:48:04 UTC
Unfortunately, that doesn't work either (it also inserts a bunch of spaces in space-indentation mode, at least in KWrite), and it isn't quite what I'm after anyway (8 keypresses all over the keyboard to insert 1 character).
Comment 3 Mildred 2007-06-07 09:34:36 UTC
What about creating a shortcut to do that ? for example shift+tab would do.
And of course you could change it.
Comment 4 Christoph Cullmann 2009-04-22 16:26:24 UTC
*** Bug 172950 has been marked as a duplicate of this bug. ***
Comment 5 Erlend Hamberg 2009-04-24 17:40:27 UTC
i suggest doing it like vim does it: have one special key press who inserts whatever you press afterwards literally.

that way one can insert a tab even if tabs are set to expand to spaces, insert a special character like escape and so on.

in vim it is also possible to press number keys to insert an ascii code or, by prepending the numbers with 'u', insert a unicode char.

examples:

<key combo><tab> inserts a tab character
<key combo>009   inserts a tab character
<key combo>u0937 inserts a 'Ω'
<key combo>ux3c0 inserts a 'π' ('x' indicates hexadecimal)
Comment 6 gd2shoe 2009-08-01 23:39:58 UTC
There's a reason I'm using kwrite instead of vim or emacs.  If I wanted to use vim as my default editor, I would.

If you want to have an editor that replaces tabs with spaces by default, that's fine (though strongly not my preference).  It must be intuitive to get them back, though.  Anything less frustrates users.  

MS style access to code-points is fine and all, but if I cannot make the tab key produce x09, then something is seriously wrong.  Chew on that for a minute.

(Note that I did find the answer to my problem in bug report 172950.  What should be intuitively obvious is as obscure as it could possibly be.  I think most non-programmers still wouldn't be able to figure it out, let alone find the solution.)

The mantra that should be followed: Get out of my way and let me work!
Comment 7 Christoph Cullmann 2011-06-26 13:46:46 UTC
In newer Kate versions, you can configure shortcut for "insert tab char".
If you don't enforce indent with spaces, tabs are insertable anyway, if you enforce indent with spaces, you can use that shortcut.
Comment 8 Kevin Kofler 2011-06-26 14:54:22 UTC
Uh, being able to set an obscure shortcut is no substitute for having the Tab key behave as designed.
Comment 9 Kevin Kofler 2011-06-26 15:00:00 UTC
Well, actually, Tab can be used as a shortcut, but:
* This is not a very intuitive way to set this up.
* The "insert tab" action does not behave like normal typing: For example, it always INSERTS a tab, even if you have text selected, it doesn't replace the selected text.
* Kate also messes with my indentation characters in other cases, e.g. when I paste stuff from the clipboard. So I can't even copy a line of code with unchanged indentation without changing my indentation settings all the time.

There really needs to be a "Don't mess with my indentation characters" option.
Comment 10 Kevin Kofler 2011-07-28 16:59:02 UTC
There is also no way to set a shortcut for "insert tab char" in other applications embedding the KatePart, e.g. Krusader.
Comment 11 Christoph Cullmann 2012-11-03 14:36:43 UTC
*** Bug 184260 has been marked as a duplicate of this bug. ***
Comment 12 Kåre Särs 2015-08-11 11:16:05 UTC
There was a bug that the "Insert Tab" action that it did not overwrite selected text, but that was fixed actually quite some time ago.

I am able to use the shortcut in KWrite and Kate... I think it should also appear in all applications that use the KatePart

It is not the nicest or most intuitive way but it gets it done... :)

Please reopen if it does not work in some situation. I will close this as fixed as the added Insert Tab action works for me.