### Vim: Install fugitive.vim using Vim's built-in package support Source: https://github.com/tpope/vim-fugitive/blob/master/README.markdown This snippet demonstrates how to install the fugitive.vim plugin using Vim's built-in package management system. It involves creating a directory structure and cloning the plugin repository. ```vim mkdir -p ~/.vim/pack/tpope/start cd ~/.vim/pack/tpope/start git clone https://tpope.io/vim/fugitive.git vim -u NONE -c "helptags fugitive/doc" -c q ``` -------------------------------- ### Start Git Interactive Prompt Source: https://github.com/tpope/vim-fugitive/wiki/Basic-fugitive-commands Initiates the interactive Git prompt within Vim, allowing for navigation and execution of Git commands. Press 'g?' for a help screen explaining available commands. ```vim :G :Git ``` -------------------------------- ### Vim Autocommand for Fugitive Blob Overrides Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt An example of setting up a Vim autocommand to call a custom function when a Fugitive blob object is loaded. This allows for custom handling or overrides. ```vimscript autocmd User FugitiveBlob,FugitiveStageBlob call s:BlobOverrides() ``` -------------------------------- ### Customize Vim Statusline with Fugitive Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Adds Git branch and commit information to the Vim statusline using the FugitiveStatusline() function. This example demonstrates a common statusline configuration. ```vimscript set statusline=%<%f %h%m%r%{FugitiveStatusline()}%=%-14.(%l,%c%V%) %P ``` -------------------------------- ### vim-fugitive: Help Commands Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Command to display the help documentation for vim-fugitive. ```vim c? Show this help. ``` -------------------------------- ### Vim: Browse files on web hosting providers with :GBrowse Source: https://github.com/tpope/vim-fugitive/blob/master/README.markdown This command opens the current file in a web browser, leveraging the front-end of your Git hosting provider. It supports optional line ranges and can be used in visual mode. Plugins exist for providers like GitHub, GitLab, and Bitbucket. ```vim " Open current file in browser :GBrowse " Open a specific range in the browser (visual mode) :GBrowse :normal! "ayiw :call GBrowse(':' . @a) ``` -------------------------------- ### Grep Commands (Git and Vim) Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Provides 'grep' functionality using 'git-grep' as the 'grepprg'. It can either display output directly or open the quickfix list when the '--quiet' or '-q' flag is used. The '!' flag jumps to the first match. ```vim :Ggrep[!] [args] :Git[!] grep -O [args] ``` ```vim :Ggrep[!] --quiet [args] :Ggrep[!] -q [args] ``` -------------------------------- ### Git Difftool Command Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Invokes 'git diff' with provided arguments and loads changes into the quickfix list. Each changed hunk becomes a quickfix entry unless specific options are used. Jumps to the first change by default, unless '!' is given. ```vim :Git[!] difftool [args] ``` -------------------------------- ### Git Commit Log Command Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Loads commit history into the quickfix list using 'git log [args]'. The '!' flag jumps to the first commit. For large datasets, ':Git log --oneline' is recommended for better performance. ```vim :Gclog[!] [args] ``` -------------------------------- ### vim-fugitive: Git Branch Commands Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Commands for checking out and creating Git branches within Vim. 'cb' populates the command line for branch creation, and 'co' for checking out. ```vim cb Populate command line with ":Git branch ". ``` ```vim co Populate command line with ":Git checkout " ``` -------------------------------- ### vim-fugitive: Git Checkout/Branch Commands Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Commands for checking out specific commits and showing help for checkout/branch operations. ```vim coo Check out the commit under the cursor. ``` ```vim cb? Show this help. ``` ```vim co? Show this help. ``` -------------------------------- ### Git Log Command for Location List Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Similar to ':Gclog', but loads the commit history into the location list instead of the quickfix list. ```vim :Gllog [args] ``` -------------------------------- ### vim-fugitive: Navigation Commands Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Commands to navigate through different sections of Git status (Untracked, Unstaged, Staged, Unpushed, Unpulled, Rebasing). ```vim gu Jump to file [count] in the "Untracked" or "Unstaged" section. ``` ```vim gU Jump to file [count] in the "Unstaged" section. ``` ```vim gs Jump to file [count] in the "Staged" section. ``` ```vim gp Jump to file [count] in the "Unpushed" section. ``` ```vim gP Jump to file [count] in the "Unpulled" section. ``` ```vim gr Jump to file [count] in the "Rebasing" section. ``` -------------------------------- ### vim-fugitive: .gitignore and .git/info/exclude Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Command to open the .git/info/exclude file for editing. A count argument switches to opening .gitignore instead. ```vim gi Open .git/info/exclude in a split. Use a count to open .gitignore. ``` -------------------------------- ### Navigation and File Opening in Vim Fugitive Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Navigate between files, hunks, or revisions using CTRL-P ('(') and CTRL-N (')'). Open the file or object under the cursor in various splits (horizontal, vertical), tabs, or a preview window using '', 'o', 'gO', 'O', and 'p' respectively. '~' opens the file in the Nth ancestor, and 'P' opens in the Nth parent. ```vim " Open the file or |fugitive-object| under the cursor. " In a blob, this and similar maps jump to the patch " from the diff where this was added, or where it was " removed if a count was given. If the line is still in " the work tree version, passing a count takes you to " it. " o Open the file or |fugitive-object| under the cursor in " a new split. " gO Open the file or |fugitive-object| under the cursor in " a new vertical split. " O Open the file or |fugitive-object| under the cursor in " a new tab. " p Open the file or |fugitive-object| under the cursor in " a preview window. In the status buffer, 1p is " required to bypass the legacy usage instructions. " ~ Open the current file in the [count]th first ancestor. " P Open the current file in the [count]th parent. " Experimental: In the "Unpushed" section of the status " buffer, this will populate the command line with a " ":Git push" command for the commit under the cursor. " ( Jump to the previous file, hunk, or revision. " ) Jump to the next file, hunk, or revision. ``` -------------------------------- ### Git Browse (:GBrowse) Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Opens the current file, blob, tree, commit, or tag in the browser at the upstream hosting provider. Supports custom remotes and ranges for anchors. ```vim :GBrowse [object] :GBrowse {object} :{range}GBrowse [args] :GBrowse [...]@{remote} :GBrowse {url} :[range]GBrowse! [args] ``` -------------------------------- ### View Git Status Summary Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Opens a summary window that provides an overview similar to 'git-status'. If a summary window is already open for the current repository, it is focused instead. Further usage details are available via '|fugitive-maps|'. ```vim :Git ``` -------------------------------- ### Execute Git Commands and Split Output Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Executes a Git command, saves the output to a temporary file, and then opens that file in a new split window. An alternative exists to edit the temp file in the current window. This is particularly useful for commands like diff and log. ```vim :Git --paginate {args} ``` ```vim :Git -p {args} ``` -------------------------------- ### Manage .gitignore/.git/info/exclude with Vim Fugitive Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Open .git/info/exclude or .gitignore in a split and add the file under the cursor using 'gI'. Use a count to open .gitignore. ```vim " gI Open .git/info/exclude in a split and add the file " under the cursor. Use a count to open .gitignore. ``` -------------------------------- ### Vim: Search using Git's grep functionality Source: https://github.com/tpope/vim-fugitive/blob/master/README.markdown fugitive.vim provides :Ggrep and :Glgrep for searching within the repository using 'git grep'. These commands integrate seamlessly with Vim's search capabilities. ```vim " Search for 'pattern' in the repository :Ggrep pattern " Use :lgrep for a similar functionality :Glgrep pattern ``` -------------------------------- ### Preview Edit Git Object Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Opens a specified Git object in a preview window using Vim's '|:pedit|' command. ```vim :Gpedit [object] ``` -------------------------------- ### Staging/Unstaging Maps Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Maps for staging (adding) and unstaging (resetting) files or hunks under the cursor. These are available in Fugitive summary and object buffers. ```vim s u ``` -------------------------------- ### Background Git Command Execution with Output Streaming Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Runs Git commands in the background and streams their output to the preview window. This feature requires Vim to have the setbufline() function. Users can switch to this mode interactively during a :Git invocation. ```vim :Git! {args} ``` -------------------------------- ### Write and Quit Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Performs the same action as ':Gwrite' and then quits the buffer if the write operation was successful. This is analogous to Vim's '|:wq|'. ```vim :Gwq [path] ``` -------------------------------- ### Run Git Blame and Navigate Results Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Executes 'git-blame' on the current file and displays the results in a scroll-bound vertical split. It provides several key mappings for navigating blame information, such as resizing columns, closing the blame view, jumping to specific commits, and reblaming. ```vim :Git blame [flags] ``` ```vim :{range}Git blame [...] ``` -------------------------------- ### Vim: View repository contents with :Gedit Source: https://github.com/tpope/vim-fugitive/blob/master/README.markdown The :Gedit command allows viewing various Git objects like blobs, trees, commits, or tags within Vim. You can specify paths and revisions to load content into a buffer. ```vim " Load the current file as it existed 3 commits ago :Gedit HEAD~3:% ``` -------------------------------- ### vim-fugitive: Git Stash Commands Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Commands for managing Git stashes. Includes pushing stashes with options for untracked/all files, pushing work-tree or staged changes, applying, preserving index, and popping stashes. ```vim czz Push stash. Pass a [count] of 1 to add `--include-untracked` or 2 to add `--all`. ``` ```vim czw Push stash of the work-tree. Like `czz` with `--keep-index`. ``` ```vim czs Push stash of the stage. Does not accept a count. ``` ```vim czA Apply topmost stash, or stash@{count}. ``` ```vim cza Apply topmost stash, or stash@{count}, preserving the index. ``` ```vim czP Pop topmost stash, or stash@{count}. ``` ```vim czp Pop topmost stash, or stash@{count}, preserving the index. ``` ```vim cz Populate command line with ":Git stash ". ``` -------------------------------- ### vim-fugitive: Git Rebase Commands Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Commands for performing various Git rebase operations. This includes interactive rebase, autosquash rebase, continuing, skipping, aborting, and editing the rebase todo list. ```vim ri Perform an interactive rebase. Uses ancestor of commit under cursor as upstream if available. ``` ```vim rf Perform an autosquash rebase without editing the todo list. Uses ancestor of commit under cursor as upstream if available. ``` ```vim ru Perform an interactive rebase against @{upstream}. ``` ```vim rp Perform an interactive rebase against @{push}. ``` ```vim rr Continue the current rebase. ``` ```vim rs Skip the current commit and continue the current rebase. ``` ```vim ra Abort the current rebase. ``` ```vim re Edit the current rebase todo list. ``` ```vim rw Perform an interactive rebase with the commit under ``` -------------------------------- ### Stage File in Vim Source: https://github.com/tpope/vim-fugitive/wiki/Basic-fugitive-commands Stages a file for commit by moving the cursor to the file's line in the interactive prompt and pressing 's'. The file will move to the 'Staged' list. ```vim s ``` -------------------------------- ### Execute Git Commands in Vim Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Allows running arbitrary Git commands directly from Vim. The output is displayed within Vim, with file edits loaded into split windows. Different platforms may exhibit slight behavior differences. ```vim :Git {args} ``` ```vim :G [args] ``` -------------------------------- ### Git Blame Command Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Executes 'git blame' on a specified file, displaying blame information. It opens the output in a horizontal split without scrollbinding. An arbitrary filename can be provided. ```vim :Git blame [...] {file} ``` -------------------------------- ### Vim: Move and rename files with :GMove and :GRename Source: https://github.com/tpope/vim-fugitive/blob/master/README.markdown These commands perform 'git mv' operations. :GMove moves the current file and updates the buffer name, while :GRename moves the file relative to its current directory. ```vim " Move current file and update buffer name :GMove new/path/to/file.txt " Rename current file relative to its directory :GRename new_filename.txt ``` -------------------------------- ### Open Commit with Vim Fugitive Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Open the commit containing the current file using the 'C' command. ```vim " C Open the commit containing the current file. ``` -------------------------------- ### Vim: Compare staged and working tree versions with :Gdiffsplit Source: https://github.com/tpope/vim-fugitive/blob/master/README.markdown This command opens the staged version of a file side-by-side with the working tree version, enabling you to use Vim's diff capabilities to manage changes before staging. ```vim " Open staged version side-by-side with working tree version :Gdiffsplit " Diff against an older version of the file :Gdiffsplit HEAD~1:% ``` -------------------------------- ### Set Git core.worktree Manually Source: https://github.com/tpope/vim-fugitive/blob/master/README.markdown This snippet shows how to manually configure the 'core.worktree' setting in Git, which is sometimes necessary when Git's automatic configuration fails or when using external tools. ```bash git config core.worktree "$PWD" ``` -------------------------------- ### Set Local Directory Relative to Repository Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Sets the local working directory to a specified directory, relative to the Git repository's root. This mirrors Vim's '|:lcd|' command. ```vim :Glcd [directory] ``` -------------------------------- ### Grep Command for lgrep Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt An adaptation of ':Ggrep' that works with Vim's '|:lgrep|'. It uses 'git-grep' and integrates with the location list. ```vim :Glgrep[!] [args] :0Git[!] grep -O [args] ``` -------------------------------- ### Git Write and Quit (:Gwq!) Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Writes the buffer and quits Vim if the write operation is successful. Similar to :Gwrite followed by :quit. ```vim :Gwq! [path] ``` -------------------------------- ### Push Commit in Vim Source: https://github.com/tpope/vim-fugitive/wiki/Basic-fugitive-commands Pushes the committed changes using the Git push command directly from Vim. ```vim :Git push ``` -------------------------------- ### Vim: Execute arbitrary Git commands using :Git Source: https://github.com/tpope/vim-fugitive/blob/master/README.markdown The :Git command (or :G) in fugitive.vim allows execution of any Git command. It provides an integrated experience for Git operations within Vim, with features like direct output echoing and in-editor editing for commands that invoke an editor. ```vim " Example: Stage all changes :Git add . " Example: Commit changes with a message :Git commit -m "My commit message" " Example: View diff with pagination enabled :Git diff --paginate " Example: Open summary window :Git ``` -------------------------------- ### Managing Diff Buffers with Vim Fugitive Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Close all but the current diff buffer and invoke ':diffoff!' using 'dq'. 'd?' displays help information for diff commands. ```vim " dq Close all but the currently focused diff buffer, and " invoke |:diffoff|!. " d? Show this help. ``` -------------------------------- ### Git Commit Log for File Range Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Loads previous revisions of a specified line range within the current file into the quickfix list using 'git log -L'. The cursor is placed on the first line of each commit's diff hunk. Use ':0Gclog' for the entire file. ```vim :{range}Gclog[!] [args] ``` -------------------------------- ### Git Difftool with New Tabs Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Invokes 'git diff' with arguments, opens each changed file in a new tab, and then executes ':Gdiffsplit!' against the appropriate commit. ```vim :Git difftool -y [args] ``` -------------------------------- ### Write and Stage Changes Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Writes changes to the current file's path and stages them using 'git add'. If not in a work tree file, it acts like 'git checkout'. Handles cases where the work tree or index version is open in another buffer. ```vim :Gwrite ``` -------------------------------- ### Vim: Delete files with :GDelete and :GRemove Source: https://github.com/tpope/vim-fugitive/blob/master/README.markdown Perform 'git rm' operations with these commands. :GDelete removes the file and closes the buffer, while :GRemove removes the file but leaves the (empty) buffer open. ```vim " Remove current file and delete buffer :GDelete " Remove current file but leave buffer open :GRemove ``` -------------------------------- ### Git Mergetool Command Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Similar to ':Git difftool', but targets merge conflicts. It invokes 'git mergetool' and loads conflict information. ```vim :Git mergetool [args] ``` -------------------------------- ### Commit Changes in Vim Source: https://github.com/tpope/vim-fugitive/wiki/Basic-fugitive-commands Commits staged changes after providing a commit message. Use ':wq' to finalize the commit process. ```vim cc :wq ``` -------------------------------- ### Stage/Unstage Files and Hunks in Vim Fugitive Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Commands to stage or unstage the file or hunk under the cursor. 'U' unstages everything. These commands directly interact with the Git staging area. ```vim " Stage or unstage the file or hunk under the cursor. " U Unstage everything. ``` -------------------------------- ### Drop Git Object Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Opens a specified Git object in the current window using Vim's '|:drop|' command. If the object is already open, it jumps to it. ```vim :Gdrop [object] ``` -------------------------------- ### Change Directory Relative to Repository Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Changes the current working directory to a specified directory, relative to the Git repository's root. This is analogous to Vim's ':cd' command. ```vim :Gcd [directory] ``` -------------------------------- ### Patching and Untracked Files with Vim Fugitive Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Invoke ':Git' add --patch or reset --patch on the file under the cursor with 'I'. For untracked files, this calls ':Git' add --intent-to-add. ```vim " I Invoke |:Git| add --patch or reset --patch on the file " P under the cursor. On untracked files, this instead " calls |:Git| add --intent-to-add. ``` -------------------------------- ### Git Move (:GMove) Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt A wrapper around git-mv that renames the buffer afterward. Add '!' to pass the -f flag for forceful renaming. ```vim :GMove {destination} ``` -------------------------------- ### Insert Git Command Output into Current Buffer Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Runs a Git command and inserts its output directly after a specified line range in the current buffer. This is useful for incorporating command results inline. ```vim :{range}Git! --paginate {args} ``` ```vim :{range}Git! -p {args} ``` -------------------------------- ### Vim: Stage and write changes with :Gwrite Source: https://github.com/tpope/vim-fugitive/blob/master/README.markdown This command writes changes to both the working tree and the Git index. When used on a file in the working tree, it acts like 'git add'. When used from the index or a historical blob, it updates the working tree. ```vim " Stage changes and write to working tree :Gwrite ``` -------------------------------- ### vim-fugitive: Git Commit Commands Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Commands for creating and amending Git commits. These include options for editing the commit message, amending with verbose output, rewording, and creating fixup/squash commits. ```vim cc Create a commit. ``` ```vim cvc Create a commit with -v. ``` ```vim ca Amend the last commit and edit the message. ``` ```vim cva Amend the last commit with -v. ``` ```vim ce Amend the last commit without editing the message. ``` ```vim cw Reword the last commit. ``` ```vim cW Create an `amend!` commit that rewords the commit under the cursor. ``` ```vim cf Create a `fixup!` commit for the commit under the cursor. ``` ```vim cF Create a `fixup!` commit for the commit under the cursor and immediately rebase it. ``` ```vim cs Create a `squash!` commit for the commit under the cursor. ``` ```vim cS Create a `squash!` commit for the commit under the cursor and immediately rebase it. ``` ```vim cn Create a `squash!` commit for the commit under the (formerly cA) cursor and edit the message. ``` ```vim c Populate command line with ":Git commit ". ``` -------------------------------- ### Split Edit Git Object Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Opens a specified Git object in a new horizontal split window using Vim's '|:split|' command. ```vim :Gsplit [object] ``` -------------------------------- ### Git Rename (:GRename) Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Operates like :GMove but performs the rename relative to the parent directory of the current file. ```vim :GRename {destination} ``` -------------------------------- ### Edit Git Object Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Opens a specified Git object (e.g., a file at a specific commit, a tree) in a new buffer using Vim's '|:edit|' command. ```vim :Gedit [object] ``` -------------------------------- ### Git Delete (:GDelete) Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt A wrapper around git-rm that deletes the buffer afterward. Passes --cached when invoked on an index file. Add '!' to pass -f and discard the buffer forcefully. ```vim :GDelete ``` -------------------------------- ### Git Remove/Unlink (:GRemove, :GUnlink) Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Similar to :GDelete but keeps the buffer around, even if it becomes empty. These commands are aliases. ```vim :GRemove :GUnlink ``` -------------------------------- ### Read Git Object into Buffer Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Clears the current buffer and reads a specified Git object into it using Vim's '|:read|' command. If no object is specified, it acts like 'git checkout' for a work tree file or 'git add' for a staged file, without disk writes. ```vim :Gread [object] ``` -------------------------------- ### Write Changes to Specific Path/Stage Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Writes changes to an explicit path within the work tree. Can also specify paths like ':0:foo.txt' or ':0:%' to write only to that stage in the index. ```vim :Gwrite {path} ``` -------------------------------- ### vim-fugitive: Git Revert Commands Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Commands for reverting Git commits. 'crc' reverts the commit under the cursor, while 'crn' reverts and keeps the changes in the working tree without committing. ```vim crc Revert the commit under the cursor. ``` ```vim crn Revert the commit under the cursor in the index and work tree, but do not actually commit the changes. ``` ```vim cr Populate command line with ":Git revert " ``` -------------------------------- ### Vim: Revert buffer changes with :Gread Source: https://github.com/tpope/vim-fugitive/blob/master/README.markdown Similar to 'git checkout -- filename', :Gread operates on the buffer, allowing undo operations and preventing warnings about file changes outside Vim. It effectively reverts the buffer to the version on disk. ```vim " Revert buffer to the version on disk :Gread ``` -------------------------------- ### Read Git Object After Range Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Reads a specified Git object into the buffer after the given range of lines using Vim's '|:read|' command. ```vim :{range}Gread [object] ``` -------------------------------- ### Git Diff Split (:Gdiffsplit) Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Performs a Vimdiff against a specified file or commit. Without arguments, it compares the index or work tree version. Use :do and :dp for staging/unstaging. ```vim :Gdiffsplit [object] :Gdiffsplit! :Gdiffsplit! {object} ``` -------------------------------- ### Vim: Add FugitiveStatusline to statusline configuration Source: https://github.com/tpope/vim-fugitive/blob/master/README.markdown This Vimscript snippet shows how to add the FugitiveStatusline function to your 'statusline' option. This enables an indicator in your Vim statusline showing the current Git branch. ```vim let &statusline .= '%{FugitiveStatusline()}' ``` -------------------------------- ### Discard Changes with Vim Fugitive Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Discard changes under the cursor using 'X'. This command utilizes 'checkout' or 'clean' internally. For merge conflicts, '2X' uses 'checkout --ours' and '3X' uses 'checkout --theirs'. A command to undo the change is echoed and can be viewed in ':messages'. ```vim " X Discard the change under the cursor. This uses " `checkout` or `clean` under the hood. A command is " echoed that shows how to undo the change. Consult " `:messages` to see it again. During a merge conflict, " use 2X to call `checkout --ours` or 3X to call " `checkout --theirs` . ``` -------------------------------- ### Vertical Split Edit Git Object Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Opens a specified Git object in a new vertical split window using Vim's '|:vsplit|' command. ```vim :Gvsplit [object] ``` -------------------------------- ### Diffing Files in Vim Fugitive Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Perform various diff operations on the file under the cursor. 'dp' invokes ':Git' diff (deprecated in favor of inline diffs), 'dd' performs ':Gdiffsplit', 'dv' performs ':Gvdiffsplit', and 'ds'/'dh' perform ':Ghdiffsplit'. ```vim " dp Invoke |:Git| diff on the file under the cursor. " Deprecated in favor of inline diffs. " dd Perform a |:Gdiffsplit| on the file under the cursor. " dv Perform a |:Gvdiffsplit| on the file under the cursor. " ds Perform a |:Ghdiffsplit| on the file under the cursor. " dh ``` -------------------------------- ### Inline Diffs with Vim Fugitive Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Toggle, insert, or remove inline diffs of the file under the cursor using '=', '>', and '<' respectively. These commands provide visual feedback on file changes directly within the buffer. ```vim " = Toggle an inline diff of the file under the cursor. " > Insert an inline diff of the file under the cursor. " < Remove the inline diff of the file under the cursor. ``` -------------------------------- ### Tab Edit Git Object Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Opens a specified Git object in a new tab using Vim's '|:tabedit|' command. ```vim :Gtabedit [object] ``` -------------------------------- ### Unstage File in Vim Source: https://github.com/tpope/vim-fugitive/wiki/Basic-fugitive-commands Unstages a file by moving the cursor to a staged file and pressing 'u'. The file will be moved from the 'Staged' list back to the 'Unstaged' list. ```vim u ``` -------------------------------- ### Git Vertical Diff Split (:Gvdiffsplit) Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Similar to :Gdiffsplit but always splits the window vertically. ```vim :Gvdiffsplit [object] ``` -------------------------------- ### Configure Fugitive Dynamic Colors Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Disables the highlighting of commit hashes in different colors within the GUI or a 256-color terminal. This setting is useful for users who prefer a consistent color scheme. ```vimscript let g:fugitive_dynamic_colors = 0 ``` -------------------------------- ### Git Horizontal Diff Split (:Ghdiffsplit) Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Diffs against the specified object, removing the 'vertical' option from 'diffopt'. The split will still be vertical if combined with :vertical. ```vim :Ghdiffsplit [object] :Gdiffsplit ++novertical [object] ``` -------------------------------- ### Disable Fugitive Global Maps Source: https://github.com/tpope/vim-fugitive/blob/master/doc/fugitive.txt Disables all global maps provided by the Fugitive plugin. This is achieved by setting the g:fugitive_no_maps variable to 1. ```vimscript let g:fugitive_no_maps = 1 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.