vim-logger provides easy print statements for some common languages. I get tired of having to type out console.log('my var', myVar);
so this plugin makes it possible to insert log statements with a few keystrokes
Out of the box this plugin provides 3 mappings:
cly
- in normal mode to add a log statement for the last thing you yankedcll
- starts a print statement for you (and leaves you in insert mode where it counts)cl
followed by a text object, like:
cliw
will log out the word under the cursorcliW
will log out the Word under the cursorclib
will log out whatever is in between parens ()- etc.
cl
also works in visual mode and will add a log statement with the selected text
It's recommneded you use your favorite bundler like Vundle or Pathogen
Templates for log statements are preconfigured by file extension, but can be overridden (or new extensions can be supported) by setting the following in your vimrc
let g:vim_logger_templates = {
\'js': "console.log('$$', $$)"
\'py': "print('$$', $$)"
\}
The special characters $$
are used as find and replace
markers, meaning, they will get substituted for the incoming text object.
The default mappings are as follows. You can copy these into your vimrc and change them to your liking.
" Add a print statement for whatever is in the Yank register
nmap co <Plug>LogFromLastYank
" Create a new line with a barebones print statment
nmap ci <Plug>LogFromInsertMode
" Log from following text object
nmap cl <Plug>LogFromTextObject
vmap cl <Plug>LogFromTextObject