Copy Function Extension / Copiar Função

Esta extensão para o VS Code permite copiar, selecionar ou recortar toda a função (ou método) para facilitar a extração, reutilização ou modificação do código.
This VS Code extension allows you to copy, select, or cut the entire function (or method) to facilitate code extraction, reuse, or modification.

Descrição / Description
Português:
A extensão Copy Function permite que você copie, selecione ou recorte a função inteira onde o cursor está localizado. As funcionalidades são acionadas pelos comandos disponíveis no menu de contexto do editor ou por atalhos de teclado:
- Cópia:
Ctrl+Shift+C
(Mac: Cmd+Shift+C
)
- Seleção:
Ctrl+Shift+S
(Mac: Cmd+Shift+S
)
- Recorte:
Ctrl+Shift+X
(Mac: Cmd+Shift+X
)
⚠️ Nota sobre atalhos: O atalho Ctrl+Shift+C
pode conflitar com o comando nativo "Developer: Toggle DevTools" em algumas configurações. Você pode personalizar os atalhos em Arquivo > Preferências > Atalhos de Teclado
.
English:
The Copy Function extension enables you to copy, select, or cut the entire function where the cursor is located. The functionalities are triggered via the context menu command in the editor or by using the following keyboard shortcuts:
- Copy:
Ctrl+Shift+C
(Mac: Cmd+Shift+C
)
- Select:
Ctrl+Shift+S
(Mac: Cmd+Shift+S
)
- Cut:
Ctrl+Shift+X
(Mac: Cmd+Shift+X
)
⚠️ Note about shortcuts: The Ctrl+Shift+C
shortcut may conflict with the native "Developer: Toggle DevTools" command in some configurations. You can customize shortcuts in File > Preferences > Keyboard Shortcuts
.
Motivo da Criação / Reason for Creation
Português:
Eu frequentemente precisava selecionar, copiar ou recortar a função inteira, tendo que realizar múltiplos cliques e scroll manual para capturar todo o trecho de código. Procurei no Marketplace alguma solução que atendesse exatamente essa necessidade e, ao não encontrar, decidi criar esta extensão. Caso já exista uma maneira mais prática ou nativa de realizar essa tarefa no VS Code, peço desculpas. Se houver qualquer problema, por favor, informe para que eu possa realizar as correções necessárias. O código-fonte está disponível no repositório para contribuições e forks.
English:
I often had to manually select, copy, or cut the entire function, which required multiple clicks and manual scrolling to capture the whole code snippet. I searched the Marketplace for a solution that met this specific need, and when I couldn’t find one, I decided to create this extension. If there is an easier or native way to do this in VS Code, I apologize. If you encounter any issues, please let me know so I can address them. The source code is available in the repository for contributions and forks.
Funcionalidades / Features
- Cópia de Função:
Copia o código inteiro da função ou método para o clipboard.
Function Copy: Copies the entire function or method code to the clipboard.
- Seleção de Função:
Seleciona a função inteira no editor, facilitando a análise, modificação ou extração do código.
Function Selection: Selects the entire function in the editor, making it easier to review, modify, or extract the code.
- Recorte de Função:
Recorta (corta) o código inteiro da função ou método para o clipboard e o remove do editor.
Function Cut: Cuts the entire function or method code to the clipboard and removes it from the editor.
- Suporte a Internacionalização:
Mensagens e descrições em inglês e português (pt-BR) utilizando vscode-nls
.
Internationalization Support: Messages and descriptions available in English and Brazilian Portuguese using vscode-nls
.
- Atalho e Menu de Contexto:
Atalhos de teclado:
Ctrl+Shift+C
para copiar
Ctrl+Shift+S
para selecionar
Ctrl+Shift+X
para recortar
e comandos no menu de contexto do editor.
Shortcut and Context Menu: Keyboard shortcuts (as listed above) and commands in the editor context menu.
- Logs para Depuração:
Log detalhado no console para auxiliar na depuração e monitoramento da ativação da extensão.
Debug Logging: Detailed console logging to assist in debugging and monitoring extension activation.
Onde Foi Testado / Where It Was Tested
Português:
Apenas testei a extensão usando C e TypeScript, mas acredito que ela funcione com diversas outras linguagens de programação.
English:
I have only tested the extension using C and TypeScript, but I believe it should work with many other programming languages.
Requisitos / Requirements
- VS Code: Versão ^1.75.0 ou superior.
VS Code: Version ^1.75.0 or higher.
- Node.js: Recomenda-se a versão 18 ou superior.
Node.js: Node.js version 18 or higher is recommended.
- TypeScript: Utilizado para o desenvolvimento da extensão.
Instalação / Installation
Clone o repositório:
git clone https://github.com/mmlo/vscode-copy-function-extension.git
Desenvolvimento / Development
Pré-requisitos / Prerequisites
Português:
- Node.js: Versão 18 ou superior
- npm: Para gerenciamento de pacotes
- VS Code: Versão ^1.75.0 ou superior
English:
- Node.js: Version 18 or higher
- npm: For package management
- VS Code: Version ^1.75.0 or higher
Compilação / Build
Português:
Instale as dependências:
npm install
Compile a extensão:
npm run compile
Este comando irá:
- Compilar o TypeScript para JavaScript usando webpack
- Gerar o arquivo
out/extension.js
otimizado
English:
Install dependencies:
npm install
Compile the extension:
npm run compile
This command will:
- Compile TypeScript to JavaScript using webpack
- Generate the optimized
out/extension.js
file
Teste Local no VS Code / Local Testing in VS Code
Português:
Abra o projeto no VS Code:
code .
Pressione F5 ou vá em Run > Start Debugging:
- Isso abrirá uma nova janela do VS Code com a extensão carregada
- A extensão será ativada automaticamente quando você usar os comandos
Teste os comandos:
- Abra um arquivo de código (TypeScript, JavaScript, etc.)
- Escreva uma função
- Clique com botão direito dentro da função
- Teste os comandos: "Copy Function", "Select Function", "Cut Function"
- Teste os atalhos:
Ctrl+Shift+C
, Ctrl+Shift+S
, Ctrl+Shift+X
English:
Open the project in VS Code:
code .
Press F5 or go to Run > Start Debugging:
- This will open a new VS Code window with the extension loaded
- The extension will activate automatically when you use the commands
Test the commands:
- Open a code file (TypeScript, JavaScript, etc.)
- Write a function
- Right-click inside the function
- Test the commands: "Copy Function", "Select Function", "Cut Function"
- Test the shortcuts:
Ctrl+Shift+C
, Ctrl+Shift+S
, Ctrl+Shift+X
Teste Local no Browser / Local Testing in Browser
Português:
Instale as dependências de teste web:
npm install -g @vscode/test-web
Execute os testes web:
npx @vscode/test-web --extensionDevelopmentPath=.
Este comando irá:
- Abrir uma página web no seu navegador padrão
- Carregar a extensão em um ambiente web simulado
- Permitir testar a funcionalidade no github.dev/vscode.dev
Teste no browser:
- Abra um arquivo de código no editor web
- Use os comandos do menu de contexto
- Verifique se a extensão funciona corretamente
English:
Install web testing dependencies:
npm install -g @vscode/test-web
Run web tests:
npx @vscode/test-web --extensionDevelopmentPath=.
This command will:
- Open a web page in your default browser
- Load the extension in a simulated web environment
- Allow testing functionality in github.dev/vscode.dev
Test in browser:
- Open a code file in the web editor
- Use context menu commands
- Verify the extension works correctly
Publicação no Marketplace / Publishing to Marketplace
Português:
Instale o VSCE (VS Code Extension Manager):
npm install -g @vscode/vsce
Faça login no marketplace (opcional, se não estiver logado):
vsce login <publisher-name>
Nota: Você precisa de uma conta no Azure DevOps ou GitHub para publicar.
Crie o pacote da extensão:
vsce package
Este comando irá:
- Criar um arquivo
.vsix
(ex: copy-function-extension-0.0.8.vsix
)
- O arquivo será otimizado usando o
.vscodeignore
Teste o pacote localmente (opcional):
code --install-extension copy-function-extension-0.0.8.vsix
Publique no marketplace:
vsce publish
Ou para publicar uma versão específica:
vsce publish <version>
Verifique a publicação:
English:
Install VSCE (VS Code Extension Manager):
npm install -g @vscode/vsce
Login to marketplace (optional, if not logged in):
vsce login <publisher-name>
Note: You need an Azure DevOps or GitHub account to publish.
Create the extension package:
vsce package
This command will:
- Create a
.vsix
file (e.g., copy-function-extension-0.0.8.vsix
)
- The file will be optimized using
.vscodeignore
Test the package locally (optional):
code --install-extension copy-function-extension-0.0.8.vsix
Publish to marketplace:
vsce publish
Or to publish a specific version:
vsce publish <version>
Verify publication:
Scripts Disponíveis / Available Scripts
Português:
{
"scripts": {
"vscode:prepublish": "npm run compile",
"compile": "webpack --mode production",
"test": "npm run lint && npm run unit-test",
"lint": "eslint . --ext .ts",
"unit-test": "mocha ./out/test/**/*.test.js",
"webpack": "webpack --mode development"
}
}
npm run compile
- Compila a extensão para produção
npm run webpack
- Compila em modo desenvolvimento
npm test
- Executa linting e testes unitários
npm run lint
- Executa apenas o linting
English:
{
"scripts": {
"vscode:prepublish": "npm run compile",
"compile": "webpack --mode production",
"test": "npm run lint && npm run unit-test",
"lint": "eslint . --ext .ts",
"unit-test": "mocha ./out/test/**/*.test.js",
"webpack": "webpack --mode development"
}
}
npm run compile
- Compiles the extension for production
npm run webpack
- Compiles in development mode
npm test
- Runs linting and unit tests
npm run lint
- Runs only linting
Contribuição / Contributing
Português:
- Fork o projeto
- Crie uma branch para sua feature (
git checkout -b feature/AmazingFeature
)
- Commit suas mudanças (
git commit -m 'Add some AmazingFeature'
)
- Push para a branch (
git push origin feature/AmazingFeature
)
- Abra um Pull Request
English:
- Fork the project
- Create a feature branch (
git checkout -b feature/AmazingFeature
)
- Commit your changes (
git commit -m 'Add some AmazingFeature'
)
- Push to the branch (
git push origin feature/AmazingFeature
)
- Open a Pull Request
Licença / License
Português:
Este projeto está sob a licença MIT - veja o arquivo LICENSE.md para detalhes.
English:
This project is licensed under the MIT License - see the LICENSE.md file for details.
Suporte / Support
Português:
Se você encontrar algum problema ou tiver sugestões:
- Abra uma issue no GitHub
- Verifique os logs no Developer Console (F12) para mensagens de erro
- Certifique-se de que está usando uma linguagem suportada
English:
If you encounter any issues or have suggestions:
- Open an issue on GitHub
- Check the logs in Developer Console (F12) for error messages
- Make sure you are using a supported language
Última atualização: Outubro 2025