LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 06-21-2022, 02:44 PM   #1
Tsuga
Member
 
Registered: Jul 2020
Distribution: Slackware64 15.0
Posts: 59

Rep: Reputation: Disabled
Kate editor does not save indentations.


I'm using Kate for editing multiple files. Currently, I'm working with a Python script. I have some blank lines between some sections of code in a declared class. If there is not an indentation between the sections, the interactive session breaks up the sections as if they're separate pieces of code. I've tried using spaces and tabs but with either, when I save the file, the indentation disappears and I have to recreate the indentation again. I used Tools > Indentation > Python and > Normal and neither saves the indentations. What do I need to change to make Kate save the indentations?

Code:
class data(torch.utils.data.Dataset):
    def __init__(self, root, transforms=None, target_transform=None):
        self.root = root
        self.transforms = transforms
        self.target_transform = target_transform
        # load all image files, sorting them to
        # ensure that they are aligned
        self.imgs = list(sorted(os.listdir(os.path.join(root,"image"))))
        self.masks = list(sorted(os.listdir(os.path.join(root,"mask"))))
##This line needs to have an indentation saved to it. 
    def __getitem__(self, idx):
        # load images ad masks
        img_path = os.path.join(self.root, "images", self.imgs[idx])
 
Old 06-21-2022, 03:44 PM   #2
Mark Pettit
Member
 
Registered: Dec 2008
Location: Cape Town, South Africa
Distribution: Slackware 15.0
Posts: 619

Rep: Reputation: 299Reputation: 299Reputation: 299
Have you confirmed, by using an editor such as vi/vim that the indents are in fact missing ? And if you use another editor and edit afterwards with Kate, do they change again ?
 
1 members found this post helpful.
Old 06-21-2022, 04:23 PM   #3
Tsuga
Member
 
Registered: Jul 2020
Distribution: Slackware64 15.0
Posts: 59

Original Poster
Rep: Reputation: Disabled
I made the indents while the file was open in Kate. I saved the file, and the cursor sitting in one of the indents immediately dropped back to the left margin of the editor. I opened the file in Vi and ran the cursor to the two places where there should be indents and the cursor moves to the next line when I use the arrow key to move into what "should" be an indent. I created an indent while in Vi in a couple of places and saved the file and then opened again in Kate. The indents made while the file was open in Vi remained in Kate. But I still can't make an indent and save it in Kate. Does the same thing: on an unindented line, make an indent and save. The cursor instantly drops back to margin like there is no indent.
 
Old 06-21-2022, 07:43 PM   #4
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,323
Blog Entries: 28

Rep: Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141
It's a long shot, in fact a very long shot, but try starting Kate from the command line, creating and saving a test file, closing that tab (but not exiting Kate), then reopening the file. I'm hoping you might get some useful messages to the terminal.

As an aside, I was unable to duplicate this issue with Kate v. 20.12.0 on Mageia v. 8. I had created indentations with both tabs and spaces and they were present when I reopened the file.

Last edited by frankbell; 06-21-2022 at 07:44 PM.
 
Old 06-22-2022, 01:57 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,841

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
Just a comment: there can be issues caused by automatic language detection and formatting, also by auto-indent settings and similar (like tab <=> space replacement).
Additionally (especially for python) we have black, flake8 and other tools to format the code.
 
Old 06-22-2022, 06:50 AM   #6
Tsuga
Member
 
Registered: Jul 2020
Distribution: Slackware64 15.0
Posts: 59

Original Poster
Rep: Reputation: Disabled
I did as you suggested, frankbell.

Code:
~/Documents$ kate
Qt: Session management error: networkIdsList argument is NULL
kf.kio.core: The recently-used.xbel is not an XBEL file, overwriting.
kf.kio.core: The recently-used.xbel is not an XBEL file, overwriting.
kf.kio.core: The recently-used.xbel is not an XBEL file, overwriting.
kf.kio.core: The recently-used.xbel is not an XBEL file, overwriting.
kf.kio.core: The recently-used.xbel is not an XBEL file, overwriting.
kf.kio.core: The recently-used.xbel is not an XBEL file, overwriting.
Those are all the messages from the console while I tried your suggestion.

I created a file, typed a few characters on a line, used tab and space with no characters on following lines, and typed characters with trailing spaces on another lines. It looked like for a moment it was going to save the spaces and indents, but when I opened the files ("all" and .py) back up in the same Kate session, they were not saved. I opened the files in Vi and there were no spaces there as well. I'm using Kate 21.12.3.
 
Old 06-22-2022, 11:04 AM   #7
Tsuga
Member
 
Registered: Jul 2020
Distribution: Slackware64 15.0
Posts: 59

Original Poster
Rep: Reputation: Disabled
I made a system update with slackpkg. I'm on Kate 22.04.2 and still have the same issue. I'll submit a bug report I suppose.
 
Old 06-22-2022, 11:07 AM   #8
ppr:kut
Slackware Contributor
 
Registered: Aug 2006
Location: Netherlands
Distribution: Slackware
Posts: 631

Rep: Reputation: 463Reputation: 463Reputation: 463Reputation: 463Reputation: 463
There's a setting in kate that automatically removes spaces on empty lines when you save a file.

Settings -> Configure Kate... -> Open/Save -> General -> Automatic Cleanups on Save -> Remove trailing spaces

This is also a setting that can be controlled from editorconfig files. So if you work on a project using those, what's defined in them overrides whatever is configured in kate.
 
2 members found this post helpful.
Old 06-22-2022, 11:24 AM   #9
Tsuga
Member
 
Registered: Jul 2020
Distribution: Slackware64 15.0
Posts: 59

Original Poster
Rep: Reputation: Disabled
That was it, ppr:kut. Much obliged.
 
1 members found this post helpful.
  


Reply

Tags
configuration, kate



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Kate text editor to write new .csv and can't save file deretsigernu Slackware 8 10-04-2017 09:34 PM
LXer: Kate/KDevelop October Sprint: What's new in Kate LXer Syndicated Linux News 0 11-24-2012 10:20 PM
LXer: Getting Started With the Kate Text Editor: Kate For Coders LXer Syndicated Linux News 0 04-01-2009 11:40 PM
I want Openoffice to have preset ruler indentations newbiesforever Linux - Software 2 11-20-2006 12:17 PM
Kate Is Not Working, Kate editor is not starting in Redhat 9 apur Linux - General 4 05-11-2004 09:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 07:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration