Lazy, so I need snippets!

How I run into snippets?  

In this post, I will tell you how to set up the snippets and also some solution to problems…

Each time when I writing the payload of PWN in CTF, I need to tap #!/usr/bin/env python; from pwn import *; in the top. As everyone knows, I am a very lazy man and also tired of trivial and repetive things XD. When I run into the snippets plugin vim, I just feel like I find my angel…

How to install the plugin?

  1. You need the plugin manager first. Personally, I use Vundle.
    Please read the documentation carefully and clone to the ~/.vim/.vimrc/bundle.
    If you not find the .vimrc directory under ~/.vim, you can mkdir by yourself.
    
  2. Second, we need to tell .vimrc the plugin we want to install. add lines between call vundle#begin() and call vundle#end():
    Plugin 'MarcWeber/vim-addon-mw-utils'
    Plugin 'tomtom/tlib_vim'
    Plugin 'garbas/vim-snipmate'
    Plugin 'honza/vim-snippets'   // vim default snippets
    
  3. Install them. Open the .vimrc and tap :PluginInstall Then you can see lines of plugin :
    + plugin ....
    > plugin ....
      plugin ....
      plugin ....  // You can see the signal at the left side, you just need to wait for seconds until it finish download
    

How to use?

Here is my example :

  1. Set up a snippets directory under ~/.vim
  2. Set up the snippets file with the name of **.snippets**
  3. Then follwing is the file content of python.snippets :
    snippet pwn
         #!/usr/bin/env python
         from pwn import *
    

    After save it. Vim to open a file, insert pwn and press the Tab key, then the content above will show on the screen <3

Conclusion

Are you also a lazy person? Come to enjoy it XD

Reference

Vim screencast #10: Snippets and autocomplete