Tag Archives: coding

Window stacking in VIM

Stolen shamelessly from this site.

map <c -J> </c><c -W>j</c><c -W>_
map </c><c -K> </c><c -W>k</c><c -W>_
set wmh=0
</c>

The first two lines allow you to switch between splits much more smoothly — just press to open and maximize the split below the current one and to open and maximize the split above the current one. I chose these mappings because they correspond to vi’s default up and down keys, you might want to use different key combinations if you’ve ever used an editor that had hotkeys for moving from one open file to another.

The last line allows splits to reduce their size to a single line (which includes the filename and position); this saves a lot of space when you have many splits open. By default, vim forces splits to include an additional line that contains the line of text the cursor was on in that file.

This gives you some sort of stacking functionality like in wmii

C specifier meanings

%c  – Print a character
%d  – Print a Integer
%i  – Print a Integer
%e  – Print float value in exponential form.
%f  – Print float value
%g  – Print using %e or %f whichever is smaller
%o  – Print actual value
%s  – Print a string
%x  – Print a hexadecimal integer (Unsigned) using lower case a – F
%X  – Print a hexadecimal integer (Unsigned) using upper case A – F
%a  – Print a unsigned integer.
%p  – Print a pointer value
%hx – hex short
%lo – octal long
%ld – long 

c Makefile

Note that you have to set TARGET with your executable name, and list the .c files to compile in SRCS. Also, note that Makefile indents must be tabs, not spaces.

    TARGET  := <<your executable name>> 
    SRCS    := <<one ore more of your .c files>> 
    OBJS    := ${SRCS:.c=.o} 
    DEPS    := ${SRCS:.c=.dep} 
    XDEPS   := $(wildcard ${DEPS}) 
 
    CCFLAGS = -std=gnu99 -O2 -Wall -Werror -ggdb 
    LDFLAGS = 
    LIBS    = 
 
    .PHONY: all clean distclean 
    all:: ${TARGET} 
 
    ifneq (${XDEPS},) 
    include ${XDEPS} 
    endif 
 
    ${TARGET}: ${OBJS} 
        ${CC} ${LDFLAGS} -o $@ $^ ${LIBS} 
 
    ${OBJS}: %.o: %.c %.dep 
        ${CC} ${CCFLAGS} -o $@ -c $< 
 
    ${DEPS}: %.dep: %.c Makefile 
        ${CC} ${CCFLAGS} -MM $< > $@ 
 
    clean:: 
       -rm -f *~ *.o ${TARGET} 
 
    distclean:: clean