用vim编写程序源文件是常用的命令

    技术2024-07-20  65

    1、删除所有行首空格

    %s/^/+/s//g

    %s/^\s*//g

     

    2、删除所有行尾空格

    %s//s/+$//g

     

    3、替换所有三个句点相连的字符串

    %s//./{3}//g

     

    4、显示/关闭制表符Tab键和行尾换行键

    set list

    set nolist

     

    5、自动格式化代码

    gg=G

     

    6. 配置~/.vimrc

    syntax on

    set  tabstop=4

    set cindent set smartindent set autoindent set expandtab set shiftwidth [Number of spaces to use for each step of (auto)indent. User for 'cindent', >>, <<, etc. Default 8]

     

    7.大小写转换

    g~  - 大小写反转

    gu - 转换为小写

    gU - 转换为大写

     

    最新回复(0)