Skip to content

Instantly share code, notes, and snippets.

@abuseofnotation
Last active February 12, 2016 15:30
Show Gist options
  • Save abuseofnotation/f032ee58b8fdb4ef7429 to your computer and use it in GitHub Desktop.
Save abuseofnotation/f032ee58b8fdb4ef7429 to your computer and use it in GitHub Desktop.
Debug node.js Apps from Vim
" A handy mapping for debugging node.js applications from vim using the node build-in debugger.
" Add the following mapping to your .vimrc file:
nnoremap <C-D> Odebugger<esc>:w<CR>:!node debug %:p <CR>dd:w<CR>
" Now in vim, go to the place where you want to break and press Ctrl + D.
" This inserts a 'debugger' statement, at your current line and launches the file in debug mode.
" You can also combine this with a testing framework like nodeunit:
nnoremap <C-D> Odebugger<esc>:w<CR>:!node debug nodeunit<CR>dd:w<CR>
" This works if vim is launched from the project root.
nnoremap <C-D> Odebugger<esc>:w<CR>:!node debug node_modules/nodeunit/bin/nodeunit<CR>dd:w<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment