Skip to content

lesgrieve/paste-indent

Repository files navigation

paste-indent README

This Visual Studio Code Extension is meant to recreate the paste_and_indent feature in Sublime Text 3. That causes pasted content to follow the indentation of the current line. This began as a fork of https://github.com/partkyle/paste-and-indent but function diverged enough to create a new project. I tried all of the paste_and_indent VS Code extensions, all have some flaw.

Paste and Indent by g3rry
    Some characters are always selected leading to loss of pasted content
Indent on Paste by gazugafan
    No hotkey
    Reformats
paste-and-indent by partkyle
    Pasted contents cannot begin with blank line
Paste with Indent by anhnhoktvn
    Reformats

paste-and-indent was the superior extension, so I decided to solve the small problem I had with it. The content I wish to paste often begins with one or more blank lines. The result with paste-and-indent was that nothing would be pasted. With paste-indent, content beginning with blank lines is pasted and content is left justified. Huge thanks to partkyle for preparing this valuable extension.

Features

Provides a command palette item named paste-indent that will paste text following the indentation of the current line. The pasted block is left justified within the indentation.

There are no keybindings set, but you can set them yourself. I suggest mapping "ctrl+cmd+v" to the paste-indent command. On macOs, I have ~/Library/Application Support/Code/User/keybindings.json

    {
        "key": "ctrl+cmd+v",
        "command": "extension.paste-indent",
        "when": "editorTextFocus && !editorReadonly"
    },
    {
        "key": "ctrl+cmd+v",
        "command": "editor.action.clipboardPasteAction",
        "when": "!editorTextFocus"
    },

An alternate way to map a shortcut key is through VSCode menu Settings... -> Keyboard Shortcuts, search for paste-indent. Edit Keybinding and set ctrl+cmd+v.

Requirements

None

Extension Settings

None

Known Issues

None

Release Notes

[0.0.6] - 2025-09-02

  • Issue-9 Fix Handle Windows line endings ("\r\n") with multiple cursors.

About

Visual Studio Code Extension meant to recreate the paste_and_indent feature from Sublime Text 3.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors