4,461
edits
mNo edit summary |
|||
Line 25: | Line 25: | ||
== beautify json == | == beautify json == | ||
< | <syntaxhighlight lang="vim"> | ||
:%!python -m json.tool | :%!python -m json.tool | ||
</ | </syntaxhighlight> | ||
Line 34: | Line 34: | ||
In ~/.vimrc file, add as follows. Macro content can be retrieved by pressing <code>"xp</code> where x is the bound key. | In ~/.vimrc file, add as follows. Macro content can be retrieved by pressing <code>"xp</code> where x is the bound key. | ||
< | <syntaxhighlight lang="vim"> | ||
let @q = 'macro contents' | let @q = 'macro contents' | ||
</ | </syntaxhighlight> | ||
Line 64: | Line 64: | ||
1) Join all the lines | 1) Join all the lines | ||
< | <syntaxhighlight lang="vim"> | ||
(highlight lines) gJ | (highlight lines) gJ | ||
</ | </syntaxhighlight> | ||
2) Break tags to new lines | 2) Break tags to new lines | ||
< | <syntaxhighlight lang="vim"> | ||
(highlight lines) :s/>\s*</>\r</g | (highlight lines) :s/>\s*</>\r</g | ||
</ | </syntaxhighlight> | ||
3) Set filetype | 3) Set filetype | ||
< | <syntaxhighlight lang="vim"> | ||
:set ft=html | :set ft=html | ||
</ | </syntaxhighlight> | ||
4) Indent | 4) Indent | ||
< | <syntaxhighlight lang="vim"> | ||
(highlight lines) = | (highlight lines) = | ||
</ | </syntaxhighlight> | ||
== Remove all HTML tags == | == Remove all HTML tags == | ||
Line 99: | Line 99: | ||
With the introduction of internal package management system, there is no longer a logical need to install a third-party package management tool. Here's a refresh of my .vimrc as of mid-2018 with VIM v8. | With the introduction of internal package management system, there is no longer a logical need to install a third-party package management tool. Here's a refresh of my .vimrc as of mid-2018 with VIM v8. | ||
< | <syntaxhighlight lang="vim"> | ||
if &compatible | if &compatible | ||
set nocompatible | set nocompatible | ||
Line 115: | Line 115: | ||
syntax on | syntax on | ||
</ | </syntaxhighlight> | ||
= Initial setup (deprecated) = | = Initial setup (deprecated) = | ||
Line 122: | Line 122: | ||
Here is my entire ~/.vimrc file. | Here is my entire ~/.vimrc file. | ||
< | <syntaxhighlight lang="vim" enclose="div"> | ||
set nocompatible | set nocompatible | ||
set noexpandtab | set noexpandtab | ||
Line 188: | Line 188: | ||
autocmd FileType php setlocal omnifunc=phpcomplete_extended#CompletePHP | autocmd FileType php setlocal omnifunc=phpcomplete_extended#CompletePHP | ||
</ | </syntaxhighlight> | ||
<code>set nocompatible</code> - forget about making Vim behave like Vi. | <code>set nocompatible</code> - forget about making Vim behave like Vi. | ||
Line 309: | Line 309: | ||
== Setting GUI font in .vimrc == | == Setting GUI font in .vimrc == | ||
< | <syntaxhighlight lang="vim"> | ||
if has("gui_running") | if has("gui_running") | ||
if has("gui_gtk2") | if has("gui_gtk2") | ||
Line 319: | Line 319: | ||
endif | endif | ||
endif | endif | ||
</ | </syntaxhighlight> | ||
== Installing vim-plug == | == Installing vim-plug == | ||
Line 325: | Line 325: | ||
{{testedon|2019-12-06|Windows 10 v1903 (build#18362.449),VIM 8.1.1657}} | {{testedon|2019-12-06|Windows 10 v1903 (build#18362.449),VIM 8.1.1657}} | ||
< | <syntaxhighlight lang="doscon"> | ||
PS C:\> $uri = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' | PS C:\> $uri = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' | ||
(New-Object Net.WebClient).DownloadFile( | (New-Object Net.WebClient).DownloadFile( | ||
Line 333: | Line 333: | ||
) | ) | ||
) | ) | ||
</ | </syntaxhighlight> | ||
== Ultisnips requires py >= 2.7 or py3 == | == Ultisnips requires py >= 2.7 or py3 == | ||
Line 341: | Line 341: | ||
This may not be the best method, so it's more of a workaround. Install Python3 (e.g. via Chocolatey) and make a copy of pythonXX.dll under the python folder (e.g. \Python38) to the version that vim is looking for. For example, if Python 3.8 was installed, but vim is compiled with Python 3.7, then you would make a copy as follows: | This may not be the best method, so it's more of a workaround. Install Python3 (e.g. via Chocolatey) and make a copy of pythonXX.dll under the python folder (e.g. \Python38) to the version that vim is looking for. For example, if Python 3.8 was installed, but vim is compiled with Python 3.7, then you would make a copy as follows: | ||
< | <syntaxhighlight lang="doscon"> | ||
C:\Python38> copy python38.dll python37.dll | C:\Python38> copy python38.dll python37.dll | ||
</ | </syntaxhighlight> | ||
= Plug-ins = | = Plug-ins = | ||
Line 401: | Line 401: | ||
{{testedon|2013-08-10|VIM 7.4}} | {{testedon|2013-08-10|VIM 7.4}} | ||
< | <syntaxhighlight lang="vim"> | ||
:ve | :ve | ||
</ | </syntaxhighlight> | ||
== Reload .vimrc without quitting == | == Reload .vimrc without quitting == | ||
{{testedon|2013-08-10|VIM 7.4}} | {{testedon|2013-08-10|VIM 7.4}} | ||
< | <syntaxhighlight lang="vim"> | ||
:so ~/.vimrc | :so ~/.vimrc | ||
</ | </syntaxhighlight> | ||
== Fixing an issue with Python version when using VIM with some packages == | == Fixing an issue with Python version when using VIM with some packages == |