Thread: Seeing more with VIM

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    13

    Seeing more with VIM

    Hello,

    I have a long list of numbers that I am doing a lot with. I want to print them out after every operation, to ensure that I have done the operation correctly. I am using VIM, but it seems that VIM will only allow me to see a certain number of lines when I execute my program. For example, if I have 500 lines of printout, it will only print out like 300 of them. I'm pretty sure this is a fault of VIM, because I can see small printouts just fine (like less than 200).

    Is there a way to see all of the printout in VIM? If there is not, can you recommend another program that lets me execute programs and lets me see all of the printouts?

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    It sounds like you're hitting a file size limit...

    If all your numbers are on a single line, you can only display 512 bytes.

    Try a different editor or add newlines to your outputs...
    Last edited by CommonTater; 11-06-2011 at 11:28 AM.

  3. #3
    Registered User
    Join Date
    Oct 2011
    Posts
    13
    What are some other editors that you would recommend? Is there anything like microsoft visual studio, but for c?

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Well, for big text files on windows TextPad is best... TextPad

    VIM is probably just fine for editing source files, but it is customized for that job, which is likely what you're bumping up against.

    If you want to get into a REAL IDE/Compiler for C, I usually recommend Pelles C
    Last edited by CommonTater; 11-06-2011 at 11:33 AM.

  5. #5
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    vim will accept huge files, this is likely not the fault of vim.

  6. #6
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by rags_to_riches View Post
    vim will accept huge files, this is likely not the fault of vim.
    I'm thinking he's hitting the 512 character line length stated in the vim manual.

    TestPad has a 32k line length and will split lines to avoid loss of data... which is why I suggested it.

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Are we to infer from "VIM" that you're using Linux (or some other non-windows OS)?

    > Is there anything like microsoft visual studio, but for c?
    What's this supposed to mean?
    One is an IDE and the other is a language. It's like saying "is there anything like cabbage, but for horses".

    300 lines seems more like the scroll-back limit of a default console, rather than anything to do with VIM.
    Perhaps if you used the editor's navigation keys to move around the file, rather than dragging the scroll bars, you might see more of the file.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  8. #8
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    rags_to_riches is right, I regularly open 1000+ line files in GVIM with a color theme with absolutely no visible penalty.

    Though it's very unlikely to be your problem, a good place to start with finicky things like this, is to take VIM out of compatibility mode
    Code:
    <esc> :set nocompatible
    If you are really that convinced still that it's VIM's fault, run
    Code:
    <esc> :ver
    and tell me what you see.

  9. #9
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by CommonTater
    I'm thinking he's hitting the 512 character line length stated in the vim manual.
    Maybe, but it seemed pretty clear that nkbxwb was talking about "a certain number of lines", e.g., "500 lines", not "500 characters".

    Quote Originally Posted by Salem
    Are we to infer from "VIM" that you're using Linux (or some other non-windows OS)?
    Official distributions of Vim are available for Windows though, so that inference is probably unwarranted.

    Quote Originally Posted by Yarin
    I regularly open 1000+ line files in GVIM with a color theme with absolutely no visible penalty.
    Hmm... nkbxwb, when you say "printout", you are referring to the content of files generated from your program that you view in Vim, not the content of files generated from your program that you are attempting to print on paper via Vim, right?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  10. #10
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by nkbxwb View Post
    I have a long list of numbers that I am doing a lot with. I want to print them out after every operation, to ensure that I have done the operation correctly. I am using VIM, but it seems that VIM will only allow me to see a certain number of lines when I execute my program. For example, if I have 500 lines of printout, it will only print out like 300 of them. I'm pretty sure this is a fault of VIM, because I can see small printouts just fine (like less than 200).
    How are you executing? I've been a vim user for years. In general I don't execute from it, but when I do, I've never noticed this problem. Most likely, as Salem suggests, this is because of your console. Try gvim instead.

    If I do execute I use

    :!whatever

    Where "whatever" is the command.

    Quote Originally Posted by CommonTater View Post
    I'm thinking he's hitting the 512 character line length stated in the vim manual.
    No, that is from ye olde unix vi. There is no such limit in vim.



    To be honest, I don't see the purpose of using one megalithic app to edit, compile, and execute, when you can simply use VIM and flip back and forth between that and a console window. OTOH, I know the MS windows console leaves a lot to be desired, lol, if that is where you are...

    VIM is dedicated to being the best code editor in the universe, but it will not make toast and coffee for you. You can try to use it that way (or switch to something that does claim to include the kitchen sink), or you can just learn to make toast and coffee the original way, which is pretty darn simple, really. It might even still be the simplest way, but YMMV.
    Last edited by MK27; 11-08-2011 at 02:11 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  11. #11
    Registered User
    Join Date
    Oct 2011
    Posts
    13
    Quote Originally Posted by Salem View Post
    Are we to infer from "VIM" that you're using Linux (or some other non-windows OS)?

    > Is there anything like microsoft visual studio, but for c?
    What's this supposed to mean?
    One is an IDE and the other is a language. It's like saying "is there anything like cabbage, but for horses".



    300 lines seems more like the scroll-back limit of a default console, rather than anything to do with VIM.
    Perhaps if you used the editor's navigation keys to move around the file, rather than dragging the scroll bars, you might see more of the file.
    What I mean by this is: Is there any program that is an IDE that can help me step into and debug my program. I know you can do it in visual studio, but it is a pain in the ass. You have to change file names, and such, and from the experiences I've had, it doesn't always turn out nice.

    I tried scrolling with my arrow keys, but that doesn't seem to work

    I then tried the nocompatible. and nothing happened

    For ver, I got VIM - Vi IMproved 7.0 (2006 May 7, compiled Aug 4 2010 07:21:08)

    When I do the !: I get


    -bash: : unrecognized history modifier



    PS thanks for all the responses!!!

  12. #12
    Registered User
    Join Date
    Aug 2008
    Location
    Belgrade, Serbia
    Posts
    163
    Mine returns:
    VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Sep 30 2011 05:51:10)
    Look like yours is more than aged.
    Vanity of vanities, saith the Preacher, vanity of vanities; all is vanity.
    What profit hath a man of all his labour which he taketh under the sun?
    All the rivers run into the sea; yet the sea is not full; unto the place from whence the rivers come, thither they return again.
    For in much wisdom is much grief: and he that increaseth knowledge increaseth sorrow.

  13. #13
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    It was :! not !: And that was to be done in vi, not from bash. In vi, when in command mode, :!whatever opens a shell and executes the program whatever. In bash, ! is the start of a history command. For example, !! executes the previous command, !-3 the 3rd previous command. There are all sorts of tricks you can to do it to strip off the firs word, last word, parameter substitution, etc. It's quite sexy actually. If you're a regular Unix/Linux user, do "man bash" and search for the "HISTORY EXPANSION" section. It will change your life.

  14. #14
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    I have 7.3, too.

    nkbxwb, you could upgrade, but i doubt your version is the problem.
    I would try as MK27 suggested, and see if using GVIM instead doesn't fix your problem (it's generally nicer to use anyway).

    anduril462, in bash/ksh, I press left when the line is blank, then I can use up and down to navigate my command history. No expansion necessary. I actually only mention this because you can do the same thing in VIM! Only, you have to type the colon first.

  15. #15
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Quote Originally Posted by Yarin View Post
    anduril462, in bash/ksh, I press left when the line is blank, then I can use up and down to navigate my command history. No expansion necessary. I actually only mention this because you can do the same thing in VIM! Only, you have to type the colon first.
    I've never had to press left first, maybe that's a ksh thing. I use the up/down arrows a lot, but just as often I find the extra power of history expansion extremely useful. But I digress.

    @nxbxwb: If you're looking for an IDE that works on Linux, try looking into Eclipse or Code::Blocks, both integrate with various debuggers, the main one on Linux being GDB. IIRC, emacs has GDB integration too. Both Eclipse and C::B have Windows versions too. Also on Windows, you have Pelles C, which is an IDE with debugger. I hear Pelles is good for beginners. If you plan on doing much Linux development, learning GDB is a must, whether it's from the command line or via an IDE integration.

Popular pages Recent additions subscribe to a feed