• Searching from end of file using VIM


    https://stackoverflow.com/questions/12867573/searching-from-end-of-file-using-vim

    Asked 9 years, 8 months ago
    Viewed 64k times
    43

    How do I search from the end of file using VIM? I want to search for the last occurrence of XXXX in the open file.

    5 Answers

    57

    Type G$?XXXX

    • G to go to the end of the file
    • $ to go to the end of the line
    • ? to search backwards
    • XXXX being what you want to search for

    You could also do gg?XXXX which goes to the start of the file, then searches backwards, wrapping around to the end of the file. However for large files it can be slow to seek to the start of the file and then immediately to the end of the file.

    40
     

    My suggestion is to use a range combined with searching backwards via ?.

    :1?XXXX
    

    Overview:

    • 1?XXXX is the range.
    • The 1 means first line of the file.
    • ?XXXX means search backwards from the first line (wrapping around) until you find the pattern XXXX

    As ZyX mentioned this relies on wrapscan to be set, which it is by default. See :h 'wrapscan' for more information.

  • 相关阅读:
    FPGA开发全攻略——FPGA选型
    FPGA开发全攻略——FPGA开发基本流程
    希尔伯特变换的物理意义
    无线通信方式
    FPGA DDR3调试
    FPGA调试光纤模块
    FPGA FIFO深度计算
    Xilinx FPGA LVDS应用
    电源设计注意事项
    波特图与零极点
  • 原文地址:https://www.cnblogs.com/kungfupanda/p/16385332.html
Copyright © 2020-2023  润新知