Looking for Column Mode editor (like IBM's XEDIT or KEDIT)
Linux - DesktopThis forum is for the discussion of all Linux Software used in a desktop context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Debian ("jessie", "squeeze"), Linux Mint (Serena), XUbuntu
Posts: 221
Rep:
Looking for Column Mode editor (like IBM's XEDIT or KEDIT)
Greetings LQ'ers
I used to use XEDIT on IBM/Mainframes and KEDIT in DOS, and they both had the
ability to delete or copy certain columns of long text files (all the way down,
not just one line at a time). Anyone who has used those editors knows what I
mean. VI has something called column mode, but I have never been able to figure
out how to make it do what I want.
I am amazed to have found no easy way (short of Perl, Python, C) to delete
certain columns (or truncate lines) in an ASCII file.
Open to all suggestions. SED, a special line truncation command, or an
(open source) editor with column mode.
Thanks lots!
PS -- There is an open source dummy editor called XEDIT -- it doesn't do what IBM's
XEDIT did.
The closest in "vi" may be the blockwise visual mode. Position the cursor to the first character in the column. Then press "CTRL-v". Now you can move the cursor to the right and down to select the other characters in the block.
Then you can press "x" to delete the column, or "y" to yank (copy) the column or block. This could be used to select a column or even a block from the middle of the page.
I don't think that pasting it would result in the extra spaces needed being added to the end of short lines however. I'm not an expert in using vi. You could use a regular expression to delete certain characters on a line within a range of characters. The percent character is used to select a line range covering the entire document. ":%s/^...//" would delete the first three characters of every line for example. It is also possible to yank regions into a register and paste that register later.
I've used a similar editor program (dos based) at work to quickly take a file listing and convert it into a script by inserting a command and pasting the filenames twice, before making certain global changes to one of the columns.
A similar thing could be done in vi:
:%s/^\(.*\)$/mv \1 \1.bu/
This would create a rename script adding .bu to a file list. Of course a bash script to do the same thing whould be a snap as well.
Distribution: Debian ("jessie", "squeeze"), Linux Mint (Serena), XUbuntu
Posts: 221
Original Poster
Rep:
Thank you all! My willingness to use sed indicated I was game for
awk, but hadn't yet figured out if it would help! Knowing about le
sounds great, and I'll have to check out cut. Re: Anomie's question about truncate. In this particular case, I wanted
to remove the final four columns of a fixed column width file (it had
been created by printf's in C.), thus truncate. In fact, the general
solutions you presented for column editing were even more what I
was hoping for.
# Version: 1.13.4
# Entered-date: 2006-11-30
# Description: LE has many block operations with stream and rectangular blocks, can edit both unix and dos style files (LF/CRLF), is binary clean, has hex mode, can edit text with multibyte character encoding, has full undo/redo, can edit files and mmap'able devices in mmap shared mode (only replace), has tunable syntax highlighting, tunable color scheme (can use default colors), tunable key map, tunable menu. It is slightly similar to Norton Editor for DOS, but has more features.
Re: Anomie's question about truncate. In this particular case, I wanted
to remove the final four columns of a fixed column width file (it had
been created by printf's in C.), thus truncate.
In that case, gawk may be an option for you. It can handle fixed-width fields/columns using the FIELDWIDTHS special variable.
In this case I've identified that there are four columns in data-file, which are 4 bytes, 10 bytes, 4 bytes, and 5 bytes. Then I am printing to stdout only the first three columns. And.. I am only printing the first 3 bytes of the third column.
Distribution: Debian ("jessie", "squeeze"), Linux Mint (Serena), XUbuntu
Posts: 221
Original Poster
Rep:
le -- block mode
Hi -- makyo. I tried out LE's block mode.
At first I couldn't find what I was looking for, but then
I did. LOVELY.
For others on this thread.
F4 B to begin a block
F4 E to close the block (selected text now highlighted)
Default block type is rows, but then do an F4 T to
change type of block to columns. It is now easy to delete
selected columns in any range of lines in the file.
I have been crunching data urgently for past couple of days
and this just saved me a bunch of time!!
Distribution: Kubuntu 14.04 (Dell Linux-preinstalled laptop + 2 other laptops)
Posts: 117
Rep:
KDE editors (KATE or KWrite) have block mode
You said:
I am amazed to have found no easy way (short of Perl, Python, C) to delete certain columns (or truncate lines) in an ASCII file.
Well, yes, there is. I, in turn, am amazed that with all the replies so far, no one has mentioned that KWrite and KATE (the KDE Advanced Text Editor that comes with any basic KDE installation) have block mode.
Main Menu > E)dit > B)lock selection mode, or use Ctrl-Shift-B, to switch between the two. Then you can select one or more columns of text "all the way down", or from a particular line to another line of your choice. You basically highlight in a rectangular area, and you can cut, paste, copy, etc. And then you can switch back to non-block mode for normal editing.
There must be some GNOME equivalent if you're not a KDE user; perhaps someone more familiar with GNOME can add a comment here. Of course, if you want to mess around with sed, awk, or Python, that's your choice ...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.