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.
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.
With permission of Ansgar Wiechers, I post a sed 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 vim, so as extra I will post a one-liner that does the same than the previous sed 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With