Skip to content

Instantly share code, notes, and snippets.

@niftynei
Last active August 8, 2016 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niftynei/bf03dae06fc6bdc62a0200774395d080 to your computer and use it in GitHub Desktop.
Save niftynei/bf03dae06fc6bdc62a0200774395d080 to your computer and use it in GitHub Desktop.
keycodes: https://gist.github.com/awidegreen/3854277
let's talk about modes!
there are 3 modes.
"n" (or normal) mode
"i" (or insert) mode
"v" (or visual) mode
keyboard shortcuts that i use a lot:
down - j
down 5 lines - 5j
delete line - dd
delete 20 lines - 20dd
delete to end of file - dgg
yy - yank and paste
:reg (registers)
/ (search)
? (reverse search)
:line_number
[{ & }] (code block jumping!)
running commands `!`
pattern match & replace
[I (show all uses of this word)
* (jump between current word)
split screen, and navigating between them
tmux & ^Z
buffers! (opening multiple files)
writing a custom key binding:
try this
:%!python -m json.tool
shorten this to a command
:command JsonFmtAll %!python3 -m json.tool
(run :JsonFmtAll) . this is a lot to type. let's make a shortcut for it
:nnoremap & :JsonFmtAll<CR>
that's great. but what if my file looks like this:
{ "json":"this is", "some" :"json" }
Not Json.
here's another command
:command -range JsonFmt <line1>,<line2>!python3 -m json.tool
great. now we want to remap a key, but only when in visual mode
:vnoremap & :JsonFmt<CR>
here's what i put in my .vimrc file
" Fast JSON formatting
command JsonFmtAll %!python3 -m json.tool
command -range JsonFmt <line1>,<line2>!python3 -m json.tool
nnoremap & :JsonFmtAll<CR>
vnoremap & :JsonFmt<CR>
good resource for more VIMscripting:
http://learnvimscriptthehardway.stevelosh.com/chapters/03.html
.vimrc
pathogen: https://github.com/tpope/vim-pathogen
vimium: vim in your browser! https://vimium.github.io/
IntelliJ plugins!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment