Skip to content

Instantly share code, notes, and snippets.

@existme
Last active August 29, 2015 13:59
Show Gist options
  • Save existme/10564512 to your computer and use it in GitHub Desktop.
Save existme/10564512 to your computer and use it in GitHub Desktop.

Caching Password: Overcomming the need for reentering password on GitHub.

git config --global credential.helper cache
git config --global credential.helper "cache --timeout=3600"
git config --global credential.helper osxkeychain

For Windows, there is a helper called git-credential-winstore.exe. For Linux, you can use gnome-keyring.

First Header Second Header
Content Cell Content Cell
Content Cell Content Cell

Let's try something else.

These are some of the usefull help files that could be used for quick reference.

help change

Vim Matching

To see a complete list of color groups:

:so $VIMRUNTIME/syntax/hitest.vim
:match Group /pattern/
:match ErrorMsg /^Error/
:highlight MyGroup ctermbg=red guibg=red gctermfg=yellow guifg=yellow term=bold
:match NONE

You are working on a normal te:xt file and in the middle of a sentence you realize that you have forgotten to make the first letter in the paragraphs uppercase. You could, of course, use the arrow keys or the H | J | K | L navigation keys to move to the beginning of the paragraph to correct this. However, it would be faster to just press the following in the normal mode: { You are now placed at the beginning of the paragraph, or in the empty line just above it (if one exists). Now, you go into the normal mode by pressing the Esc key and then use the { movement command to go to the beginning of the paragraph. The same can be applied if you want to go back to the end of the paragraph—you simply have to use the counterpart of {, namely: }

djlfjaldskjf adklsjfldkaf lasdj jdfhakjsdhfjk ahkjadfhja sdfhk adhs kjdhfkjahdfjk adhkf adhskjf ahskdjf ahks {{{}}}

:%s/teh/the/g :%s/teh/the/c

:echo $VIM
:echo $MYVIMRC

vimrc can use other files as an external source for configurations: source /path/to/external/file gvimrc is used for GVim. No need to duplicate.

:set guifont=Courier\ New\ 12

ZZ : Automatic content push to the remote

command ZZ w|execute "!git add --all && git commit -m updated && git push"

Surrounding:

CMD Desc
ysaW* Surround a complete variable by character *.
{viusal}r{char} Replace each char of the selected text with {char}.
"0p Paste register 0
:dis Display all registers

For having linebreaks at then of each line: :set nolist :set lbr :set wrap

In Vim, abbreviations are created with one of the following commands depending on which mode they should be available in:

  • abbreviate: Abbreviations for all modes

  • iabbrev: Abbreviations for the insert mode

:iabbrev addr Lincoln Road, Birmingham B27 6PA, United Kingdom
:iabbr teh the
:iabbr forx for(x=0;x<100;x++){<cr><cr>}
:iabbr viml ````VimL<CR><CR>````<CR>
  • cabbrev: Abbreviations for the command line only
:cabbr csn colorscheme night

A good place to keep your abbreviations so that you don't have to execute all the commands by hand is in a file in your VIMHOME. Simply place a file there—let's call it abbreviations.vim and write all your abbreviations in it. Then, in your vimrc file, just make sure that the file is read, which is done with the source command:

:source $VIM/abbreviations.vim

The main commands to know when dealing with key bindings are:

  • map: For the Normal, Insert, Visual, and Command-line modes
  • imap: For the Insert mode only
  • cmap: For the Command-line mode only
  • nmap: For the Normal mode only
  • vmap: For the Visual mode only
Keys Notation
<BS> Backspace Tab
<Tab> Tab
<CR> Enter
<Enter> Enter
<Return> Enter
<Esc> Escape
<Space> Space
<Up> Up arrow
<Down> Down arrow
<Left> Left arrow
<Right> Right arrow
<F1>-F12> Function keys 1 to 12
#1,2..#9,#0 Function keys F1 to F9, F10
<Insert> Insert
<Del> Delete
<Home> Home
<End> End
<PageUp> Page up
<PageDown> Page down

Examples:

Saving only when in insert mode:
:imap <C-s> <esc>:w<cr>a

Navigating through buffers
map <C-right> <ESC>:bn<CR>
map <C-left> <ESC>:bp<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment