Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
4
votes
7
answers
1927
views
insert current date into text document while editing it in Kate
I would like to insert the current date into an open Kate text document while editing it by using a shortcut key combination. I see several such options for Atom, but I don't find anything for Kate.
I would like to insert the current date into an open Kate text document while editing it by using a shortcut key combination.
I see several such options for Atom, but I don't find anything for Kate.
MountainX
(18888 rep)
Jun 22, 2018, 09:00 PM
• Last activity: Jul 22, 2025, 02:36 AM
3
votes
3
answers
2739
views
Prevent Nano from creating .save files?
I have a problem with the `Nano` editor. If it ever exits unexpectedly, it leaves behind `.save` files, which are just versions of the edits I was making. Is there a way to disable this behaviour?
I have a problem with the
Nano
editor. If it ever exits unexpectedly, it leaves behind .save
files, which are just versions of the edits I was making. Is there a way to disable this behaviour?
Levi H
(123 rep)
Sep 20, 2018, 10:23 AM
• Last activity: Jun 30, 2025, 01:55 AM
3
votes
1
answers
2676
views
nano - soft wrap at 80 characters
I would like `nano` to soft-wrap at 80 characters. That is, as I keep typing, the text should flow to the next line beyond 80 characters, without `nano` insert a `\n` newline at 80 characters. set softwrap set tabsize 4 set tabstospaces set fill 72 However, this inserts a newline after each line, wh...
I would like
nano
to soft-wrap at 80 characters. That is, as I keep typing, the text should flow to the next line beyond 80 characters, without nano
insert a \n
newline at 80 characters.
set softwrap
set tabsize 4
set tabstospaces
set fill 72
However, this inserts a newline after each line, when tested with cat.
How do I softwrap and fill simultaneously?
Karthik Nishanth
(133 rep)
Jul 8, 2017, 04:27 PM
• Last activity: Jun 27, 2025, 07:00 AM
49
votes
19
answers
22883
views
Console Text Editor with Windows-like keyboard shortcuts (ctrl-z, x, c, v)
Ok, I realise that I risk a religious war asking a question about text editors, but here goes. # Requirements - Mostly used for config file edits - Text based not GUI - Available for Raspian flavour of Debian - No learning required for a Windows/Mac GUI user (no vi/vim) - Makes full use of keys foun...
Ok, I realise that I risk a religious war asking a question about text editors, but here goes.
# Requirements
- Mostly used for config file edits
- Text based not GUI
- Available for Raspian flavour of Debian
- No learning required for a Windows/Mac GUI user (no vi/vim)
- Makes full use of keys found on modern keyboards, i.e. home, end, pgup, pgdn, del
- Use keyboard shortcuts found in pretty much all GUI apps,
e.g. Undo (Ctrl-Z), Redo (Shift-Ctrl-Z),
Select All (Ctrl-A), Cut (Ctrl-X), Copy (Ctrl-C),
Paste (Ctrl-V), Expand selection (Shift-Arrow), Skip word (Ctrl-Arrow), Delete selection (Del) etc
- **Optional**: mouse support for changing cursor position and selecting text
Surely this isn't a big ask in this day and age?
Greg Woods
(611 rep)
Oct 3, 2012, 07:57 PM
• Last activity: Jun 25, 2025, 04:22 PM
2
votes
2
answers
8223
views
What's the best way to display tabs/spaces in my plain text files
I have a file that unfortunately contains both tabs and spaces. How do I display them so I know if a particular space is actually tab or space?
I have a file that unfortunately contains both tabs and spaces.
How do I display them so I know if a particular space is actually tab or space?
CuriousMind
(289 rep)
Oct 19, 2015, 04:15 PM
• Last activity: Jun 10, 2025, 06:20 AM
79
votes
6
answers
59346
views
Change default editor to vim for _ sudo systemctl edit [unit-file] _
*[4.13.12-1-ARCH with gnome3 and gdm on Xorg]* I already have set my VISUAL and EDITOR env-vars to `vim`. Similarly I did try `SYSTEMD_EDITOR="vim"; export SYSTEMD_EDITOR` in my ~/.bashrc, to no avail. When modifying unit files in Arch (systemd) via $ sudo systemctl edit _unit_ I find myself staring...
*[4.13.12-1-ARCH with gnome3 and gdm on Xorg]*
I already have set my VISUAL and EDITOR env-vars to
vim
. Similarly I did try SYSTEMD_EDITOR="vim"; export SYSTEMD_EDITOR
in my ~/.bashrc, to no avail.
When modifying unit files in Arch (systemd) via
$ sudo systemctl edit _unit_
I find myself staring at nano
. Life is too short and I want vim
by all means. How do I do this ?
Cbhihe
(2880 rep)
Dec 2, 2017, 06:11 PM
• Last activity: May 25, 2025, 07:41 AM
11
votes
1
answers
1159
views
Why doesn't visudo, like sudoedit, spawn a text editor as a regular user?
As far as I know, `sudoedit` gives a user permission to edit a file that is owned and writable by root. It makes a copy of that file, the copy is owned by the user, and then it spawns a text editor with the privileges of the user. In this way, it avoids the dangers of running a text editor as root (...
As far as I know,
sudoedit
gives a user permission to edit a file that is owned and writable by root.
It makes a copy of that file, the copy is owned by the user, and then it spawns a text editor with the privileges of the user.
In this way, it avoids the dangers of running a text editor as root (shell escapes).
On the other hand, visudo
also makes a copy of the sudoers
file. However, that copy is owned by root and it spawns a text editor with root privileges.
Also, on a Debian 12 system I tried, you can get a root shell from within visudo
: it spawns an instance of nano
and via the _Execute_ option in nano
you can get a shell escape.
For example, if you type cat /etc/shadow
to _Execute_, it works.
Why does visudo
spawn a text editor as root?
Why can't it do what sudoedit
does (make a copy owned by the user, spawn a text editor as the user)?
Wouldn't that be more secure?
At least, shouldn't it block shell escapes from within the text editor that it spawns as root?
Why doesn't it do that?
codeandfire
(215 rep)
May 20, 2025, 02:35 PM
• Last activity: May 22, 2025, 09:38 AM
57
votes
3
answers
74581
views
How can I set the default editor as nano on my Mac?
I have vim as default editor on my Mac and every time I run commands on Mac terminal, it automatically opens "vim". How can I set up "nano" instead and make sure the terminal will open "nano" every time is needed?
I have vim as default editor on my Mac and every time I run commands on Mac terminal, it automatically opens "vim".
How can I set up "nano" instead and make sure the terminal will open "nano" every time is needed?
g_tech
(673 rep)
Feb 20, 2019, 01:45 PM
• Last activity: May 6, 2025, 07:12 PM
0
votes
1
answers
2253
views
How to batch-edit pdfs to remove headers and footers
I have a large number of .pdf files with much the same headers and footers that I’d like to remove. Is there a something that can remove everything up to a known string and everything after a different known string leaving a valid .pdf?
I have a large number of .pdf files with much the same headers and footers that I’d like to remove.
Is there a something that can remove everything up to a known string and everything after a different known string leaving a valid .pdf?
Peter Brooks
(211 rep)
May 1, 2020, 04:56 PM
• Last activity: May 6, 2025, 12:06 PM
9
votes
8
answers
10726
views
How to align fstab entries easily
Editing /etc/fstab with my text editor makes all the spacing go out of alignment. I could go through the file and insert/delete spaces to line everything up, but I'm looking for a more automated solution. Ideally, there would be an online javascript page that I could put my fstab into, and have it "...
Editing /etc/fstab with my text editor makes all the spacing go out of alignment. I could go through the file and insert/delete spaces to line everything up, but I'm looking for a more automated solution. Ideally, there would be an online javascript page that I could put my fstab into, and have it "pretty" align everything. Then I could copy/paste the final result back into the file.
Is there a similar or better solution to this available?
EDIT:
I use Linux on my desktop, and I'm not seeking to join the religion of vi or emacs just to edit my fstab. Emacs might be a better solution for some people, but for some other people it's not a better solution.
EDIT2:
Here is an example snippet of my fstab using tabs. The columns are not in alignment.
proc /proc proc nodev,noexec,nosuid 0 0
/dev/disk/by-label/Linux / ext4 errors=remount-ro 0 1
/dev/disk/by-label/Home /home ext4 defaults 0 0
I want it to be automatically formatted with spaces and look more like the following.
proc /proc proc nodev,noexec,nosuid 0 0
/dev/disk/by-label/Linux / ext4 errors=remount-ro 0 1
/dev/disk/by-label/Home /home ext4 defaults 0 0
Sepero
(1619 rep)
Oct 14, 2013, 08:21 PM
• Last activity: Apr 22, 2025, 07:59 PM
7
votes
5
answers
8382
views
What are good text editors with RTL (right-to-left) support?
`gvim` doesn't seem to support it out of the box on my Ubuntu lucid.
gvim
doesn't seem to support it out of the box on my Ubuntu lucid.
ripper234
(32413 rep)
Apr 27, 2011, 02:55 PM
• Last activity: Mar 14, 2025, 06:08 PM
3
votes
1
answers
1829
views
Choice of editor when running under sudo
On an Ubuntu 12.04 machine I've used the alternatives system to set the **editor** to **vim.basic**. I get the correct editor when root but not when I sudo to root and run crontab, and I'm trying to understand why. A bit more detail. The alternative **editor** is currently set to **vim.basic** by ma...
On an Ubuntu 12.04 machine I've used the alternatives system to set the **editor** to **vim.basic**. I get the correct editor when root but not when I sudo to root and run crontab, and I'm trying to understand why.
A bit more detail. The alternative **editor** is currently set to **vim.basic** by manual mode (output trimmed):
% sudo update-alternatives --set editor /usr/bin/vim.basic
% update-alternatives --display editor
editor - manual mode
link currently points to /usr/bin/vim.basic
/bin/nano - priority 40
slave editor.1.gz: /usr/share/man/man1/nano.1.gz
/usr/bin/vim.basic - priority 30
slave editor.1.gz: /usr/share/man/man1/vim.1.gz
slave editor.fr.1.gz: /usr/share/man/fr/man1/vim.1.gz
slave editor.it.1.gz: /usr/share/man/it/man1/vim.1.gz
slave editor.pl.1.gz: /usr/share/man/pl/man1/vim.1.gz
slave editor.ru.1.gz: /usr/share/man/ru/man1/vim.1.gz
Current 'best' version is '/bin/nano'.
If I sudo to root and edit crontab the editor is vim.basic:
% sudo -i
% crontab -e
# editor is vim; :help shows
# *help.txt* For Vim version 7.3. Last change: 2010 Jul 20
EDITOR and SHELL as root:
# env | grep -i editor
EDITOR=vim
# echo $0
-bash
However as a normal user if I sudo crontab the editor is nano:
% sudo crontab -e
# GNU nano 2.2.6
EDITOR and SHELL as normal user:
% env | grep -i editor
EDITOR=vim
% echo $0
zsh
Now I'm noticing that **nano** has a higher priority (40) than **vim.basic** (30), so I could change the priority of vim.basic. But that defeats the purpose of **manual mode**.
**Update**
I've noticed that using **sudo -E** gives the correct editor, implying problem is environment related. That is:
sudo crontab -e # nano editor is used
sudo -E crontab -e # vim editor is used
Sonia Hamilton
(165 rep)
Sep 11, 2014, 03:02 AM
• Last activity: Dec 22, 2024, 06:49 AM
0
votes
2
answers
176
views
Paste text into sam editor from an external application
I am running the editor sam as a standalone application on Linux. I am using this version: git clone https://github.com/9fans/plan9port plan9 So far I have not been able to figure out a way to paste text into the *bitmap* display from an external Linux application. Is there a way to achieve this?
I am running the editor sam as a standalone application on Linux. I am using this version:
git clone https://github.com/9fans/plan9port plan9
So far I have not been able to figure out a way to paste text into the *bitmap* display from an external Linux application. Is there a way to achieve this?
edman
(588 rep)
Jul 18, 2021, 02:50 PM
• Last activity: Oct 25, 2024, 06:43 AM
0
votes
2
answers
5788
views
Opening .xlsx file in linux terminal
I work in a cluster. I would like to ask if it is possible to open .xlsx files in text editors like nano or vim. Is there any possible way if I have not Microsoft Excel (or any relevant application in my PC) to read the file. If it helps my laptop is Windows and I connect via Mobaxterm to the cluste...
I work in a cluster. I would like to ask if it is possible to open .xlsx files in text editors like nano or vim.
Is there any possible way if I have not Microsoft Excel (or any relevant application in my PC) to read the file.
If it helps my laptop is Windows and I connect via Mobaxterm to the cluster.
$ lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: Rocky
Description: Rocky Linux release 9.4 (Blue Onyx)
Release: 9.4
Codename: BlueOnyx
Dimitris Tsiaousidis
(9 rep)
Sep 13, 2024, 09:07 AM
• Last activity: Oct 7, 2024, 06:46 AM
1
votes
0
answers
62
views
Changing the charset for double click highlight in Mousepad editor
Can I modify the character set which is used to recognize a single word for the double click word highlight in [Mousepad][1], the default text editor in Debian xfce4? Eg. I would like to highlight words separated by `m` letter and the space. Then in the word `memory` two words would be highligted `e...
Can I modify the character set which is used to recognize a single word for the double click word highlight in Mousepad , the default text editor in Debian xfce4?
Eg. I would like to highlight words separated by
m
letter and the space. Then in the word memory
two words would be highligted e
and ory
. When one double-clicks on e
, e
will be highlighted, and when one double-clicks ory
, ory
will be higligted.
I mean a way to change the charset that defines separators when one double-clicks words in the editor.
trzczy
(680 rep)
Sep 29, 2024, 10:34 AM
• Last activity: Sep 30, 2024, 03:17 PM
34
votes
4
answers
23571
views
How to automatically strip trailing spaces on save in Vi and Vim?
Is there a `.vimrc` setting to automatically remove trailing whitespace when saving a file? Ideally (to be safe) I would like to only have this functionality for certain files, e.g. `*.rb`
Is there a
.vimrc
setting to automatically remove trailing whitespace when saving a file?
Ideally (to be safe) I would like to only have this functionality for certain files, e.g. *.rb
Michael Durrant
(43563 rep)
May 11, 2013, 12:50 PM
• Last activity: Aug 24, 2024, 05:43 PM
1
votes
2
answers
680
views
How to detect the linux distribution name in Neovim init.lua
How can I detect in my neovim `~/.config/nvim/init.lua` configuration which operating system distribution nvim is running? I want different Neovim configurations on debian servers as on my fedora linux workstation machines. - `vim.loop.os_uname()` only detects 'Linux'. - Is there some builtin like t...
How can I detect in my neovim
~/.config/nvim/init.lua
configuration which operating system distribution nvim is running? I want different Neovim configurations on debian servers as on my fedora linux workstation machines.
- vim.loop.os_uname()
only detects 'Linux'.
- Is there some builtin like the /etc/os-release
file?
Simon Schürg
(241 rep)
Feb 28, 2023, 07:56 PM
• Last activity: Aug 13, 2024, 12:04 AM
100
votes
7
answers
55637
views
How to edit command line in full screen editor in ZSH?
In bash, using vi mode, if I hit Esc , v , my current command line is opened in the editor specified by `$EDITOR` and I am able to edit it in full screen before 'saving' the command to be returned to the shell and executed. How can I achieve similar behaviour in zsh? Hitting v in command mode result...
In bash, using vi mode, if I hit Esc,v, my current command line is opened in the editor specified by
$EDITOR
and I am able to edit it in full screen before 'saving' the command to be returned to the shell and executed.
How can I achieve similar behaviour in zsh? Hitting v in command mode results in a bell an has no apparent effect, despite the EDITOR
environment variable being set.
Murali Suriar
(2944 rep)
Jan 29, 2011, 12:32 AM
• Last activity: Jul 3, 2024, 09:12 PM
10
votes
2
answers
9625
views
How to 'UnJustify!' text in GNU nano
I enjoy using `nano` as a respite from my usual GTK-based text editor. I like the simplicity of the interface, and using CTRL-K is the fastest way I know of to edit down long textfiles. However, I have one major gripe: whenever I justify text using CTRL-J, the editor prints the smug little message `...
I enjoy using
nano
as a respite from my usual GTK-based text editor. I like the simplicity of the interface, and using CTRL-K is the fastest way I know of to edit down long textfiles.
However, I have one major gripe: whenever I justify text using CTRL-J, the editor prints the smug little message Can now UnJustify!
-- yet I have not been able to find a way to unjustify text. Pressing M-U (which a Google search could reveal, M-U not being mentioned at all in the program's help files) simply seems to cause a glitch. The keyboard becomes unresponsive. Am I missing something?
ixtmixilix
(13520 rep)
Jul 12, 2011, 01:07 PM
• Last activity: Jun 1, 2024, 07:21 PM
1
votes
1
answers
207
views
How to regex/escape backslash in Debian (Gnome) Text Editor?
In [Gnome's Text Editor](https://gitlab.gnome.org/GNOME/gnome-text-editor) (`gnome-text-editor` aka `gted` from the `gnome-text-editor` Debian package), I cannot get replacement of starting lines (-) at newlines by *\item*. [![enter image description here][1]][1] I escape the item but does not work....
In [Gnome's Text Editor](https://gitlab.gnome.org/GNOME/gnome-text-editor) (
I escape the item but does not work.
OS: Debian latest
gnome-text-editor
aka gted
from the gnome-text-editor
Debian package), I cannot get replacement of starting lines (-) at newlines by *\item*.

Léo Léopold Hertz 준영
(7138 rep)
May 11, 2024, 04:30 PM
• Last activity: May 15, 2024, 08:07 PM
Showing page 1 of 20 total questions