Vim删除不包含指定字符串的行

  • warning: call_user_func_array() expects parameter 1 to be a valid callback, function '_imagecache_menu_access_public_files' not found or invalid function name in /var/www/drupal-6.28/includes/menu.inc on line 454.
  • warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'views_access' not found or invalid function name in /var/www/drupal-6.28/includes/menu.inc on line 454.
  • warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'views_access' not found or invalid function name in /var/www/drupal-6.28/includes/menu.inc on line 454.
  • warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'views_access' not found or invalid function name in /var/www/drupal-6.28/includes/menu.inc on line 454.

Vim 删除不包含指定字符串的行:

:g/xxx/d,删除包含xxx的行

:v/xxx/d,删除不含xxx的行

:%s/xxx//gn,统计xxx个数,n表示只报告匹配的个数而不进行实际的替换。

详见「:help :v」或「help :g」