0

I have a file in linux that has json data in each new line. When I open that file in vi editor, multiple @ symbols show up at the end of every record in a new line. The file does have new line after every record ($ shows up). I'm unable to remove these @ symbol from the file. Here's a snippet of the file -

ABCD","REFnum":"1123"}]}
@
@
@
@
{"Act":01,"tx":

Can someone help and recommend a solution to remove these?

8
  • 1
    You might run a few lines through od -t x1ac and check. I suspect vi is substituting these for something non-displayable. Very likely to be NUL 0x00. Commented Sep 17, 2020 at 18:12
  • When I did that, I don't even see representation for @ Commented Sep 17, 2020 at 18:50
  • 1
    My vi does this, but it colours the @ characters (and all other controls) blue. Look at the file and :set nu as a vi option. Not sure of the logic, but if vi cannot show all of a very long line that is the last one in the current viewing area, it pads the screen with @ to indicate that it is refusing to show the first part of the next long line. Commented Sep 17, 2020 at 20:08
  • 1
    Please edit your question and copy&paste a snippet of the output of od -t x1ac yourfile from a few lines before ABCD","REFnum":"1123" up to a few lines after {"Act":01,"tx" Commented Sep 17, 2020 at 21:11
  • 1
    Does using :set display+=lastline help? See also vim.fandom.com/wiki/Working_with_long_lines In short: The @ characters are not part of your file, just an indication of long lines. Commented Sep 18, 2020 at 6:29

1 Answer 1

0

The @ characters do not exist in your file. It's a visual representation that the Vim editor is using when it encounters "very long lines".

You may possibly be able to navigate the file easier if first using

:set display+=lastline

but you may also reformat your JSON document to be easier to read by using the jq utility like so:

jq . myfile.json >newfile.json

(and then edit newfile.json instead). The compact format of a JSON file could be restored with

jq -c . newfile.json >compact.json

Note that the compact and "pretty printed" variants of JSON are equivalent and a JSON parser would not care which one it was parsing.

Further information about working with long lines in Vim is found in the "Vim fandom wiki": https://vim.fandom.com/wiki/Working_with_long_lines

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.