Gvim

A friend introduced me to the excellent Vi editor. His constant talking about how great it is made me curious. I purchased Learning the Vi and Vim Editors – O’Reilly and learnt the basic commands.

Gvim is model editor it has two modes of operation for editing files 1) insert mode 2) qcommand mode. There might be other mode for using it but for beginners this two is enough.) Insert mode. Once you have started gvim by default you are in command mode. To enter from command mode to insert mode press character 'i' and you. Vim and gvim are the same, with one difference: gvim provides an 'interface' that doesn't run in a terminal window. Basically, gvim has menus and a toolbar like you have in most applications on Windows, Linux, etc. As far as functionality outside of the user interface, they're identical.

My boss prefers Windows: so all our servers are Windows.
I wanted to continue using Vim so started using gVim. gVim is a modified version of the UNIX Vi editor.

Gvim

Here are some things I’ve needed to configure while using gVim.

Maximising gVim Windows on file open

The default window size when opening a file in gVim is small.
To make gVim maximise windows on file open add the following to you _vimrc file.

Your _vimrc will be in the root folder of your Vim install, mine’s located in: C:Program FilesVim

Gvim64

The _vimrc file contains optional runtime configuration settings to initialize Vim when it starts.
On Unix based systems, the file is named .vimrc, on Windows systems it’s _vimrc.

Removing ^M characters in gVim

^M characters are DOS/Windows line-ending characters.
Previous developers at my work used Notepad++ to edit files. When I’d open these files in gVim they were littered with ^M characters and appear without line breaks or indents. Hard to read and edit.

To remove these use the ex command

I encountered a problem typing control characters in Windows.
In a UNIX environment you type a control character using CtrlV. In Windows CtrlV is used to ‘Paste’ so you must use CtrlQ instead.
To type ^M in gVim you type (CtrlQ) <– keep your finger on Ctrl then press M.

Good explanation of ^M characters copied from here The sims 3 outdoor living stuff key code.

There is a difference between how a Windows-based based OS and a Unix based OS store end-of-line markers.
Windows based operating systems – thanks to their DOS heritage – store an end-of-line as a pair of characters – 0x0A0D. Unix based operating systems just use 0x0A. ^M is a visual representation of 0x0D.

Changing the location of gVim swap and backup files

Gvim

When editing a file in gVim a backup file is created after saving changes to a newly opened file.
It is a copy of the file before changing the file. It is named the same as the file with a ~ at the end.
This creates a lot of clutter in your directories.
Thankfully you can change the default behaviour by disabling swap and backup files or moving the location of these.

Gvim On Macos 10.13

To disable swap and backup files add this to your _vimrc file

I like to keep these files as it saves the line location that I was last editing.

Gvim Editor Commands

To change the swap and backup file location add this to your _vimrc file

Comments are closed.