this post was submitted on 02 Jan 2024
12 points (92.9% liked)

Neovim

2197 readers
2 users here now

founded 2 years ago
MODERATORS
 

So I just had an issue where my shebang lines weren't parsing properly for a python script I was attempting to execute. A quick google revealed that it was probably because I wrote the scripts on windows and now I was trying to run them on Linux (so happy i finally made the switch btw. using the computer is fun again!). So i took the advice I found and tried to run :%s/^M/ (using C-v, C-m to insert the escape character), and it failed to find any matches. I tried the same command in vanilla vi and it worked.

Is there some setting I don't have configured properly? I would prefer to be able to do this sort of thing within neovim.

top 5 comments
sorted by: hot top controversial new old
[–] [email protected] 5 points 11 months ago* (last edited 11 months ago) (1 children)

I would just use dos2unix personally

Or :%!dos2unix from in vim

[–] Hammerheart 3 points 11 months ago

i like typing arcane looking things into neovim though

jk (kinda) you're probably right. it wasn't included in my distro and i didn't want to download a whole executable for something so minor but it will probably come in handy so I just did.

[–] [email protected] 5 points 11 months ago

I generally use %s/\n//g (or is it \r ?) rather than trying to use verbatim control characters.

[–] [email protected] 3 points 11 months ago

Next time, try enabling display of whitespace characters through set list. If I remember correctly, they can help distinguish between the Windows carriage return character and Linux end of line character.

This may help for a quick overview.

[–] [email protected] 3 points 11 months ago

Vim (and presumably neovim) will detect that it's in "DOS mode" and hide the '^M's for you. In vim you can just do ":set ff=unix" and then save.