LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-08-2010, 01:35 PM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Rep: Reputation: 76
VIM: showing line terminators.


VIM 7.1

Hi:
Can vim show on the screen the line terminators? How do I do it? Thanks in advance.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 08-08-2010, 02:11 PM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

Are you talking about showing \n \r ^M etc? If so: you can't.

You can show control characters (including where a line ends) with :set list (:set nolist to toggle off).

You can also show which fileformat you are using: :set ff (shows unix/dos/mac) or force a certain format: set ff=unix (file is written as a unix file when saving).

Hope this clears things up.
 
Old 08-08-2010, 02:35 PM   #3
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Yes. I have had text files edited by some M$-DOS editor, which uses ^M+^J (13, 10) to terminate a line. When I edited the same file with vim, vim, thinking it was a unix-style file, printed the string '^M' at the end of every line. To reject the ^M terminators, I issued ':set ff=unix' and saved. Or if I prefered to keep the dos-style format, I issued ':se ff=dos' at session start.

Going to your post, I did ':set list', and vim showed the line teminators with a generic symbol: the '$' character. Then you are write. It's impossible to see which line terminator $ is, in vim. I would have to fall back on 'hexdump -C'. Thanks for your posts. I think some day I'll make a serious attempt at studying the vim manual.
 
Old 08-08-2010, 02:46 PM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

od might also be of help: od -c filename

It will show the \n and/or \r terminators:
Code:
$ echo -ne "LF\nCRLF\r\nCR\r" > weird.file
$ od -c weird.file
0000000   L   F  \n   C   R   L   F  \r  \n   C   R  \r
0000014
 
2 members found this post helpful.
Old 08-08-2010, 03:04 PM   #5
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
I'll play a little with od. Thanks again, druuna.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Removing line terminators from a plain text file. stf92 Linux - Software 11 07-31-2010 07:05 AM
[SOLVED] Vim not showing some characters kofucii Linux - Newbie 2 09-07-2009 09:09 AM
How to remove CRLF, CR line terminators keshavk Linux - Newbie 2 08-02-2009 12:56 PM
is it possible to do this in VIM with line wrap on? hedpe Linux - Software 5 04-19-2006 06:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration