Skip to content

Commit 37e531f

Browse files
committed
Added vim command output
Now the 'vim' output option will print out a vim command that loads the file and jumps to the line with the misspelling. Also added the 'first' option, so that you can show only the first instance of a misspelled word.
1 parent 655394c commit 37e531f

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

codespell.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,12 @@ def parse_args():
198198
parser.add_argument('--verbose', '-v', action='store_true', default=False,
199199
dest='verbose', help='Make output verbose')
200200

201+
parser.add_argument('--first', '-f', action='store_true', default=False,
202+
dest='first', help='Show only first occurrence of a mispelling')
203+
204+
parser.add_argument('--vim', '-V', action='store_true', default=False,
205+
dest='vim', help='Output results in vim command format')
206+
201207
parser.add_argument('--dict', '-d', action='append',
202208
dest='dict',
203209
help='Add a dictionary (multiples allowed)')
@@ -333,10 +339,15 @@ def main():
333339
prev = ""
334340
bc = 0
335341
for x in bad_words:
336-
if x[0] == prev:
342+
if (x[0] != prev):
343+
print("\n", x[0],":", sep='')
344+
if (x[0] == prev) and args.first:
337345
sys.stderr.write('.')
338346
continue
339-
print("\n", x[0], ": ", x[1], ", ", x[2], sep='', file=sys.stderr)
347+
if args.vim:
348+
print(" vim +", x[2], " ", x[1], sep='', file=sys.stderr)
349+
else:
350+
print(" ", x[1], ", ", x[2], sep='', file=sys.stderr)
340351
prev = x[0]
341352
bc = bc + 1
342353

0 commit comments

Comments
 (0)