Как я могу удалить все console.logs, используя VIM - PullRequest
0 голосов
/ 07 ноября 2018

Я могу удалить все console.logs в файле, используя g/log/d, но я пытаюсь найти способ удалить их все из всех файлов в каталоге. Я пытался :argdo g/log/d | update, но, если честно, я совсем не уверен, как это сделать.

https://thepugautomatic.com/2014/12/vim-global/

@ Harish, ваш ответ отлично работает, когда я тестировал его на базовом проекте, но при запуске этого в моих реактивных проектах есть странные побочные эффекты.

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 голосов
/ 08 ноября 2018

Сначала вам нужно будет установить args для файлов, которые вы хотите обновить, а затем вызвать argdo.

:args ./*.js

выше выберет все файлы javascript в текущем каталоге. Если в текущем каталоге есть подкаталоги и вы хотите рекурсивно выбирать файлы, вы можете использовать

:args **/*.js

После установки аргументов вы можете вызвать команду global, используя argdo

:argdo g/log/d | update 
...