Skip to content

Commit be5186d

Browse files
committed
Add ability to change window dimensions for splits
1 parent bc7eddf commit be5186d

File tree

4 files changed

+86
-36
lines changed

4 files changed

+86
-36
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ coding in. I made this plugin to make this process easier.
1313
- [Changing the default file extension](#changing-the-default-file-extension)
1414
- [Allow any file extension in tab-completion](#allow-any-file-extension-in-tab-completion)
1515
- [Set the default file name delimiter](#set-the-default-file-name-delimiter)
16+
- [Change the default window height for splits](#change-the-default-window-height-for-splits)
17+
- [Change the default window width for vsplits](#change-the-default-window-width-for-vsplits)
1618
- [Commands](#commands)
1719
- [Create or edit a note](#create-or-edit-a-note)
1820
- [Listing and changing libraries](#listing-and-changing-libraries)
@@ -131,6 +133,26 @@ something different, set the following variable in your `vimrc`.
131133
let g:noteworthy_delimiter = '-'
132134
```
133135

136+
#### Change the default window height for splits
137+
138+
You can change the default window height for splits. The default is to split the
139+
current window in half. Note that, if `:Snote` is called with a count, this
140+
variable will be overridden.
141+
142+
```vim
143+
let g:noteworthy_split_size = 30
144+
```
145+
146+
#### Change the default window width for vsplits
147+
148+
You can change the default window width for vertical splits. The default is to
149+
split the current window in half. Note that, if `:Vnote` is called with a count,
150+
this variable will be overridden.
151+
152+
```vim
153+
let g:noteworthy_vsplit_size = 80
154+
```
155+
134156
### Commands
135157
#### Create or edit a note
136158
Create or edit a note with `:Note [subject...]`. The `subject` will be used as

autoload/noteworthy.vim

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,21 @@ endfunction
77
""
88
" Open/create a note in a new tab.
99
function! noteworthy#Tnote(...) abort
10-
call s:File('tabe', a:000)
10+
call s:File('tabedit', a:000)
1111
endfunction
1212

1313
""
1414
" Open/create a note in a new split.
15-
function! noteworthy#Snote(...) abort
16-
call s:File('split', a:000)
15+
function! noteworthy#Snote(size, ...) abort
16+
let l:prefix = a:size ? a:size : get(g:, 'noteworthy_split_size', '')
17+
call s:File(l:prefix . 'split', a:000)
1718
endfunction
1819

1920
""
2021
" Open/create a note in a new vertical split.
21-
function! noteworthy#Vnote(...) abort
22-
call s:File('vert split', a:000)
22+
function! noteworthy#Vnote(size, ...) abort
23+
let l:prefix = a:size ? a:size : get(g:, 'noteworthy_vsplit_size', '')
24+
call s:File(l:prefix . 'vsplit', a:000)
2325
endfunction
2426

2527
""

doc/noteworthy.txt

Lines changed: 49 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ Setup ........................................... |noteworthy-setup|
2828
Setting a custom header ....................... |g:noteworthy_header_command|
2929
Allow any file extension in tab completion .... |g:noteworthy_ambiguous|
3030
Set the default file name delimiter ........... |g:noteworthy_delimiter|
31+
Change the default window height for splits ... |g:noteworthy_split_size|
32+
Change the default window width for vsplits ... |g:noteworthy_vsplit_size|
3133
Commands ........................................ |noteworthy-commands|
3234
Create or open a note ......................... |Note|
3335
Create or open a note in a split .............. |Snote|
@@ -143,50 +145,74 @@ something different, set the following variable in your vimrc.
143145
<
144146
This can also be changed temporarily via the |NoteDelimiter| command.
145147

148+
*g:noteworthy_split_size*
149+
Change the default window height for splits~
150+
151+
You can change the default window height for splits. The default is to split
152+
the current window in half. Note that, if |Snote| is called with a count, this
153+
variable will be overridden.
154+
>
155+
let g:noteworthy_split_size = 30
156+
<
157+
158+
*g:noteworthy_vsplit_size*
159+
Change the default window width for vsplits~
160+
161+
You can change the default window width for vertical splits. The default is to
162+
split the current window in half. Note that, if |Vnote| is called with a count,
163+
this variable will be overridden.
164+
>
165+
let g:noteworthy_vsplit_size = 80
166+
<
167+
146168
================================================================================
147169

148170
COMMANDS *noteworthy-commands*
149171

150172
*Note* *:Note*
151-
:Note {topic} [{, ...}] Create new {topic} markdown file in the
152-
|b:noteworthy_current_library|, or open it if it
153-
already exists. The file extension can be omitted.
154-
Can be multiple words separated by spaces, which
155-
will be replaced by underscores in the file name.
173+
:Note {topic} [{, ...}] Create new {topic} markdown file in the
174+
|b:noteworthy_current_library|, or open it if it
175+
already exists. The file extension can be omitted.
176+
Can be multiple words separated by spaces, which
177+
will be replaced by underscores in the file name.
156178

157179
*Snote* *:Snote*
158-
:Snote {topic} [{, ...}] Same as |Note|, but opens in a split.
180+
:[N]Snote {topic} [{, ...}] Same as |Note|, but opens in a split. If N is
181+
provided, it will be used as the height of the
182+
window.
159183

160184
*Vnote* *:Vnote*
161-
:Vnote {topic} [{, ...}] Same as |Note|, but opens in a vertical split.
185+
:[N]Vnote {topic} [{, ...}] Same as |Note|, but opens in a vertical split. If N
186+
is provided, it will be used as the width of the
187+
window.
162188

163189
*Tnote* *:Tnote*
164-
:Tnote {topic} [{, ...}] Same as |Note|, but opens in new tab.
190+
:Tnote {topic} [{, ...}] Same as |Note|, but opens in new tab.
165191

166192
*NoteLibrary* *:NoteLibrary*
167-
:NoteLibrary [{library}] Switch to {library}, which should be a key of
168-
|g:noteworthy_libraries|. If {library} is not
169-
provided, the current library being used will be
170-
displayed.
193+
:NoteLibrary [{library}] Switch to {library}, which should be a key of
194+
|g:noteworthy_libraries|. If {library} is not
195+
provided, the current library being used will be
196+
displayed.
171197

172198
*NoteExtension* *:NoteExtension*
173-
:NoteExtension [{ext}] Change the file extension being used when creating a
174-
new note or using tab-completion to {ext}. If {ext}
175-
is not provided, the current extension being used
176-
will be displayed. If ambiguous file extensions are
177-
enabled, this will not automatically be added to new
178-
notes.
199+
:NoteExtension [{ext}] Change the file extension being used when creating a
200+
new note or using tab-completion to {ext}. If {ext}
201+
is not provided, the current extension being used
202+
will be displayed. If ambiguous file extensions are
203+
enabled, this will not automatically be added to new
204+
notes.
179205

180206
*NoteAmbiguousEnable* *:NoteAmbiguousEnable*
181-
:NoteAmbiguousEnable Allow any file extension in tab completion.
207+
:NoteAmbiguousEnable Allow any file extension in tab completion.
182208

183209
*NoteAmbiguousDisable* *:NoteAmbiguousDisable*
184-
:NoteAmbiguousDisable Disallow any file extension in tab completion.
210+
:NoteAmbiguousDisable Disallow any file extension in tab completion.
185211

186212
*NoteDelimiter* *:NoteDelimiter*
187-
:NoteDelimiter [{delim}] Change the delimiter used to join the file name. If
188-
{delim} is not passed, the current delimiter being
189-
used will be displayed.
213+
:NoteDelimiter [{delim}] Change the delimiter used to join the file name. If
214+
{delim} is not passed, the current delimiter being
215+
used will be displayed.
190216

191217
================================================================================
192218

plugin/noteworthy.vim

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ command! -nargs=+ -complete=custom,noteworthy#Completion Note
1010
\ call noteworthy#Note(<f-args>)
1111

1212
""
13-
" :VNote {topic}, ...
14-
" Create or edit a note. Opens in vertical split.
15-
command! -nargs=+ -complete=custom,noteworthy#Completion Vnote
16-
\ call noteworthy#Vnote(<f-args>)
13+
" :[N]VNote {topic}, ...
14+
" Create or edit a note. Opens in vertical split, [N] columns wide (default 20).
15+
command! -count -nargs=+ -complete=custom,noteworthy#Completion Vnote
16+
\ call noteworthy#Vnote(<count>, <f-args>)
1717

1818
""
19-
" :SNote {topic}, ...
20-
" Create or edit a note. Opens in split.
21-
command! -nargs=+ -complete=custom,noteworthy#Completion Snote
22-
\ call noteworthy#Snote(<f-args>)
19+
" :[N]SNote {topic}, ...
20+
" Create or edit a note. Opens in split, [N] columns wide (default 20).
21+
command! -count -nargs=+ -complete=custom,noteworthy#Completion Snote
22+
\ call noteworthy#Snote(<count>, <f-args>)
2323

2424
""
2525
" :TNote {topic}, ...

0 commit comments

Comments
 (0)