debugstring


Ⅰ. 插件描述

Debug printf()-style at the speed of light

Ⅱ. 基本信息

创建日期:  2017-12-28
使用用户:  7
Github星:  25
插件作者:  Nikos Koukis

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'bergercookie/debugstring'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'bergercookie/debugstring'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'bergercookie/debugstring'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/bergercookie/vim-debugstring

Ⅳ. 文档说明

# vim-debugstring

<p align="center">


</p>

     _      _                     _        _
    | |    | |                   | |      (_)
  __| | ___| |__  _   _  __ _ ___| |_ _ __ _ _ __   __ _
 / _` |/ _ \ '_ \| | | |/ _` / __| __| '__| | '_ \ / _` |
| (_| |  __/ |_) | |_| | (_| \__ \ |_| |  | | | | | (_| |
 \__,_|\___|_.__/ \__,_|\__, |___/\__|_|  |_|_| |_|\__, |
                         __/ |                      __/ |
                        |___/                      |___/

Purpose

debugstring aims to automate standard debugging operations (e.g., segfaults).
It does that by facilitating the ubiquitous
printf()-debugging
i.e., scatter logging statements around the various code snippets that you want
to test.

Demos

Finding a segfault

demo_gif

Control flow

demo_gif2

Expression evaluation

demo_gif3

Features

  • The form and syntax of the logging statements target the language at hand
    (e.g., use printf() in C/C++ but puts() in Ruby)

Currently the following languages are supported. First column corresponds to the
standard debugging string while the second to the case of debugging for a
specific variable.

LangDebug StringDebug Variable
Arduino:heavy_check_mark::heavy_check_mark:
Awk:x::x:
C:heavy_check_mark::heavy_check_mark:
C#:x::x:
C++:heavy_check_mark::heavy_check_mark:
CMake:heavy_check_mark::heavy_check_mark:
D:x::x:
Fish-Shell:heavy_check_mark::heavy_check_mark:
Fortran:heavy_check_mark::heavy_check_mark:
Go:x::x:
Haskell:heavy_check_mark::heavy_check_mark:
Java:heavy_check_mark::heavy_check_mark:
Javascript:heavy_check_mark::heavy_check_mark:
Julia:x::x:
Lua:x::x:
Makefile:heavy_check_mark::heavy_check_mark:
Matlab:x::x:
PHP:heavy_check_mark::heavy_check_mark:
Perl:x::x:
Python:heavy_check_mark::heavy_check_mark:
R:heavy_check_mark::heavy_check_mark:
Ruby:heavy_check_mark::heavy_check_mark:
Rust:heavy_check_mark::heavy_check_mark:
Scala:x::x:
Shell:heavy_check_mark::heavy_check_mark:
Swift:x::x:
Vim:heavy_check_mark::heavy_check_mark:
Visual Basic:x::x:
  • Support for debugging variable expressions e.g., the values of variables or
    arbitrary expressions at certain parts of your code
  • Support for vim-repeat. No
    need for repeat the same mapping, or rewrite the lengthy expression that you
    want to monitor, just use the . character

For a more detailed outline of debugstring check
doc/debugstring.txt

Usage

Use the mappings of your choice to place unique logging directives during
debugging times.

nnoremap <your-key-combination> <Plug>DumpDebugString
nnoremap <a-second-key-combination> <Plug>DumpDebugStringExpr

Default mappings are: <Leader>ds, <Leader>dS respectively.

An example of using it in a C++ file is given below:

// Debug String
std::cout << "[a.c:4] DEBUGGING STRING ==> " << 0 << std::endl;

// Debug Variable
std::cout << "[a.c:4] a_variable: " << a_variable << std::endl;

Remarks - Debugging

  • Make sure that filetype plugin is enabled. A line like filetype plugin on in
    your .vimrc should do the job.

Installation

Plugin managerHow to install
Deincall dein#add('bergercookie/vim-debugstring')
minpaccall minpac#add('bergercookie/vim-debugstring')
Pathogengit clone https://github.com/bergercookie/vim-debugstring.git ~/.vim/bundle/vim-debugstring
PlugPlug 'bergercookie/vim-debugstring'
VundlePlugin 'bergercookie/vim-debugstring'
manualcopy all of the files into your .vim directory (or ~/.config/nvim if you're using neovim)

Dependencies

debugstring depends on the following vim plugins:

  • vim-repeat [OPTIONAL]

Contributing

In case you want to contribute on a certain feature/fix, don't hesitate to
discuss about it in the Github issues or to implement it and make a PR.

License

Current plugin is distributed under the same terms as Vim itself. See the
LICENSE
file

Self Promotion

In case you like the plugin, you might as well [star it on
Github](https://github.com/bergercookie/vim-debugstring) or [rate it on
vim.org](https://vim.sourceforge.io/scripts/script.php?script_id=5634) Also feel
free to check my [other
plugins](https://github.com/bergercookie?tab=repositories)

Notes on Development

This mostly comprises a list of stuff I want to keep track of when developing
this or other vim plugins

  • Use vimdoc to generate documentation from
    the vim docstring (instead of manually updating the .txt file). See the
    misc/build_doc for more on how this is done.
  • Use vader for unittesting. Use
    test/run-tests.sh to run them. For this to run you have to first git clone
    vim-repeat and vim-vader in the root of this repo:

    git clone https://github.com/junegunn/vader.vim.git
    git clone https://github.com/tpope/vim-repeat.git

TODO

  • [ ] Method to delete all the debugging strings in current buffer / all "touched" buffers - see far.vim
  • [x] Method to print name and contents of a variable
  • ~[ ]Make the counter buffer-specific~ Nope, we already have the filename &
    line for file-specific text
  • [ ] Escape double single quotes vimscript variable printing
  • [x] Append to current line if that is empty
  • [x] Support repeat.vim
  • [x] Use an assertion module - vader
  • [x] Use vader.vim for TDD
  • [x] Extend vader support for rest of languages
  • [x] Use travis for CI
  • [x] Bug with changing the filename of the current file
  • [x] Make vim-repeat dependency optional
  • [x] Turn supported languages into a table - what do we support in which
    language
  • [x] Make vim-repeat dependency optional

添加新评论