[Howto] Use Powerline on Fedora

920839987_135ba34fffPowerline is a status line plugin for Vim, but also a prompt plugin for Bash, ZSH and others. It can easily be installed in Fedora via provided packages.

The status line plugin Powerline is available via the Fedora repositories. There has just been an update which is already available in the testing repository:

$ sudo yum install --enablerepo=updates-testing powerline

The powerline documentation is rather good and explains all steps necessary to configure all the various Powerline plugins. However, note that the string {repository_root} in the examples have to be replaced by /usr/lib/python2.7/site-packages/, so for example {repository_root}/powerline/bindings/vim becomes /usr/lib/python2.7/site-packages/powerline/bindings/vim/. This is due to the fact that the Powerline rpm installs the Powerline code into this specific directory.

So to use Powerline in Vim, just add the following line to the top of your ~/.vimrc:

set rtp+=/usr/lib/python2.7/site-packages/powerline/bindings/vim/

If your previously used other Vim plugins also altering the status line, make sure that you deactivate these.

To use Powerline in Zsh, simply add the following lines to your ~/.zshrc:

# Powerline
if [[ -r /usr/share/powerline/zsh/powerline.zsh ]]; then
  source /usr/share/powerline/zsh/powerline.zsh
fi

In case you use Zsh and want to get rid of the EMACS at the beginning, you need to create a configuration path for Powerline, copy the necessary Shell theme files and alter them accordingly:

$ mkdir -p ~/.config/powerline/themes/shell
$ cp -a /usr/lib/python2.7/site-packages/powerline/config_files/themes/shell/* ~/.config/powerline/themes/shell/

Open the file default.json and remove the lines:

      {
        "function": "powerline.segments.shell.mode"
      },

You might have to restart the powerline-daemon, powerline-daemon -r but afterwards the shell line in Zsh does not contain the current mode anymore. Have fun!

PS: In case you use Ubuntu, an almost perfect Howto can be found at AskUbuntu: How can I install and use powerline plugin?.

Short Tip: Write buffers and jump to next in Vim

920839987_135ba34fffUsually I wrote and close file in vim with “:wq”, write and quit vim. However, when I edit a bunch of files at the same time, like with “vim *txt”, I do not want to close vim but just one file and jump to the next. And most often I have forgotten how to do that, so this post is kind of a self reminder.

For handling multiple files you need to know that vim refers to files loaded into memory for editing is called “buffer”, and that these buffers are tracked in a list. So, whenever you edit a bunch of files and finished a file, you need to close the buffer, and delete it from the buffer list:

:bd

If you want to write the buffer and jump to the next file, there are two ways to approach this: either by deleting the buffer from the buffer list, or by just jumping to the next file without deleting it

:w|bd
:wn

Both commands write the current buffer and jump to the next file. The first one closes the buffer, however.

You can always check the buffer list with “:ls” – and jump forth and back between the buffers with “:n” and “:N”.