Skip to content

Instantly share code, notes, and snippets.

@carlesandres
Last active March 25, 2018 18:48
Show Gist options
  • Save carlesandres/7796979 to your computer and use it in GitHub Desktop.
Save carlesandres/7796979 to your computer and use it in GitHub Desktop.

My Vim shortcuts

,y Paste things copied before ,ss Search Ultisnips ,sl Search in current buffer with unite ,sw Search word under cursor (unite) ,m List my marks (unite) ma, mb ,... Set file-wide marks mA, mB,... Set project wide marks 'a, 'b, 'A Jump to mark ,V Open VimShell :e Create new files gi Go the last insertion point '' Go to last place before jump gE Like E but backwards ctrl+o Undo one jump ctrl+i Redo one jump

Ctrl + ] to follow the link (jump to the quickref topic). Ctrl + T to go back to the previous topic.

⌘ F:Search
⌥  ⌘ F:Search across all sources
⇧ ⌘ C:Select node to inspect
⌘ P:Go to source
`⇧ + ⌘ + C`    Toggle Inspect Element mode
`⌥ + ⌘ + J`    Open Dev tools console
`⌘ + ]`         Next panel
`⌘ + [`         Previous panel
`⇧ + O`         Goto source
`⌘ + L`         Goto line

https://developer.chrome.com/devtools/docs/tips-and-tricks

http://anti-code.com/devtools-cheatsheet/

git checkout -b twitter-experiment feature132 git branch copying (useful for brnach renaming, 1st copy branch with new name, 2nd delete brnach with old name)

git log --pretty=oneline one line git log

git log --pretty=format:"%h %s" --graph show branch history graphically

git log -2 show only last two commits in log

gitk interactive tool to check git history

git rebase --interactive master tool for rebasing our commit history (useful for squashing commits)

git stash save current state in a commit but don't commit to current branch (is like a temporary store for commits. You can keep several "stashed commits" in the stash)

git stash list see the contents of the git stash

git config format.pretty "format:%h %s" Make git log show the abbreviated form by default

git config --global log.abbrevCommit true another way to change git log format (in this case, globally)

git stash apply apply the contents of the topmost "stash" to the local branch

git stash pop like git stash apply but also removes the "stash"

git stash clear throws away all stashes

git stash drop discard only last stash

git log --stat show statistics of every file in the log (useful!)

git rm --cached file.txt remove file from version control without actually removing the file (you should also add it to .gitignore, of course)

Rebasing / Squashing: http://git-scm.com/book/ch6-4.html#Changing-Multiple-Commit-Messages

ctrl+o lets you issue one normal mode command while in insert mode

map <Space> <C-D> Maps a key in normal and visual modes

nmap Maps a key in normal mode vmap Maps a key in visual mode imap Maps a key in insert mode nunmap / Unmaps the map to the / key

We should never use those commands. Instead, we should use their non-recursive versions to aviod lots problems. (http://learnvimscriptthehardway.stevelosh.com/chapters/05.html) noremap , nnoremap , vnoremap , inoremap

map Shows a list of all mappings

verbose map Shows a list of all current mappings indicating where they were defined

map!


ysiw[ Add square brackets to current word. Remember iw is a text object.

yssb Add surrounding brackets to whole line (same as yss{

ds{ Delete surrounding curly brackets

Gwrite add current file (or its changes to git commit)

Gread revert current file to its previous state in the git repository

Gcommit commit from inside VIM (opens a the commit message file to edit. It is useful to close it with :x)

Gstatus Gblame

Gremove remove current file from our system and from the git repo and wipeout the current buffer

`Gmove newpath/newname.txt' move the current file to a new path (including new name), and open in this very same buffer (path is relative to current's file path)

`Gmove /newpath/newname.txt' same as previous but path is relative to current git repository's path

npm cache clean solved my npm ENOTEMPTY problems

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment