Posts Tagged ‘vi’

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 […]