Browse Source

Updating custom UltiSnips

pull/2/head
Ryan Reed 3 years ago
parent
commit
6b4020f3a0
3 changed files with 16 additions and 2 deletions
  1. +11
    -1
      dot_vim/README.md
  2. +4
    -0
      dot_vim/UltiSnips/python.snippets
  3. +1
    -1
      dot_vim/vimrc

+ 11
- 1
dot_vim/README.md View File

@ -15,6 +15,7 @@ Note: Some features require version 8+ of vim. For instance, the ALE plugin whic
* [Tabs and Windows Related](#tabs-and-windows-related) * [Tabs and Windows Related](#tabs-and-windows-related)
* [Misc Related](#misc-related) * [Misc Related](#misc-related)
* [Snippets](#snippets) * [Snippets](#snippets)
* [Adding/Editing Custom Snippets](#addingediting-custom-snippets)
* [Common Snippet Examples](#common-snippet-examples) * [Common Snippet Examples](#common-snippet-examples)
* [Go Snippets](#go-snippets) * [Go Snippets](#go-snippets)
* [Python Snippets](#python-snippets) * [Python Snippets](#python-snippets)
@ -124,7 +125,7 @@ Note: Some features require version 8+ of vim. For instance, the ALE plugin whic
Snippets have a few extra things to note: Snippets have a few extra things to note:
* Snippet Leader: `<tab>`
* Snippet Leader: `<shortcut><tab>` (e.g. `class<tab>`)
* List Snippets: `<ctrl-l>` * List Snippets: `<ctrl-l>`
* Forward Through Snippet: `<ctrl-j>` * Forward Through Snippet: `<ctrl-j>`
* Backward Through Snippet: `<ctrl-k>` * Backward Through Snippet: `<ctrl-k>`
@ -141,10 +142,18 @@ A more in depth example:
5. `<ctrl-j>` to move to inputs of the `__init__` function (typing a new input name automatically adds `self._varname = varname`) 5. `<ctrl-j>` to move to inputs of the `__init__` function (typing a new input name automatically adds `self._varname = varname`)
### Adding/Editing Custom Snippets
You can edit the snippets for the current filetype that's open by using `:UltiSnipsEdit`
**Important Note**: If using chezmoi, make sure to copy the snippet to the chezmoi repo so it isn't overwritten during next `chezmoi apply`
### Common Snippet Examples ### Common Snippet Examples
These are taken from [this article](https://bhupesh-v.github.io/learn-how-to-use-code-snippets-vim-cowboy/). These are taken from [this article](https://bhupesh-v.github.io/learn-how-to-use-code-snippets-vim-cowboy/).
#### Go Snippets #### Go Snippets
[All Go snippets](https://github.com/honza/vim-snippets/blob/master/snippets/go.snippets). Also, see Ultisnips specific [snippets](https://github.com/honza/vim-snippets/blob/master/UltiSnips/go.snippets) [All Go snippets](https://github.com/honza/vim-snippets/blob/master/snippets/go.snippets). Also, see Ultisnips specific [snippets](https://github.com/honza/vim-snippets/blob/master/UltiSnips/go.snippets)
@ -188,6 +197,7 @@ These are taken from [this article](https://bhupesh-v.github.io/learn-how-to-use
| `if` | Python basic if statement | | `if` | Python basic if statement |
| `el` | Python basic else statement | | `el` | Python basic else statement |
| `for` | Range based for loop | | `for` | Range based for loop |
| `forkey` | Enumerate using key value of an interable (**Custom**) |
| `lcp` | List comprehension | | `lcp` | List comprehension |


+ 4
- 0
dot_vim/UltiSnips/python.snippets View File

@ -0,0 +1,4 @@
snippet forkey "Enumerate an iterable for key/value pair"
for ${1:key}, ${2:value} in enumerate(${3}):
pass
endsnippet

+ 1
- 1
dot_vim/vimrc View File

@ -96,7 +96,7 @@
endif endif
" Plugin - Vim Snippets (UltiSnips) " Plugin - Vim Snippets (UltiSnips)
let g:UltiSnipsSnippetDirectories=["UltiSnips", $HOME.'/.vim/snippets/'] " Add custom snippets
let g:UltiSnipsSnippetDirectories=["~/.vim/UltiSnips/", "UltiSnips"] " Add custom snippets
let g:UltiSnipsExpandTrigger="<tab>" let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsListSnippets="<c-l>" " list all snippets for current filetype let g:UltiSnipsListSnippets="<c-l>" " list all snippets for current filetype
let g:UltiSnipsJumpForwardTrigger="<c-j>" let g:UltiSnipsJumpForwardTrigger="<c-j>"


Loading…
Cancel
Save