Archive for the ‘Vim’ Category

To highlight any results found when searching in Vim, you can use :set hlsearch. To turn off the highlighting, use :nohlsearch. If search highlighting is something you always want turned on, you can add set hlsearch (no colon) to your .vimrc file. If, like me, you like to turn off the search highlighting after you’ve […]

Disabling auto indent in Vim

Posted: 12th October 2014 by Tim in Vim
Tags: , , , , , , ,

Auto indent is disabled by default in Vim, but some systems have this feature enabled in the system-wide vimrc file (found in /usr/share/vim/vimrc or a similar location). There are two ways to disable this: remove the system-wide setting, or remove the setting for your user only. To remove the setting system-wide, search for and remove […]

Editing a file in hex mode in Vim

Posted: 27th July 2013 by Tim in Linux, Vim
Tags: , , , , , ,

Native Vim doesn’t have a hex editing mode built in, however it is possible to edit a file in hex by converting the file back and forth using xxd. To do this, open your file in Vim and run :%!xxd. From here you can change the hex values and, when you’re done, run :%!xxd -r […]

Show line numbers in vi or vim

Posted: 7th January 2013 by Tim in Linux, Vim
Tags: , , , , , , ,

If you want line numbers to show up in vi or vim, this can be done by typing the following command from within the program: :set number or, in shorter form: :set nu Doing this from within vi[m] will show the numbers for that session, but they will be gone next time you start up […]

Vim, by default, will insert a tab character when you press the <tab> key. Some people prefer to use spaces instead, and the number of spaces preferred varies from person to person. To use spaces instead of tabs, you need to set tabstop, shiftwidth and expandtab in your .vimrc file. If, for example, you wanted […]

Highlighting tabs in Vim

Posted: 26th April 2012 by Tim in Vim
Tags: , , , , , , , ,

Some people like to indent code with tabs, and others like to indent with spaces. There are advantages and disadvantages to both. Regardless of which you prefer, it can be useful to see which indent style has been used. In Vim, you can do this by adding the following line to you .vimrc file (which […]

Let’s say you have a file type whose contents are in XML format but have a different file extension such as .tim . If you want to edit these files with Vim with syntax highlighting, simply add the following to ~/.vimrc (affects only your Vim environment) or /etc/vim/vimrc (affects everyone’s Vim environment): au BufNewFile,BufRead *.tim […]

Doxygen highlighting is set up by default on most Vim installations, but for some reason it’s disabled. There are two options for enabling it. First, it can be enabled globally. This means adding the parameters to the global Vim configuration. Note that you may need to be root for this to work (ie: sudo echo […]