我可以使用g/log/d
删除文件中的所有console.log,但是我试图找到一种从目录中所有文件中删除所有console.log的方法。我尝试了:argdo g/log/d | update
,但老实说,我完全不确定该如何完成。
@在我在一个基本项目上测试它时,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}
});
答案 0 :(得分:3)
您必须将args
设置为要首先更新的文件,然后调用argdo
。
:args ./*.js
上面将选择当前目录中的所有javascript文件。如果当前目录包含子目录,并且您要递归选择文件,则可以使用
:args **/*.js
设置参数后,您可以使用global
调用argdo
命令
:argdo g/log/d | update