Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
I'm performing an editing process for the first time in CentOS that I'm accustomed to perform in Windows. At one step a web-based validator looks for errors in a JSON ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2013
    Posts
    5

    Character position in a text editor


    I'm performing an editing process for the first time in CentOS that I'm accustomed to perform in Windows. At one step a web-based validator looks for errors in a JSON file and identifies them by their character offset from the start of the file. I must then edit the file and rerun the validator.

    In Windows my preferred text editor (Notepad++) has a plugin which displays the character position of the cursor on request. Problem solved.

    gedit, the standard text editor in CentOS, appears to have no built-in character offset display and no plug-in that provides one. Notepad++ is not implemented for Linux.

    None of the solutions I've thought of are attracdtive. I could conduct an open-ended, quite possibly futile search for a suitable gedit plug-in. Or I could conduct a similar search for a validator that is more user friendly. Or I could find, evaluate, and break in a new text editor for Linux. All of these approaches would require time and effort that seem far out of proportion to the problem.

    Before I go off and do one of those things, can someone suggest a simpler solution?

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    hello and welcome, Orthoducks!

    yeah, i use notepad++, too, it rocks.

    for Linux, when I need a GUI editor, I used nedit. i think it can do that column cursor location thing you want. Under Preferences in Nedit, make sure that Statistics Line is enabled, and you should see the cursor Line and Column in the top right corner of the Nedit window.

    Nedit is probably in your software repos already, if not, nedit.org. it has a good deal of plugins available, too.

  3. #3
    Just Joined!
    Join Date
    Aug 2013
    Posts
    5
    Thank you, I downloaded nedit but ran into problems installing it. This is the first time I've installed software in Linux "by hand," and I need some very newbie help!

    I downloaded the archive nedit-5.5-Linux-x86.tar.gz. When I opened it, I found that it contained one directory named nedit-5.5-Linux-x86, which contained nedit, nedit.doc, a readme file, etc. I selected the directory, clicked Extract, and pointed the extract operation to /usr/bin.

    When I was done, I expected to find nedit-5.5-Linux-x86 in /usr/bin with all of the nedit files tucked neatly inside of it. Instead I found that the CONTENTS of the directory had been unpacked, so I had nedit, nedit.doc, etc., rattling around in /usr/bin.

    Is this normal behavior for whatever Linux utility handles gz files? I find it hard to understand. Suppose I want to unpack one subdirectory -- how can I do it? If I select the parent directory, it unpacks the subdirectory I want and all of its siblings. If I select the subdirectory I want, it unpacks the subdirectory's contents.

    But OK, now I've got the nedit executable in /usr/bin. I should be able to run it by entering 'nedit' in a shell, right? It didn't work. I checked the file's execute bits, and they are all set. But the shell says "bash: nedit: command not found" even when /usr/bin is the current directory.

    What has happened, and what must I do to make it right?
    Last edited by Orthoducks; 08-08-2013 at 05:14 PM.

  4. $spacer_open
    $spacer_close
  5. #4
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    if yum is configured and working, try installing nedit that way first. if that can't work, we'll go back to the way you already tried.

    first, in a terminal, change to root user:

    Code:
    su -
    then install the package via yum:
    Code:
    yum install nedit
    however, depending on your version of CentOS and the repos you have configured, nedit may not be in your software repos yet. I know that Nedit is provided by the EPEL repo (run by RHEL/Fedora contributors), so you can try that one.

    go here and follow the instructions to install the EPEL repo for your CentOS version (5, 6, etc.) and arch (i386, x86_64).

    here's an example for the basic command to install the repo for CentOS 6 i386:

    Code:
    rpm -ivh http://mirror.us.leaseweb.net/epel/6/i386/epel-release-6-8.noarch.rpm
    do that as root. then you should see EPEL repos, do this to check:
    Code:
    yum repolist
    then you should be able to install nedit via the above yum command.

  6. #5
    Just Joined!
    Join Date
    Aug 2013
    Posts
    5
    I got it installed through yum, and learned a little bit about how yum deals with repositories. I'd still like to figure out why I couldn't run nedit after I installed it manually, but that may have to wait for another time.

    Now I can run nedit, but I don't see how to make it solve my original problem. The statistics line shows the cursor's position in lines and characters. And now that I've read your original suggestion carefully, as I should have done in the first place, I see that this is just what you said it would do.

    To clarify, if the cursor is somewhere in the middle of a file, I need to know that it's at (for example) character 4632 -- not that it's at line 79, character 17.

  7. #6
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by Orthoducks View Post
    To clarify, if the cursor is somewhere in the middle of a file, I need to know that it's at (for example) character 4632 -- not that it's at line 79, character 17.
    oh, i didn't understand that. can you describe how to do that in notepad++? By default, I only see the same Ln/Col count in the status bar at the bottom.

  8. #7
    Just Joined!
    Join Date
    Aug 2013
    Posts
    5
    There's a "Character Position" plug-in that does it. I believe I got it from Softpedia.com. It's not the most convenient thing in the world, but it does the job.

  9. #8
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    hmm...i guess you can't do that in Nedit, sorry. it is a good little editor, though.

    have you looked into Emacs? It has long history in the Unix world and is famous for its hack-ability. According to this manual, you can do something like what you want (if i read it right):


    C-x =
    Display the character code of character after point, character position of point, and column of point (what-cursor-position).


    i have zero exp w/Emacs, i only mention it b/c it is so popular and may help you, if you are willing to sink some time into it. it is also surely in your software repos:

    Code:
    yum install emacs

  10. #9
    Just Joined!
    Join Date
    Aug 2013
    Posts
    5
    Emacs, as I recall, is strictly a command line editor. It dates from the days when 24 line by 80 character CRT terminals could display WYSIWYG text (as long as what you get was limited to plain ASCII), but interacting directly with the text as displayed was not yet technically feasible.

    Emacs is incredibly flexible and powerful, but the commands needed to apply its capabilities are incredibly abstract and arcane. That is: you don't edit the text on the screen with Emacs, you edit an abstract model of the text that's based on the way the program is structured rather than the way the text is structured. Then you see the results on the screen.

    There are still people who love Emacs, but I'm not one of them. If I need to find another text editor, that won't be it.

  11. #10
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by Orthoducks View Post
    There are still people who love Emacs, but I'm not one of them. If I need to find another text editor, that won't be it.
    i have no idea of emacs current capability, but i have no interest in learning, either.

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •