Vim tip: Open the last file you closed with :e#

I can’t believe I didn’t learn this earlier because now I do it all the time: If you close a file, as I often do with :bd, to open the last file you closed, type e# in command mode: :e# The last closed file opens in your current window. This is great for me because in my editing workflow, I have a story budget from one directory in one window, and I work on stories from a different directory in another.
Read more →

C++ in Vim with two lines in .vimrc

With inspiration and code from Ankit, I am using Vim to compile and run C++ programs without leaving the editor. I added these two lines to my .vimrc: nnoremap <F7> :!g++ -o %:r %<Enter> nnoremap <F8> :!./%:r<Enter> I hit F7 to compile the program I’m working on. F8 runs that program. This is much simpler than an IDE, and simpler still than Geany, which is pretty simple already. These lines could be modified to compile and run a Java program, or to just run your code in scripting languages like Ruby, Perl and Python.
Read more →