Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some example Vim sciprts that use the bridge.
- Loading branch information
Showing
4 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
python << endpython | ||
from vim_bridge import bridged | ||
|
||
@bridged | ||
def SayHello(first, last): | ||
return "Hello, %s %s!" % (first, last) | ||
|
||
endpython | ||
|
||
" Now call directly into the Python function! | ||
echo SayHello("John", "Doe") | ||
" prints "Hello, John Doe!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
python << endpython | ||
from vim_bridge import bridged | ||
|
||
@bridged | ||
def GetLongest(list): | ||
return max(map(lambda s: len(s), list)) | ||
|
||
endpython | ||
|
||
echo GetLongest(['one', 'two', 'three', 'four']) | ||
" returns 5 (because "three" is 5 chars long) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
python << endpython | ||
from vim_bridge import bridged | ||
|
||
@bridged | ||
def WillCauseException(): | ||
raise Exception("Oops") | ||
|
||
endpython | ||
|
||
" This will throw an error to the user... | ||
echo WillCauseException() | ||
|
||
" But here's how you can catch that in Vim | ||
try | ||
echo WillCauseException() | ||
catch | ||
echo "Something went wrong. Aborting." | ||
finally | ||
echo "Cleaning up." | ||
endtry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
python << END | ||
import os.path | ||
from vim_bridge import bridged | ||
|
||
@bridged | ||
def NormalizePath(path): | ||
return os.path.realpath(path) | ||
END | ||
|
||
echo NormalizePath("/this/../or/./.././that/is/./a/.//very/../obscure/..//././long/./../path/name") | ||
echo NormalizePath("..") |