About: Smart mapping for tab completion   Sponge Permalink

An Entity of Type : owl:Thing, within Data Space : 134.155.108.49:8890 associated with source dataset(s)

I've come to find the following really useful. This is how you can map the Tab key in insert mode while still being able to use it when at the start of a line or when the preceding char is not a keyword character. in a script file in a plugin directory or in your .vimrc file: first define a function which returns a Tab or the appropriate completion, depending on the context: Then define the appropriate mappings: inoremap =Smart_TabComplete() The trick here is the use of the = in insert mode to be able to call your function without leaving insert mode. See [help i_CTRL-R].

AttributesValues
rdfs:label
  • Smart mapping for tab completion
rdfs:comment
  • I've come to find the following really useful. This is how you can map the Tab key in insert mode while still being able to use it when at the start of a line or when the preceding char is not a keyword character. in a script file in a plugin directory or in your .vimrc file: first define a function which returns a Tab or the appropriate completion, depending on the context: Then define the appropriate mappings: inoremap =Smart_TabComplete() The trick here is the use of the <c-r> = </c-r> in insert mode to be able to call your function without leaving insert mode. See [help i_CTRL-R].
Version
  • 6(xsd:integer)
dbkwik:vim/property/wikiPageUsesTemplate
Previous
  • 100(xsd:integer)
Category
  • Completion
Text
  • SuperTab
Author
  • benoit cerrina
Complexity
  • basic
Created
  • 2001(xsd:integer)
ID
  • 102(xsd:integer)
  • 1643(xsd:integer)
NEXT
  • 103(xsd:integer)
Rating
  • 1271(xsd:integer)
abstract
  • I've come to find the following really useful. This is how you can map the Tab key in insert mode while still being able to use it when at the start of a line or when the preceding char is not a keyword character. in a script file in a plugin directory or in your .vimrc file: first define a function which returns a Tab or the appropriate completion, depending on the context: function! Smart_TabComplete() let line = getline('.') " current line let substr = strpart(line, -1, col('.')+1) " from the start of the current " line to one character right " of the cursor let substr = matchstr(substr, "[^ ]*$") " word till cursor if (strlen(substr)==0) " nothing to match on empty string return "\" endif let has_period = match(substr, '\.') != -1 " position of period, if any let has_slash = match(substr, '\/') != -1 " position of slash, if any if (!has_period && !has_slash) return "\\" " existing text matching elseif ( has_slash ) return "\\" " file matching else return "\\" " plugin matching endif endfunction Then define the appropriate mappings: inoremap =Smart_TabComplete() The trick here is the use of the <c-r> = </c-r> in insert mode to be able to call your function without leaving insert mode. See [help i_CTRL-R].
Alternative Linked Data Views: ODE     Raw Data in: CXML | CSV | RDF ( N-Triples N3/Turtle JSON XML ) | OData ( Atom JSON ) | Microdata ( JSON HTML) | JSON-LD    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 07.20.3217, on Linux (x86_64-pc-linux-gnu), Standard Edition
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2012 OpenLink Software