Make "set ruler!" change status line
dblume

dblume commited on 2024-03-19 22:22:43
Showing 2 changed files, with 20 additions and 0 deletions.


Maybe sometimes I'll want to see the column position in the
status line.
... ...
@@ -84,6 +84,13 @@ function! EncodingAndFormat()
84 84
   return ''
85 85
 endfunction
86 86
 
87
+function! OnRuler()
88
+  if &ruler
89
+    return '│ '.line('.').':'.col('.').' '
90
+  endif
91
+  return ''
92
+endfunction
93
+
87 94
 function! Current_mode()
88 95
   let l:currentmode={
89 96
     \ 'n'  : 'NORMAL',
... ...
@@ -122,6 +129,7 @@ set statusline+=\ %#StatusLineNC#
122 129
 set statusline+=\ %{b:enc_fmt}
123 130
 set statusline+=%p%%\ of
124 131
 set statusline+=\ %L\ 
132
+set statusline+=%{OnRuler()}
125 133
 
126 134
 " Fast saving
127 135
 nmap <leader>w :w!<cr>
... ...
@@ -360,8 +368,10 @@ nnoremap <silent> [q :cprevious<CR>
360 368
 nnoremap <silent> ]q :cnext<CR>
361 369
 
362 370
 " From `:help :DiffOrig`.
371
+if exists(":DiffOrig") != 2
363 372
   command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_
364 373
     \ | diffthis | wincmd p | diffthis
374
+endif
365 375
 
366 376
 " I use Roboto Mono from https://github.com/powerline/fonts
367 377
 " On iTerm2, Preferences -> Profiles -> Text -> Font
... ...
@@ -108,6 +108,13 @@ function! EncodingAndFormat()
108 108
   return ''
109 109
 endfunction
110 110
 
111
+function! OnRuler()
112
+  if &ruler
113
+    return '│ '.line('.').':'.col('.').' '
114
+  endif
115
+  return ''
116
+endfunction
117
+
111 118
 function! Current_mode()
112 119
   let l:currentmode={
113 120
     \ 'n'  : 'NORMAL',
... ...
@@ -146,6 +153,7 @@ set statusline+=\ %#StatusLineNC#
146 153
 set statusline+=\ %{b:enc_fmt}
147 154
 set statusline+=%p%%\ of
148 155
 set statusline+=\ %L\ 
156
+set statusline+=%{OnRuler()}
149 157
 
150 158
 set encoding=utf-8
151 159
 
... ...
@@ -389,8 +397,10 @@ nnoremap <silent> [q :cprevious<CR>
389 397
 nnoremap <silent> ]q :cnext<CR>
390 398
 
391 399
 " From `:help :DiffOrig`.
400
+if exists(":DiffOrig") != 2
392 401
   command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_
393 402
     \ | diffthis | wincmd p | diffthis
403
+endif
394 404
 
395 405
 " I use Roboto Mono from https://github.com/powerline/fonts
396 406
 " On iTerm2, Preferences -> Profiles -> Text -> Font
397 407