diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..861f2e6
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+tmp_config
diff --git a/README.md b/README.md
index 2254eed..bac95bd 100755
--- a/README.md
+++ b/README.md
@@ -35,12 +35,6 @@ To display a tip (and not a quote) in your vim-startify you can include the foll
You'll probably also want to deactivate the basic tip display at startup.
-## Add your own tips
-
-If you want, you can add your own tips by modifying the files in the tips folder.
-You may find them on your own system (probably in your plugin manager's files), but to simplify that I suggest forking my repo and adding your own changes in a version controlled repo.
-
-Tips must not exceed 70 characters
## Important note
diff --git a/convert_file_to_vim_list.py b/convert_file_to_vim_list.py
new file mode 100644
index 0000000..e3915ba
--- /dev/null
+++ b/convert_file_to_vim_list.py
@@ -0,0 +1,12 @@
+import sys
+
+if len(sys.argv) != 2:
+ print("This script requires an argument corresponding to the file path to listify")
+
+filepath = sys.argv[1]
+
+with open(filepath, 'r') as f:
+ print("[", end="")
+ for line in f.readlines():
+ print("\"" + line.strip("\n") + "\",", end="")
+ print("]")
diff --git a/plugin/tips/miscallenous.txt b/plugin/tips/miscallenous.txt
index 8ab0498..548636c 100755
--- a/plugin/tips/miscallenous.txt
+++ b/plugin/tips/miscallenous.txt
@@ -7,4 +7,5 @@ gt : show next tab
C-w : (in insert mode) erases word from start to position
C-u : (in insert mode) erases line from start to position
// : run your previous search
-CTRL + w + x : exchange with next window
+C-w-x : exchange with next window
+set ? : see the value of a config option
diff --git a/plugin/tips/othermodes.txt b/plugin/tips/othermodes.txt
new file mode 100644
index 0000000..178b1c3
--- /dev/null
+++ b/plugin/tips/othermodes.txt
@@ -0,0 +1,19 @@
+C-k (+characters) : insert digraphs (æ,π...) in insert mode
+C-K * p : insert π (in insert mode)
+C-K Eu : insert € (in insert mode)
+C-K +- : insert ± (in insert mode)
+C-K OK : insert ✓ (in insert mode)
+C-K XX : insert ✗ (in insert mode)
+C-K AN : insert ∧ ('and' symbol) (in insert mode)
+C-K OR : insert ∨ ('or' symbol) (in insert mode)
+C-K (- : insert ∈ (in insert mode)
+C-a : insert the last content inserted (in insert mode)
+C-@ : insert the last content insert and quit insert mode (in insert mode)
+C-h : delete character before the cursor (in insert mode)
+C-l : delete character after the cursor (like Del) (in insert mode)
+C-w : delete word under cursor (in insert mode)
+C-o : execute one normal or command-mode and return to insert (in insert mode)
+o : move cursor to opposite side of selection (in visual mode)
+U : Uppercase the selection
+C-v : Change to visual-bloc mode (from visual mode)
+S-v : Change to visual mode (from visual-bloc mode)
diff --git a/plugin/vim-tips.vim b/plugin/vim-tips.vim
index 2da7df5..3481679 100755
--- a/plugin/vim-tips.vim
+++ b/plugin/vim-tips.vim
@@ -13,6 +13,7 @@ let s:vimrc = $MYVIMRC
function Rand()
+ "ok-tier rng
return str2nr(matchstr(reltimestr(reltime()), '\v\.@<=\d+')[1:])
endfunction
@@ -20,7 +21,7 @@ endfunction
function GetTip()
let s:random_number = Rand()
- let s:number_categories = 9
+ let s:number_categories = 10
let s:chosen_category = s:random_number % s:number_categories
let s:tip = ""
@@ -42,6 +43,8 @@ function GetTip()
let s:tip = GetPhrases()
elseif s:chosen_category == 8
let s:tip = GetSelection()
+ elseif s:chosen_category == 9
+ let s:tip = GetOtherModes()
endif
return s:tip
endfunction
@@ -77,6 +80,11 @@ function GetMarkers()
return s:tiplist[s:index]
endfunction
+function GetOtherModes()
+ let s:tiplist = ["C-k (+characters) : insert digraphs (æ,π...) in insert mode","C-K * p : insert π (in insert mode)","C-K Eu : insert € (in insert mode)","C-K +- : insert ± (in insert mode)","C-K OK : insert ✓ (in insert mode)","C-K XX : insert ✗ (in insert mode)","C-K AN : insert ∧ ('and' symbol) (in insert mode)","C-K OR : insert ∨ ('or' symbol) (in insert mode)","C-K (- : insert ∈ (in insert mode)","C-a : insert the last content inserted (in insert mode)","C-@ : insert the last content insert and quit insert mode (in insert mode)","C-h : delete character before the cursor (in insert mode)","C-l : delete character after the cursor (like Del) (in insert mode)","C-w : delete word under cursor (in insert mode)","C-o : execute one normal or command-mode and return to insert (in insert mode)","o : move cursor to opposite side of selection (in visual mode)","U : Uppercase the selection","C-v : Change to visual-bloc mode (from visual mode)","S-v : Change to visual mode (from visual-bloc mode)",]
+ let s:index = Rand() % len(s:tiplist)
+ return s:tiplist[s:index]
+endfunction
@@ -88,7 +96,7 @@ endfunction
function GetMiscallenous()
- let s:tiplist =[":w! sudo tee % :write as root (ask password)","CTRL + w + = :resize splits equally","[[ : jump to function start",":new file.txt : open file.txt in new split","gt : show next tab","=% : indent code between parenthesis","C-w : (in insert mode) erases word from start to position","C-u : (in insert mode) erases line from start to position","// : run your previous search","CTRL + w + x : exchange with next window",]
+ let s:tiplist =[":w! sudo tee % :write as root (ask password)","CTRL + w + = :resize splits equally","[[ : jump to function start",":new file.txt : open file.txt in new split","gt : show next tab","=% : indent code between parenthesis","C-w : (in insert mode) erases word from start to position","C-u : (in insert mode) erases line from start to position","// : run your previous search","CTRL + w + x : exchange with next window", "set ? : see the value of a config option", "C-k (+characters) : insert digraphs (æ,π...) in insert mode","C-K-*-p : insert π (in insert mode)",]
let s:index = Rand() % len(s:tiplist)
return s:tiplist[s:index]
endfunction
@@ -116,13 +124,65 @@ function GetSelection()
return s:tiplist[s:index]
endfunction
-function DisplayTip()
- let s:prefix = "Tip => "
- echo s:prefix.g:GetTip()
+function GetPathTmpFile()
+ if has('win32')
+ let tmpfilepath = resolve(expand(':p:h')).'\tmp_config'
+ else
+ let tmpfilepath = resolve(expand(':p:h')).'/tmp_config'
+ endif
+ return tmpfilepath
+endfunction
+
+function GetConfig()
+ try
+ let tmpfilepath =GetPathTmpFile()
+ let s:configlist = readfile(tmpfilepath)
+ let s:config= s:configlist[0]
+ catch
+ return ""
+ endtry
+ return s:config
+endfunction
+
+
+function PrepareNextConfig()
+ let tmpfilepath = GetPathTmpFile()
+ if has('win32')
+ "nothing yet
+ else
+ " on UNIX-like OS
+ silent !sleep 5 &
+ "instead, start here a bash/python script in background (&) that remove the first line
+ "of the tmpfile and if it is empty, populate it with the config fetched
+ endif
+endfunction
+
+
+
+
+function DisplayTipOrConfig()
+ let s:very_random_float = (Rand() % 100) +150
+ if s:vim_tips_tips_frequency * 100> s:very_random_float
+ let s:prefix = "Tip => "
+ echo s:prefix.g:GetTip()
+ else
+ let s:configtip = GetConfig()
+ if s:configtip == "" "failed to get a proper mapping, return a normal tip instead
+ let s:prefix = "Tip => "
+ echo s:prefix.g:GetTip()
+ return
+ endif
+
+
+ "got a proper mapping
+ let s:prefix = "Config =>"
+ echo s:prefix.s:configtip
+ call PrepareNextConfig()
+ endif
endfunction
if s:vim_tips_display_at_startup
- autocmd VimEnter * call DisplayTip()
+ autocmd VimEnter * call DisplayTipOrConfig()
endif