View | Details | Raw Unified | Return to bug 264921
Collapse All | Expand All

(-)b/documentation/content/en/books/fdp-primer/editor-config/_index.adoc (-33 / +51 lines)
Lines 52-64 Adjusting your text editor configuration can make working on document files quic Link Here
52
[[editor-config-vim]]
52
[[editor-config-vim]]
53
== Vim
53
== Vim
54
54
55
Install from package:editors/vim[], package:editors/vim-console[], or package:editors/vim-tiny[] then follow the configuration instructions in <<editor-config-vim-config>>.
55
Install from package:editors/vim[], or package:editors/vim-console[], then follow the configuration instructions in <<editor-config-vim-config>>.
56
More advanced users can use a proper linter like link:https://github.com/dense-analysis/ale[Ale] which can also act as a Vim link:https://langserver.org/[Language Server Protocol] client.
56
57
57
[[editor-config-vim-use]]
58
[[editor-config-vim-use]]
58
=== Use
59
=== Use
59
60
60
Press kbd:[P] to reformat paragraphs or text that has been selected in Visual mode.
61
Manual page writers can use the following keyboard shortcuts to reformat:
61
Press kbd:[T] to replace groups of eight spaces with a tab.
62
* Press kbd:[P] to reformat paragraphs or text that has been selected in Visual mode.
63
* Press kbd:[T] to replace groups of eight spaces with a tab.
62
64
63
[[editor-config-vim-config]]
65
[[editor-config-vim-config]]
64
=== Configuration
66
=== Configuration
Lines 68-110 Edit [.filename]#~/.vimrc#, adding these lines to the end of the file: Link Here
68
[.programlisting]
70
[.programlisting]
69
....
71
....
70
if has("autocmd")
72
if has("autocmd")
71
    au BufNewFile,BufRead *.sgml,*.ent,*.xsl,*.xml call Set_SGML()
73
  au BufNewFile,BufRead *.adoc call Set_ADOC()
72
    au BufNewFile,BufRead *.[1-9] call ShowSpecial()
74
  au BufNewFile,BufRead *.[1-9] call Set_MAN()
73
endif " has(autocmd)
75
endif " has(autocmd)
74
76
75
function Set_Highlights()
77
function Set_Highlights()
76
    "match ExtraWhitespace /^\s* \s*\|\s\+$/
78
  "match ExtraWhitespace /^\s* \s*\|\s\+$/
77
    highlight default link OverLength ErrorMsg
79
  return 0
78
    match OverLength /\%71v.\+/
80
endfunction " Set_Highlights_Adoc()
79
    return 0
81
80
endfunction " Set_Highlights()
82
function Set_Highlights_MAN()
83
  highlight default link OverLength ErrorMsg
84
  match OverLength /\%71v.\+/
85
  return 0
86
endfunction " Set_Highlights_MAN()
81
87
82
function ShowSpecial()
88
function ShowSpecial()
83
    setlocal list listchars=tab:>>,trail:*,eol:$
89
  setlocal list listchars=tab:>>,trail:*,eol:$
84
    hi def link nontext ErrorMsg
90
  hi def link nontext ErrorMsg
85
    return 0
91
  return 0
86
endfunction " ShowSpecial()
92
endfunction " ShowSpecial()
87
93
88
function Set_SGML()
94
function Set_COMMON()
89
    setlocal number
95
  setlocal number
90
    syn match sgmlSpecial "&[^;]*;"
96
  setlocal shiftwidth=2
91
    setlocal syntax=sgml
97
  setlocal tabstop=8
92
    setlocal filetype=xml
98
  setlocal softtabstop=2
93
    setlocal shiftwidth=2
99
  setlocal formatprg="fmt -p"
94
    setlocal textwidth=70
100
  setlocal autoindent
95
    setlocal tabstop=8
101
  setlocal smartindent
96
    setlocal softtabstop=2
102
  call ShowSpecial()
97
    setlocal formatprg="fmt -p"
103
  call Set_Highlights()
98
    setlocal autoindent
104
  return 0
99
    setlocal smartindent
105
endfunction " Set_COMMON()
100
    " Rewrap paragraphs
106
101
    noremap P gqj
107
function Set_ADOC()
102
    " Replace spaces with tabs
108
  setlocal syntax=asciidoc
103
    noremap T :s/        /\t/<CR>
109
  setlocal filetype=asciidoc
104
    call ShowSpecial()
110
  call Set_COMMON()
105
    call Set_Highlights()
111
  return 0
106
    return 0
112
endfunction " Set_ADOC()
107
endfunction " Set_SGML()
113
114
function Set_MAN()
115
  setlocal syntax=man
116
  setlocal filetype=man
117
  setlocal textwidth=70
118
  " Rewrap paragraphs
119
  noremap P gqj
120
  " Replace spaces with tabs
121
  noremap T :s/        /\t/<CR>
122
  call Set_COMMON()
123
  call Set_Highlights_MAN()
124
  return 0
125
endfunction " Set_Man()
108
....
126
....
109
127
110
[[editor-config-emacs]]
128
[[editor-config-emacs]]

Return to bug 264921