234 bytes added ,  4 October 2023
m
no edit summary
mNo edit summary
Line 25: Line 25:
== beautify json ==
== beautify json ==


<source lang="vim">
<syntaxhighlight lang="vim">
:%!python -m json.tool
:%!python -m json.tool
</source>
</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.


<source lang="vim">
<syntaxhighlight lang="vim">
let @q = 'macro contents'
let @q = 'macro contents'
</source>
</syntaxhighlight>




Line 64: Line 64:
1) Join all the lines
1) Join all the lines


<source lang="vim">
<syntaxhighlight lang="vim">
(highlight lines) gJ
(highlight lines) gJ
</source>
</syntaxhighlight>




2) Break tags to new lines
2) Break tags to new lines


<source lang="vim">
<syntaxhighlight lang="vim">
(highlight lines) :s/>\s*</>\r</g
(highlight lines) :s/>\s*</>\r</g
</source>
</syntaxhighlight>




3) Set filetype
3) Set filetype


<source lang="vim">
<syntaxhighlight lang="vim">
:set ft=html
:set ft=html
</source>
</syntaxhighlight>




4) Indent
4) Indent


<source lang="vim">
<syntaxhighlight lang="vim">
(highlight lines) =
(highlight lines) =
</source>
</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.


<source lang="vim">
<syntaxhighlight lang="vim">
if &compatible
if &compatible
   set nocompatible
   set nocompatible
Line 115: Line 115:


syntax on  
syntax on  
</source>
</syntaxhighlight>


= Initial setup (deprecated) =
= Initial setup (deprecated) =
Line 122: Line 122:


Here is my entire ~/.vimrc file.
Here is my entire ~/.vimrc file.
<source lang="vim" enclose="div">
<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
</source>
</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 ==


<source lang="vim">
<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
</source>
</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}}


<source lang="doscon">
<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:
   )
   )
)
)
</source>
</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:


<source lang="doscon">
<syntaxhighlight lang="doscon">
C:\Python38> copy python38.dll python37.dll
C:\Python38> copy python38.dll python37.dll
</source>
</syntaxhighlight>


= Plug-ins =
= Plug-ins =
Line 401: Line 401:
{{testedon|2013-08-10|VIM 7.4}}
{{testedon|2013-08-10|VIM 7.4}}


<source lang="vim">
<syntaxhighlight lang="vim">
:ve
:ve
</source>
</syntaxhighlight>


== Reload .vimrc without quitting ==
== Reload .vimrc without quitting ==
{{testedon|2013-08-10|VIM 7.4}}
{{testedon|2013-08-10|VIM 7.4}}


<source lang="vim">
<syntaxhighlight lang="vim">
:so ~/.vimrc
:so ~/.vimrc
</source>
</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 ==