如何使用 VIM 删除所有 console.logs
How can I remove all console.logs using VIM
我可以使用 g/log/d
删除文件中的所有 console.logs,但我正在尝试找到一种方法从目录中的所有文件中删除所有文件。我试过 :argdo g/log/d | update
但老实说,我完全不确定如何完成此操作。
https://thepugautomatic.com/2014/12/vim-global/
@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}
});
您必须先将 args
设置为要更新的文件,然后调用 argdo
。
:args ./*.js
以上将 select 当前目录中的所有 javascript 文件。如果当前目录有子目录并且你想递归地 select 文件你可以使用
:args **/*.js
设置参数后,您可以使用 argdo
调用 global
命令
:argdo g/log/d | update
我可以使用 g/log/d
删除文件中的所有 console.logs,但我正在尝试找到一种方法从目录中的所有文件中删除所有文件。我试过 :argdo g/log/d | update
但老实说,我完全不确定如何完成此操作。
https://thepugautomatic.com/2014/12/vim-global/
@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}
});
您必须先将 args
设置为要更新的文件,然后调用 argdo
。
:args ./*.js
以上将 select 当前目录中的所有 javascript 文件。如果当前目录有子目录并且你想递归地 select 文件你可以使用
:args **/*.js
设置参数后,您可以使用 argdo
global
命令
:argdo g/log/d | update