2

The Kate text editor has a default line length of 1024 chars. I need to change this. And I need to change it via a bash script (it's for automated installs).

Here's some background: https://stackoverflow.com/a/13496876/463994

I would appreciate a bash script that changes that sets the default line length to 0 chars.

Community
  • 1
  • 1
MountainX
  • 6,217
  • 8
  • 52
  • 83
  • 1
    I don't use KDE, but according to [this answer](http://askubuntu.com/a/168413) on AskUbuntu there should be a config file `/home/$USER/.kde/share/config/katerc`. I'd check that file for the line-length setting. Once you identified the setting, you can probably modify it via `sed`. – Ansgar Wiechers Jul 13 '13 at 22:18
  • @AnsgarWiechers - yes indeed, that file contains `Line Length Limit=` which is what I need to change. Thanks! – MountainX Jul 13 '13 at 22:38
  • If you can give me the `sed` line that will change `Line Length Limit=` to `Line Length Limit=0` I'll accept your answer. Even better, how would I use sed to comment out the original value and insert the new line right below it? – MountainX Jul 13 '13 at 22:41

2 Answers2

6

If KDE is installed, use kwriteconfig. This is a KDE tool to modify config files:

kwriteconfig --file katerc --group "Kate Document Defaults" --key "Line Length Limit" 0

The value 0 entirely disables the line length limit. In this case, the edited file is katerc, located in ~/.kde4/share/config/. Of course, you can choose any other file here, such as kilerc.

dhaumann
  • 1,590
  • 13
  • 25
4

With permission of Ansgar Wiechers, I post a solution that seems to work for me:

sed -i.bak -e 's/^Line Length Limit=.*$/##&\nLine Length Limit=0/' ~/.kde4/share/config/katerc

It comments current value adding ## at the beginning of the line and appending after that the same with 0 as value. I use the -i switch that appends a .bak suffix as backup to the original file. Use sed -i -e ... (note the space between both switches) to modify the file in place. Be careful with this last option.


In my case, I prefer to modify files in-place with , so as extra I will post a one-liner that does the same than the previous command, only that its backup file is suffixed with ~:

vim \
    +'/^\v\cline\s+length\s+limit' \
    -u NONE \
    -N \
    -c 'set backup | yank | s/\v^/##/ | put | s/\v(\=\s*)\d+/\10/ | x' \
~/.kde4/share/config/katerc
Birei
  • 35,723
  • 2
  • 77
  • 82
  • Thank you! That's excellent. It works and I learned something useful about `sed`. (I'll stick with the sed solution for now.) – MountainX Jul 14 '13 at 01:43