3

I basically need a text editor which displays text in a grid, so that I can know the exact column numbers of the text. The numerical simulation software I am using, TOUGH+ (written in FORTRAN), has a strict format and I need to specify my input files in the exact format.

A letter misplaced here and there can make the whole file useless. So I need this to quickly glance at the input files, and know/verify which text starts and ends in which column. Otherwise, the file gets confusing sometimes.

For example in the image of the input file snippet, it's very difficult to separate at a glance where one value ends and other starts.

Input file snippet with lines separating values

The most useful thing I have tried is the TextFX plugin with Notepad++, but it is very inelegant, as in it just places a text of characters to see the column numbers.

Text FX plugin

The best way to describe my requirement would be Spreadsheet but which takes only one character in a cell.

7
  • I notice you tagged the question with Excel. You could use text to columns, specify fixed width, then add a break line at every column break (bit tedious), then use the column ID as your identifier. I would suggest using a macro/VBA to do the split, something like Selection.TextToColumns Destination:=Range("A2"), DataType:=xlFixedWidth, _ FieldInfo:=Array(Array(0, 1), Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array _ (5, 1)), TrailingMinusNumbers:=True Feb 20, 2019 at 8:07
  • 1
    @spikey_richie, instead of suggesting answer through comments better you post it as Answer, will help the community. Feb 20, 2019 at 8:18
  • 1
    Thanks a lot! I added excel as a last resort if I don't find any application that is suitable for my work. Doing it in excel would be cumbersome, every time I open a file. But I would definitely try and work on this, also need to work on my macro/VBA skills.
    – yavvee
    Feb 20, 2019 at 8:20
  • 1
    This question confirms that you can't do it with Notepad++ So, let's seek another solution Feb 20, 2019 at 8:55
  • @RajeshS I often probe a bit before committing to an answer, but I have now posted my comment as an answer with some formatting. Feb 20, 2019 at 9:09

5 Answers 5

1

Posting as an answer, as it's too big for even multiple comments. Disclosure: I have not tried any of these, but some have been accepted as answers.

  • Multiple margins in Atom Editor? on S.O says that it is possible, and the answer was accepted.
  • IntelliJ IDE: How to add one or more margins on this site has an accepted answer saying that you can do it with Sublime text (which is not an IDE), plus a comment, with screenshots, showing how to do it with PyCharm, which is JetBrains' excellent and free (even for commercial use), Python IDE.

Personally, I would find it simple enough to write a Python script to:

  • strip multiple spaces from each line
  • split each line into multiple words
  • insert spaces as appropriate
1
  • @yavvee Thank for accepting the answer. Which one did you go for? I am sure that others would be interested to know. Feb 25, 2019 at 7:43
1

If you are able to use Microsoft Access you can use a text-to-column method similar to Excel but with the advantage of saving your specification for re-use. This will import your fixed-width text file into an easily-readable data table. Repeating the import can be as simple as three or four clicks.

(I don't know if this is relevant to you, so I would put this as a comment, but I don't have the reputation for that.)

1

This can be easily solved by using VBA (Macro):

This code will Loop through all Worksheets in active workbook, find the value in SearchRange on each sheet, and store values in the worksheet named FindAddressWorksheet in row Sheetindex of column A.

Sub FindAddress()

Sheetindex = 1
For Each ws In Worksheets

  If ws.Name <> FindAddressWorksheet Then
    FindAddressWorksheet.Cells(Sheetindex, 1).Value = _
    ws.Range(Myrange).Value
    Sheetindex = Sheetindex + 1
  End If
Next
End Sub

How it works:

  • Copy & Paste this Macro as Standard Modele.
  • Input All Data to be searched, and Name it as Myrange (this name is editable).
  • Name any blank Sheet as FindAddressWorksheet (Sheet name is editable) before you RUN the Macro.

This Can be used if you are working on a Sheet only:

Sub FindRange()

    Dim rngX As Range
    Dim Data As String

    Data = InputBox("Write Value", "Obtain Cell Address")
    Set rngX = Worksheets("Sheet1").Range("A1:AFD65000").Find(Data, lookat:=xlPart)

    If Not rngX Is Nothing Then
        MsgBox "Found at " & rngX.Address
    End If

End Sub

N.B.

  • Sheet Name & Data Range are editable.
1

I notice you tagged the question with Excel. You could use text to columns, specify fixed width, then add a break line at every column break (bit tedious), then use the column ID as your identifier.

A cleaner solution would be to use a macro/VBA to do the split, something like

Selection.TextToColumns Destination:=Range("A2"), DataType:=xlFixedWidth, _     
    FieldInfo:=Array( _
        Array(0, 1), _
        Array(1, 1), _
        Array(2, 1), _
        Array(3, 1), _
        Array(4, 1), _
        Array(5, 1)), _
        TrailingMinusNumbers:=True

Expanding out the number of array items to cover appropriate number of columns.

-1

If you know the unix vi text editor, you can open your text file therein and make initial guesses as to which column a particular field or text item starts. For example, if an item looks like it may be at or near column number 45, you enter 45| (vertical bar) and the cursor will go right to that column. From there, you can then space or backspace while keeping count to determine the true column number. I happen to have a PC version of the vi editor which I use a lot on the command line. Hope this helps.

2
  • 1
    I think OP works with Windows
    – Toto
    Jul 26, 2022 at 19:41
  • I can't see how this post answers the question "need a text editor which displays text in a grid" Jul 26, 2022 at 20:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.