LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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, 02:35 PM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,284

Rep: Reputation: 49
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, 03:11 PM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
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, 03:35 PM   #3
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,284

Original Poster
Rep: Reputation: 49
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, 03:46 PM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
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, 04:04 PM   #5
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,284

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 08:05 AM
[SOLVED] Vim not showing some characters kofucii Linux - Newbie 2 09-07-2009 10:09 AM
How to remove CRLF, CR line terminators keshavk Linux - Newbie 2 08-02-2009 01:56 PM
is it possible to do this in VIM with line wrap on? hedpe Linux - Software 5 04-19-2006 07:19 PM


All times are GMT -5. The time now is 11:42 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration