Table of Contents
Applications - Text Editors - Vim - Notes
Permanently enable syntax highlighting
Add to ~/.vimrc:
:syntax enable
Set default highlighting to 'desert' in system config
Tested on Ubuntu.
echo :colorscheme desert >> /etc/vim/vimrc.local
Set default in system config to always show current filename
Tested on Ubuntu.
echo :set ls=2 >> /etc/vim/vimrc.local
SourceThe UNIX and Linux Forums - Continuously display the file name in vim
Convert file format from DOS to UNIX
To UNIX:
:set ff=unix
To DOS:
:set ff=dos
Source: stack overflow - Convert DOS line endings to Linux line endings in vim
Replace ^M line endings with UNIX line endings
Type:
:s/Ctrl+VCtrl+M/\r/g
The replace will then look like this:
:s/^M/\r/g
Source:Tech Recipes - Remove ^M characters at end of lines in vi
Replace curly double-quotes
To replace from the current line to the end (,$):
:,$s/[Ctrl+vu201cCtrl+vu201d]/"/g
Ctrl+vu201c means: hit Ctrl+V, enter u201c.
So that it looks like:
:,$s/[“”]/"/g
Source:stack overflow - In Vim how do I efficiently search and replace “ and ” with normal double quotes "
Sort
:sort
Sort case-insensitive:
:sort i
Source: Stack Exchange - How to sort case-insensitive?
Sort and keep unique values:
:sort u
Update ColdFusion syntax highlighting
The cf.vim with syntax highlighting supplied with Vim (on OpenBSD) does not highlight cfscript files.
To update, replace the highlighting with the cf-utils.vim from GitHub.
- Download the last version from GitHub - davejlong/cf-utils.vim via the “Download ZIP/TAR.GZ” button on the right.
- Unpack the archive.
- Copy the contents of the cf-utils.vim-<hash> directory to ~/.vim/:
mkdir ~/.vim/ && cp -R cf-utils.vim-15088cfad92f0e01d8d6c62e8804828f5adf8bd6/* ~/.vim/
- Start vim and open a .cfm file from ~/.vim/examples/ to test.
- The code should be highlighted in colors.
Disable mouse support
Tested on Debian 9 with VIM 8.0 with included patches: 1-197, 322, 377-378, 550.
Disable mouse support so you can copy and paste the way I'm used to by commenting the “if has ('mouse')” statement in /usr/share/vim/vim80/defaults.vim.
Unified diff patch to do this:
--- /usr/share/vim/vim80/defaults.vim.original 2017-04-23 14:10:29.000000000 +0200 +++ /usr/share/vim/vim80/defaults.vim 2017-07-25 09:57:42.009742204 +0200 @@ -66,9 +66,9 @@ " In many terminal emulators the mouse works just fine. By enabling it you " can position the cursor, Visually select and scroll with the mouse. -if has('mouse') - set mouse=a -endif +"if has('mouse') +" set mouse=a +"endif " Switch syntax highlighting on when the terminal has colors or when using the " GUI (which always has colors).
Source: Stack Exchange - Unix & Linux - vim cut&paste not working in Stretch / Debian 9
Or just do the following which is simpler and less invasive:
echo :set mouse= >> ~/.vimrc
Recording
Start recording:
q+LETTER
End recording:
q
To disable recording add the following to .vimrc:
map q <Nop>
Source:stackoverflow - What is Vim recording and how can it be disabled?