Posts

Showing posts with the label vim

Vim Search for Tags File

I use ctags with vim. This works great when the tags file is in the same directory as the files I'm working on, but is a chore when projects have nested directories. Add this to your .vimrc file and the recursive search up the directory structure will be done for the tags file: set tags=tags;/

Vim: Replace tabs with spaces

When working in other peoples code I almost always notice mixed tabs and spaces. Like many programmers, this makes my skin crawl since it usually causes formatting to look horrible or incomprehensible. First I'll double check that there are mixed tabs and spaces by highlighting the tabs. /\t If I see some whitespace highlighted and some not highlighted I'll look at the indentation and figure out how many spaces each tab should be, then do a replace. This will perform a replace on the entire file ( %s ) for all tabs ( \t ) into four spaces ( \ \ \ \ ), the g at the end will allow the match to be done multiple times per line: :%s/\t/\ \ \ \ /g If your tab expand matches the file, you can also use the vim built-in retab: :%retab

Vim Window Size

I have a couple entries in my vimrc configuration that I need: map - <C-W>- map = <C-W>+ When you have multiple windows open you can change their size with "Control-w" and '+' or '-' (note that you need to be holding SHIFT to get a '+' sign). This will change the window size one line at a time. If your extremely suave and can count line numbers in your head you can prepend the number of lines you would like to move and the keyboard shortcut isn't all that bad. I can't count the lines in my head, so I use the above macro. Since I work with multiple windows constantly I have the increase and decrease size bound to '-' and '=', I use equal so that I don't have to press SHIFT for one but not the other.