zoukankan      html  css  js  c++  java
  • vim 查看某字符串出现的次数

    http://blog.chinaunix.net/uid-23577393-id-1751983.html

    To count how often any pattern occurs in the current buffer use the substitute
    command and add the 'n' flag to avoid the substitution.  The reported number
    of substitutions is the number of items.  Examples: >

            :%s/./&/gn              characters     
            :%s/i+/&/gn           words          
            :%s/^//n                lines          
            :%s/the/&/gn            "the" anywhere
            :%s/<the>/&/gn        "the" as a word

    You might want to reset 'hlsearch' or do ":nohlsearch".
    Add the 'e' flag if you don't want an error when there are no matches.

    An alternative is using |v_g_CTRL-G| in Visual mode.

    If you want to find matches in multiple files use |:vimgrep|.


    :%s/mystring//gn 



                                                            *count-bytes*
    If you want to count bytes, you can use this:

            Visually select the characters (block is also possible)
            Use "y" to yank the characters
            Use the strlen() function: >
                    :echo strlen(@")
    A line break is counted for one byte.

    %s            在整个文件中替换 (:help :s )
              匹配一个字 (word) (:help /w )
    g           替换行内所有出现的匹配 (:help :s_flags)
              只报告匹配的数目,并不真正进行替换(:help :s_flags)


    vim 显示当前正在编辑的文件名
    :f
    或者ctrl+g



    删除匹配的行
    : g/template/d

  • 相关阅读:
    html HTML 文本格式化
    纯css3实现图片切换
    绝对路径和相对路径
    CSS设置html网页背景图片 CSS设置网页背景颜色
    使用CSS3制作响应式网页背景图像
    CSS背景全攻略
    HTML中通过CSS设置背景图片自适应浏览器大小
    CSS设置背景——图片背景
    如何让图片自适应手机等移动设备屏幕大小
    SERVER 2012 R2 对域用户禁用移动存储设备
  • 原文地址:https://www.cnblogs.com/jingzhishen/p/3758456.html
Copyright © 2011-2022 走看看