vis: a simpler vim

vis

vim has been around for years and accumulated a lot of legacy code. Projects like neovim have emerged to remove the clutter and extend vim with a modern approach. vis is a similar attempt written from the scratch to provide a vim-like experience without legacy baggage. It is under active development at the time of writing. Continue reading vis: a simpler vim

vim as an encrypted cloud note manager

vim_compvim is one of the most popular editors on Linux. You can edit multiple notes in vim simultaneously. However, it is not a generic note manager by design. You can turn it into one using the vim-notes plugin, which also means you need to remember more commands. We already explored how to encrypt files with vim. Let’s try a simple way to turn vim into a note manager. I use it everyday for my notes. Continue reading vim as an encrypted cloud note manager

vim: list all matching lines

vim_compOne of the coolest features of Notepad++ is you can find all matches (occurrences) of a pattern in a file in a list. Here are some ways to do the same in vim, sans any external plugin.

1. vimgrep (Error List)

This is a command to be used in the vim command mode. The syntax is:

:vimgrep pattern %

To open the list of matches in a buffer:

:copen

Use <Up> and <Down> keys to navigate the list, <Enter> to select a match. Traverse the matches in the open file using <n> and <N> the regular way.

Note that you can replace vimgrep with normal grep. This will increase one step (lists on the console first) but works almost the same way.

2. lvim (Location List)

Run the following in the command mode:

:lvim pattern %

To open the list

:lopen

Navigation is similar to that in vimgrep.

3. global search

To get the list of all matches in the file, run the following in command mode:

:g/regular-expression/p

Note that grep got its name from this command sequence!

yavide: modern C C++ IDE over vim

vim has numerous plugins for developers and when combined together it becomes far more powerful than any IDE out there. The additional advantage is the resource consumption, it’s minimal when compared to Eclipse or NetBeans and the likes of those. This also makes a vim based IDE ideal for remote programming. yavide is a new project that takes these vim plugins seriously and tries to package everything together. It also aims to provide some features not available in any other IDE. In its current status (at the time of writing), yavide looks like the next step from spf13-vim. yavide is still in the development phase and yet to see its first release at the time of writing. However, the author is working on missing and requested features.

Features

  • Bundled and tweaked for C/C++ (support for Python & Java planned)
  • Project management & Project explorer
  • Class browser with overview of symbols defined in current unit (i.e. macro, struct, class, method, namespace, etc.)
  • Source code auto-completion (real C/C++ compiler back-end for correctness)
  • Source code navigation (fully automated background tag generation system to ensure the best UI experience)
  • Source code static analysis
  • Source code management client integration (git integrated)
  • Build tools (make integrated)
  • Custom keybinds for various operations
  • Miscellaneous:
    > syntax highlighting
    > highlight all occurrences
    > parenthesis auto-complete
    > context-aware ordinary text auto-complete
    > multiple-selection editing support
    > code snippets
    > grep support
    > bash shell integration
    > color schemes support

Plugins

The following vim plugins are integrated into yavide at the time of writing:

  • A
  • Clang_complete
  • NERDTree
  • NERDCommenter
  • SuperTab
  • Tagbar
  • vim-airline
  • UltiSnips
  • vim-autoclose
  • vim-fugitive
  • vim-gitgutter
  • vim-multiple-cursors
  • vim-pathogen

Installation

To install yavide dependencies on Ubuntu, run:

$ sudo apt-get install build-essential vim-gnome python2.7 git libclang-dev python-dev

Run the following commands to clone the git repository of yavide and install it:

$ cd ~/ && git clone https://github.com/JBakamovic/yavide.git
$ cd yavide && ./install.sh

Replace  with the location where you want to install yavide. The deault is /opt. yavide will create its own directory and install the files within it.

On GitHub: yavide

spf13-vim: custom vim for devs

Are you a vim fan who loves customization tips or plugins to make it more power-packed? spf13-vim is a custom vim distribution that might exactly be the thing you are looking for.

Features

  • Custom configuration for ~/.vimrc and suited to programming. Well organized into sections with labels and comments.
  • Centralized swap and backup files.
  • Fixes common typos like :W, :Q etc.
  • Setup the interface to make use to vim’ power features.
  • Configured plugins like Vundle, NERDtree, Surround, Syntastic, Tagbar, Easymotion and more…
  • Provision to add your own bundles or custom settings
  • Additional syntaxes like Markdown, Twig, Git commits
  • Colour themes included
  • Snippets for use with snipmate
  • Support through mailing list and discussion group
  • Same customization for Linux, Windows and Mac

Installation

If you think all that is purely awesome, install spf13-vim on Linux with the following command:

$ curl http://j.mp/spf13-vim3 -L -o - | sh

Don’t worry! It will backup your existing configuration.

Webpage: spf13-vim

Similar software

Encrypt files with vim

vim_compWhat if you want to hide the contents of a file from the root user? Encryption is the answer. If it is a plaintext file, you do not need any additional software to encrypt it, vim has the ability to encrypt files using several algorithms. Currently vim supports 3 encryption methods:

zip: weak [default method for backward compatibility]
blowfish: better
blowfish2: best [supported from v7.4.399]

To use an encryption method other than zip (which is the default) set it explicitly in vim command mode:

:setlocal cm=blowfish

You can encrypt a file in 2 ways:

  • Open the file in vim and before quitting press :X in command mode. Note that after setting the password (or key) you must apply it using :w before you quit.
  • Add password to the file using
    $ vim +X myfile

Encryption is a one time operation. You can update the file as many times as you want without changing the password. To reset a password, use any of the two methods above and just press Enter when prompted for new password. You can also empty the key from vim command mode:

:set key=

vim will ask for the password every time you open the encrypted file. You will not be able to view the original contents of the file using any other external editor either. If you enter the wrong password while opening the file in vim, you will see gibberish content. In the latest versions of vim (mine is 7.4.52) saving the file in this state does not corrupt the original content. While editing, the text in the swap file, undo file, and backup files are also encrypted; however, the text in memory is not encrypted.

Scratch.vim: quick text buffer window

The intent of a vim scratch buffer is to provide a temporary area to store or edit text which gets discarded when you exit vim. The buffer will be retained as long as the vim session is on. Even if you are a heavy user of vim copy paste registers, the scratch buffer comes in handy to deal with reminders or code snippets you want to refer to later. There was a old plugin that does this. However, it’s not being maintained for 4 years (at the time of writing).

scratch.vim is a new vim plugin inspired by the original project and adds some nice features:

  • Auto-hide on inactivity.
  • Mappings for note taking and selection pasting directly into the scratch buffer.

Usage in vim

  • :Scratch opens the scratch buffer window using top 20% of the screen (configurable via g:scratch_height and g:scratch_top). The window automatically closes when inactive. The contents will be available the next time it is opened during the same session.
  • gs in normal mode opens the scratch window and enters insert mode. The scratch window closes when you leave insert mode. This is especially useful for quick notes.
  • gs in visual mode pastes the current selection (character-wise, line-wise or block-wise) into the scratch buffer.
  • gS in normal/visual mode clears the scratch buffer before opening it.
  • :help Scratch shows detailed list of configuration options.

Auto-closing features require hidden to be set (and can be disabled via the g:scratch_autohide option).

Installation

Install pathogen.vim (required)

$ mkdir -p ~/.vim/autoload ~/.vim/bundle && \
$ curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim

Install scratch.vim

$ cd ~/.vim/bundle
$ git clone https://github.com/mtth/scratch.vim

Webpage: scratch.vim