如何使用VIM删除所有console.logs

时间:2018-11-07 19:31:09

标签: vim console.log

我可以使用g/log/d删除文件中的所有console.log,但是我试图找到一种从目录中所有文件中删除所有console.log的方法。我尝试了:argdo g/log/d | update,但老实说,我完全不确定该如何完成。

this issue

@在我在一个基本项目上测试它时,Harish您的答案非常有用,但是在我的react项目上运行它时会产生奇怪的副作用。

import axios from 'axios' //write user autentication actions 
import {serverURL} from './config'
axios.defaults.withCredentials = true; 

export const signUp = async (user) => axios.post(`${serverURL}/api/signup`,  user)
    .then(function (response) {
        return response.data    
    })
    .catch(function (error) {
        return {error:true, message: error.response.data.message}          
    });

export const logIn = async (user) => axios.post(`${serverURL}/api/login`,  user)
    .then(function (response) {
        return response.data
    })
    .catch(function (error) {
        return {error:true, message: error.response.data.message}    
    });

export const logOut = async () => axios.post(`${serverURL}/api/logOut`)
    .then(function (response) {
        return response.data
    })
    .catch(function (error) {
        return {error:true, message: error.response.data.message}
    });

export const loggedIn = async () => axios.get(`${serverURL}/api/loggedin`)
    .then(function (response) {
        return response.data
    })
    .catch(function (error) {
        return {error:true, message: error.response.data.message}
    });

变成:

import axios from 'axios' //write user autentication actions 
import {serverURL} from './config'
axios.defaults.withCredentials = true; 

export const signUp = async (user) => axios.post(`${serverURL}/api/signup`,  user)
    .then(function (response) {
        return response.data    
    })
    .catch(function (error) {
        return {error:true, message: error.response.data.message}          
    });

    .then(function (response) {
        return response.data
    })
    .catch(function (error) {
        return {error:true, message: error.response.data.message}    
    });

    .then(function (response) {
        return response.data
    })
    .catch(function (error) {
        return {error:true, message: error.response.data.message}
    });

    .then(function (response) {
        return response.data
    })
    .catch(function (error) {
        return {error:true, message: error.response.data.message}
    });

1 个答案:

答案 0 :(得分:3)

您必须将args设置为要首先更新的文件,然后调用argdo

:args ./*.js

上面将选择当前目录中的所有javascript文件。如果当前目录包含子目录,并且您要递归选择文件,则可以使用

:args **/*.js

设置参数后,您可以使用global调用argdo命令

:argdo g/log/d | update