Vim Tips Wiki
m (Enhancing Benji Fisher's word complete.vim script moved to Enhance the word complete.vim script: Page moved by JohnBot to improve title)
(Standard category names + minor manual clean.)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{review}}
 
{{review}}
  +
{{TipImported
{{Tip
 
 
|id=526
 
|id=526
  +
|previous=525
|title=enhancing Benji Fisher's word_complete.vim script
 
  +
|next=527
|created=August 9, 2003 0:29
+
|created=2003
 
|complexity=intermediate
 
|complexity=intermediate
 
|author=Adrian von Bidder
 
|author=Adrian von Bidder
|version=5.7
+
|version=6.0
 
|rating=-1/1
 
|rating=-1/1
  +
|category1=Automated Text Insertion
|text=
 
  +
|category2=Plugin
 
}}
 
I suggest you first look at the script itself: {{script|id=73}}
 
I suggest you first look at the script itself: {{script|id=73}}
   
 
Since the script has some problems (at least for me) when I paste text in X11 with the mouse, and since I need to switch to paste more anyway, I now use this in my vimrc:
 
Since the script has some problems (at least for me) when I paste text in X11 with the mouse, and since I need to switch to paste more anyway, I now use this in my .vimrc:
 
   
 
<pre>
 
<pre>
" the word_complete.vim plugin just *rocks*
+
" the word_complete.vim plugin just *rocks*
autocmd VimEnter * call DoWordComplete()
+
autocmd VimEnter * call DoWordComplete()
   
fun! SetComplete()
+
fun! SetComplete()
call DoWordComplete()
+
call DoWordComplete()
set nopaste
+
set nopaste
nunmap &lt;F12&gt;
+
nunmap <F12>
iunmap &lt;F12&gt;
+
iunmap <F12>
nmap &lt;F12&gt; :call UnsetComplete()&lt;CR&gt;
+
nmap <F12> :call UnsetComplete()<CR>
imap &lt;F12&gt; &lt;Esc&gt;:call UnsetComplete()&lt;CR&gt;a
+
imap <F12> <Esc>:call UnsetComplete()<CR>a
  +
echo
echo
 
endfun
+
endfun
   
fun! UnsetComplete()
+
fun! UnsetComplete()
call EndWordComplete()
+
call EndWordComplete()
set paste
+
set paste
nunmap &lt;F12&gt;
+
nunmap <F12>
iunmap &lt;F12&gt;
+
iunmap <F12>
nmap &lt;F12&gt; :call SetComplete()&lt;CR&gt;
+
nmap <F12> :call SetComplete()<CR>
imap &lt;F12&gt; &lt;Esc&gt;:call SetComplete()&lt;CR&gt;a
+
imap <F12> <Esc>:call SetComplete()<CR>a
  +
echo
echo
 
endfun
+
endfun
   
nmap &lt;F12&gt; :call UnsetComplete()&lt;CR&gt;
+
nmap <F12> :call UnsetComplete()<CR>
imap &lt;F12&gt; &lt;Esc&gt;:call UnsetComplete()&lt;CR&gt;a
+
imap <F12> <Esc>:call UnsetComplete()<CR>a
 
</pre>
 
</pre>
   
'''Issues: '''
+
'''Issues'''
   
 
In insert mode, F12 switches to paste mode, but not back again. In normal mode, it works.
(i) I'm sure this can be done better
 
 
(ii) in insert mode, F12 switches to paste mode, but not back again. In normal mode, it works. I'm sure this is going to be something really, really silly.
 
 
 
}}
 
   
== Comments ==
 
<!-- parsed by vimtips.py in 0.434296 seconds-->
 
   
 
==Comments==
[[Category:Plugin]]
 
[[Category:Automated_Text_Insertion]]
 

Latest revision as of 04:11, 16 May 2012

Tip 526 Printable Monobook Previous Next

created 2003 · complexity intermediate · author Adrian von Bidder · version 6.0


I suggest you first look at the script itself: script#73

Since the script has some problems (at least for me) when I paste text in X11 with the mouse, and since I need to switch to paste more anyway, I now use this in my vimrc:

" the word_complete.vim plugin just *rocks*
autocmd VimEnter * call DoWordComplete()

fun! SetComplete()
  call DoWordComplete()
  set nopaste
  nunmap <F12>
  iunmap <F12>
  nmap <F12> :call UnsetComplete()<CR>
  imap <F12> <Esc>:call UnsetComplete()<CR>a
  echo
endfun

fun! UnsetComplete()
  call EndWordComplete()
  set paste
  nunmap <F12>
  iunmap <F12>
  nmap <F12> :call SetComplete()<CR>
  imap <F12> <Esc>:call SetComplete()<CR>a
  echo
endfun

nmap <F12> :call UnsetComplete()<CR>
imap <F12> <Esc>:call UnsetComplete()<CR>a

Issues

In insert mode, F12 switches to paste mode, but not back again. In normal mode, it works.


Comments[]