Loading ...
Sorry, an error occurred while loading the content.

Re: how to stop the vi from loading all of a huge file

Expand Messages
  • xulxer
    Hi, ... what about a little shell script that checks the filelength? And if the filelength is greater than say 1000 lines vim will only load the last 10000
    Message 1 of 2 , Sep 9, 2008
    • 0 Attachment
      Hi,
      >
      > sometimes,
      > Sometimes I need to see lets say 10000 lines only but the vi editor
      > wants to load all of it,
      >
      > with tail again it is a long process.
      >
      > I just want to know whether it is possible to stop the vi from loading
      > a huge file, something like an interrupt that will stop wherever it is
      > now while loading a file and then showing the rest of it
      >
      what about a little shell script that checks the filelength? And if the
      filelength is greater than say 1000 lines vim will only load the last
      10000 lines with the -u NONE option.


      #! /bin/sh
      INPUTFILE="$@"
      OUTPUTFILE=${INPUTFILE}.bak
      INPUTFILELENGTH=$(wc -l $INPUTFILE | awk '{print $1}')

      if [ $INPUTFILELENGTH -gt 10000 ]
      then
      STARTOUTPUT=$(($INPUTFILELENGTH-10000))
      sed -n "${STARTOUTPUT},${INPUTFILELENGTH}p" $INPUTFILE > $OUTPUTFILE
      vim -u NONE $OUTPUTFILE
      fi



      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    Your message has been successfully submitted and would be delivered to recipients shortly.