How to redraw screen of Vim

I sometimes jump from inside Vim to use other shell tools and jump back in. On occasion, when I jump back to Vim like this I find that some elements of the Vim screen are blank.

The screen of Vim can be refreshed or redrawn by pressing Ctrl+l. If that does not work, use the command :redraw. If even that does not work, try :redraw!.

Tried with: Vim 7.4 and Ubuntu 14.04

About these ads

How to use Ranger as file explorer for Vim

Vim has an internal file explorer called NetRW. Another popular choice of file explorer for Vim is the NERDTree plugin. Recently, I started to use Ranger as my file explorer at the shell. I could open text files in it using Vim easily. However, what I really wished was to use Ranger from inside Vim as a file explorer.

Using Ranger inside Vim allows me to keep a Vim session with many files open and fall down to Ranger to explore and manipulate files and jump back into my Vim session. Another big advantage is that the files I open using Ranger all persist as buffers in the Vim session. That is, if I am working on File1, I jump to Ranger to find File2 and open it, then it should open back in the same Vim session, so that I now have File1 and File2 open. Thankfully, all of this is possible easily! :-)

To use Ranger as a file explorer for Vim, all you need to is add this code to your Vimrc. You can then launch Ranger whenever you want by pressing r, that is, usually it is \r.

Tried with: Ranger 1.6.1, Vim 7.4 and Ubuntu 14.04

nullptr in C++

In C++11 and later versions, we can now use a proper null pointer value. It is named as nullptr and is a C++ keyword. Unlike 0 or NULL which were an integer and a pointer to void respectively, nullptr is cleaner and brings in stronger type checking. nullptr can be assigned to any pointer variable.

I could not find the definition of nullptr, I guess it is defined inside the compiler itself. The closest I could find is nullptr_t, which is the type of nullptr. For GCC 4.9, I found that this is defined in /usr/include/x86_64-linux-gnu/c++/4.9/bits/c++config.h:

typedef decltype(nullptr) nullptr_t;

Tried with: GCC 4.9.1 and Ubuntu 14.04