Getting back on track

Posted on Sun 14 December 2014 in General • Tagged with linuxLeave a comment

By now it's pretty obvious that I fell off of the NoVIMber wagon. I haven't made any posts recently because I've been discouraged that NoVIMber was a bit of a flop. It wasn't a total failure though! I learned several awesome things about Vim! Reflecting on NoVIMber 2014, there was one major reason that caused me to quit halfway through: Scope creep

My original intention was to write short posts about a single command (or series of commands) each day. This would be a manageable time investment and relatively easy to commit to memory. Instead the posts turned rather monolithic and became difficult to remember in a single day. It's silly to make a blog post about such things when you're not actively adding it to your repertoire. I think these were valuable lessons for all of my future projects. There's a fine line between healthy ambition and overambition.

So what am I going to do now? I've decided that it's time to get back on track with my development outside of work. I've had a subscription to Safari Books for a long time but I use it pretty sparingly - which is a shame since the service is great. When I first subscribed, I'd try to dedicate an hour each day (after work) to reading. It actually worked out really well for a while. Unfortunately, I let life get in the way and fell off of the wagon. I'm going to try something similar again. This time I'm going to guarantee at least 30 minutes per day with 60 minutes being the goal. Once I finish a book (or give up on a book if it's truly awful), I plan on summarizing my thoughts in a blog post here - a kind of informal review.

That brings me to the first book on my list: How Linux Works: What Every Superuser Should Know (2nd Edition) by Brian Ward. I started this book toward the end of November, shortly after its release, and I've enjoyed it thus far. I have a feeling a good portion of it will be review however a quick look at the table of contents leads me to believe that there will be some pretty cool information later. I'll post a full summary/review once I've completed the book.

That's all for now! Happy Holidays!

NoVIMber 14, 2014 - Some simple but useful commands

Posted on Sat 15 November 2014 in Vim • Tagged with linux, vim, NoVIMber 2014Leave a comment

I didn't get the opportunity to catch up on posts today. I'm thinking that researching a topic and writing a post every single day was a bit too ambitious. To give myself some additional project time and avoid burn-out, I'm going to cut it back to 3-4 posts per week (probably during the work week). Today's post is going to be something simple and short.

Read Commands

:read FILE  Insert the contents of FILE below cursor in current file
:read !CMD  Execute CMD and insert its output below cursor in current file

If I had known about these read commands earlier, it would've saved me so much time. For the first, if no filename is specified, it defaults to your current file (in its "saved" form). For the second, it's important to note that CMD is a shell command, not a Vim command. Notice the ! filter command that I mentioned in NoVimber 06, 2014's post.

Replacing & Changing Text

r CHAR  Replace character under cursor with CHAR
R       Enter "replace" mode

I already knew about the replace command. It's easy enough to use and I use it very reguarly. As for replace mode, I've frequently found myself getting into replace mode by accident. Long story short, replace mode is basically insert mode that replaces text instead of shifting existing text to insert new text.

~  Changes the case of character(s) under cursor

I've been meaning to commit this one to memory for a while. This also works for highlighted/selected text in visual mode. I'll cover visual mode in more depth in a later post. A quick explanation - you can enter visual mode with v, select some text with the movement keys (h,j,k,l or arrow keys), then press ~ to change the case of all selected text.


That's it for today. Like I said, simple and short! I'd still like to cover tabs in Vim but I haven't had a lot of time to actually learn about them myself. That's a task for next week. Until then, Happy Viming!

Site has moved!

Posted on Fri 14 November 2014 in General • Tagged with django, linuxLeave a comment

I had mentioned in my first or second post that this site was being hosted on a temporary server due to my current web server not supporting Django 1.7 (centos 6 with python 2.6). I've finally started rebuilding my primary web server. The first site to move over was this one! If you happen to notice any issues, please contact me via email (nathan at or twitter (@nbchowning).

NoVIMber 11, 2014 - Buffers round 2

Posted on Wed 12 November 2014 in Vim • Tagged with NoVIMber 2014, linux, vimLeave a comment

Before we get into Vim's tabs, I'd like to cover a couple more things that you can do to manipulate buffers in Vim.

Adding & Deleting Buffers

In my previous buffer post, I talked about creating new buffers with the :e command. That will create a new buffer, load its contents, and attach it to your current window. Let's say that you want to create a new buffer but you don't want to load the corresponding file's contents into memory and attach it to your current window:

:badd filename    Add a new buffer for filename to the buffer list without loading its contents
:badd N filename  Same as :bad filename except positions cursor on line number N

I failed to cover the deletion of buffers in my previous post. There are a few different ways to "delete" buffers. You can unload the buffer (freeing the memory it was consuming), you can make the buffer "unlisted", or you can completely delete the buffer. In the following examples, BUFF can represent a unique buffer number or buffer name.

:bunload BUFF   Unloads buffer BUFF freeing the memory it previously consumed. It will remain in the buffer list
:bdelete BUFF   Delete (make unlisted) buffer BUFF
:bwipeout BUFF  Same as :bd BUFF except actually deletes buffer instead of unlisting

It's important to note that "unlisted" buffers will not be displayed in :ls or :buffers by default. You can display listed and unlisted buffers by adding ! to either command (:ls!).

Additional Buffer Movement Commands

We've already covered displaying a specific buffer with :b N and flipping through the buffers sequentially with :bn and :bp. There are a few additional methods to navigate buffers.

:brewind  Go to the first buffer in your buffer list
:bfirst   Same as :br
:blast    Go to the last buffer in your bufferlist

With pretty much all of these buffer commands, you can add "s" to the beginning (:sbn) to split your current window and load the resulting buffer into a new window. In the example case of :sbn, it would split your current window (horizontally) and attach your "next" buffer to the new window. To accomplish this with a vertical split, you would do something like :vert sbn.


That's all for today. I'd like to mention that I forgot to add "Reference Material" links to yesterday's post. This oversight has been corrected! Happy Viming!

Reference Material

Vim Wiki: Buffer FAQ

Vim documentation: windows - buffer-list

NoVIMber 10, 2014 - Continuing with Windows

Posted on Tue 11 November 2014 in Vim • Tagged with NoVIMber 2014, linux, vimLeave a comment

Today we'll be picking up where we left off with windows in Vim. We're going to cover a couple more of the basic aspects: Moving windows around and resizing windows.

Moving Windows

There are a couple of ways to move windows around in Vim. The first one is "rotation" based. These rotation based movements will only work in the current row or column that the window exists in. It should also be noted that your cursor will remain in the same window when rotated.

CTRL-W r  Rotate windows right (row) or down (column)
CTRL-W R  Rotate windows left (row) or up (column)

You can also swap the current window with the "next" window. The next window would be the window to the right (row) or below (column) depending on your current layout. This command will move the cursor to the new window as well (which will be move to replace the previous window).

CTRL-W x  Swap current window with next window

When you're moving windows around, it's sometimes useful to change your current layout. Notice that the following movements correspond to the usual "h", "j", "k", "l" movement keys except they are capitalized. Also keep in mind that following commands will use the full height of your screen when moving left/right or the full width when moving up/down.

CTRL-W H  Make the current window the far-left window
CTRL-W J  Make the current window the bottom-most window
CTRL-W K  Make the current window the top-most window
CTRL-W L  Make the current window the far-right window

Resizing Windows

The basic operations for resizing windows in Vim are probably what you'd expect: you grow/shrink the current windows's height/width. As with most things in Vim, there is a bit more to it than that. To start off, let's look at making all of the windows consume an "equal" (or close to equal) height/width on your screen. This command can be a bit more complicated by the "winheight", "winwidth", "winfixheight", and "winfixwidth" settings. I'll touch on those in a later post. For now, let's just assume that none of those values have been set.

CTRL-W =  Make all windows equal in height & width

Now let's look at increasing/decreasing height/width of a window. Keep in mind that, as with pretty much every Vim command, you can preface these commands with a "count" to perform the action more than once. This can be particularly useful when resizing windows since adding/decreasing a single row/column at a time (the default if a count is not specified) is quite tedious.

:resize -N           Decreases window height by N rows
CTRL-W -             Same as :res -N

:resize +N           Increases window height by N rows
CTRL-W +             Same as :res +N

:vertical resize -N  Decrease window width by N columns
CTRL-W <             Same as :vertical res -N

:vertical resize +N  Increase window width by N columns
CTRL-W >             Same as :vertical res +N

Sometimes it's also useful to specify an explicit height/width of a window. We can do that too and as you'd imagine, the commands are strikingly similar to growing/shrinking a window. If a value is not given to these commands, they will default to "as big as possible" in which ever direction you're resizing.

:resize N           Set the height of the current window to N
CTRL-W _            Same as :res N
zN<CR>              Useful shortcut to get similar behavior to :res N. See note below

:vertical resize N  Set the width of the current window to N
CTRL-W |            Same as :vertical res N

zN does not share the same "default" behavior (if N is not provided) as :res. In my experience, z seems to have the same effect as zt (moving the current line to the top of the buffer).

That about covers it for today's post. At this point you should be able to move your windows around and resize them to fit your workflow more adequately. There are still other tricks that you can do to manipulate window sizes differently but that's a topic for yet another post! Happy Viming!

Reference Material

Vim documentation: windows - window-moving

Vim documentation: windows - window-resize