Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 99078

VSCode Regex Search and Replace to Remove Code Block

$
0
0

How can we use VSCode Search and Replace with Regular Expressions to remove a block of code with the pattern

    id: {

      ...

      field: "id"
    },

For example, if we have the following code:

module.exports = sequelize => {
  const attributes = {
    id: {
      type: DataTypes.INTEGER,
      allowNull: false,
      defaultValue: "nextval(foo_id_seq::regclass)",
      comment: null,
      primaryKey: true,
      field: "id"
    },
    count: {
      type: DataTypes.INTEGER,
      allowNull: false,
      defaultValue: null,
      comment: null,
      primaryKey: false,
      field: "count"
    },

after Search and Replace, it should become

module.exports = sequelize => {
  const attributes = {
    count: {
      type: DataTypes.INTEGER,
      allowNull: false,
      defaultValue: null,
      comment: null,
      primaryKey: false,
      field: "count"
    },

Tried using \t\t\tid: {*.? "id"\n\t\t\t}, but it was unable to select anything.


Viewing all articles
Browse latest Browse all 99078

Trending Articles