Skip to main content
added 496 characters in body
Source Link
user9433424
  • 6.2k
  • 2
  • 21
  • 30

There could be a 3rd problem, when saving/restoring buffer-local mappings. Because, between the moment when youwe saved the mappings, and the moment when youwe try to restore them, the current buffer may have changed.

And then, Restore_mappings() would use this info to restore the buffer-local mappings in the right buffer. OneWe could probably use the :bufdo command, prefix the latter with a count (matching the buffer number previously saved), and suffix it with the mapping command.

We would have to check first if the buffer still exists, using the bufexists() function, because it could have been deleted in the meantime.

There could be a 3rd problem, when saving/restoring buffer-local mappings. Because, between the moment when you saved the mappings, and the moment when you try to restore them, the current buffer may have changed.

And then, Restore_mappings() would use this info to restore the buffer-local mappings in the right buffer. One could probably use the :bufdo command, prefix the latter with a count (matching the buffer number previously saved), and suffix it with the mapping command.

There could be a 3rd problem, when saving/restoring buffer-local mappings. Because, between the moment when we saved the mappings, and the moment when we try to restore them, the current buffer may have changed.

And then, Restore_mappings() would use this info to restore the buffer-local mappings in the right buffer. We could probably use the :bufdo command, prefix the latter with a count (matching the buffer number previously saved), and suffix it with the mapping command.

We would have to check first if the buffer still exists, using the bufexists() function, because it could have been deleted in the meantime.

added 496 characters in body
Source Link
user9433424
  • 6.2k
  • 2
  • 21
  • 30

There could be a 3rd problem, when saving/restoring buffer-local mappings. Because, between the moment when you saved the mappings, and the moment when you try to restore them, the current buffer may have changed.

In this case, maybe the Save_mappings() function could be improved by saving the number of the current buffer (bufnr('%')).

And then, Restore_mappings() would use this info to restore the buffer-local mappings in the right buffer. One could probably use the :bufdo command, prefix the latter with a count (matching the buffer number previously saved), and suffix it with the mapping command.

Maybe something like:

:{original buffer number}bufdo {mapping command}

There could be a 3rd problem, when saving/restoring buffer-local mappings. Because, between the moment when you saved the mappings, and the moment when you try to restore them, the current buffer may have changed.

In this case, maybe the Save_mappings() function could be improved by saving the number of the current buffer (bufnr('%')).

And then, Restore_mappings() would use this info to restore the buffer-local mappings in the right buffer. One could probably use the :bufdo command, prefix the latter with a count (matching the buffer number previously saved), and suffix it with the mapping command.

Maybe something like:

:{original buffer number}bufdo {mapping command}
added 7 characters in body
Source Link
user9433424
  • 6.2k
  • 2
  • 21
  • 30

With it, you could save the global mappings using the keys C-a, C-b and C-c, in normal mode, inside a dictionary:

With it, you could save the mappings using the keys C-a, C-b and C-c, in normal mode, inside a dictionary:

With it, you could save the global mappings using the keys C-a, C-b and C-c, in normal mode, inside a dictionary:

added 5102 characters in body
Source Link
user9433424
  • 6.2k
  • 2
  • 21
  • 30
Loading
deleted 11 characters in body
Source Link
user9433424
  • 6.2k
  • 2
  • 21
  • 30
Loading
added 9 characters in body
Source Link
user9433424
  • 6.2k
  • 2
  • 21
  • 30
Loading
added 9 characters in body
Source Link
user9433424
  • 6.2k
  • 2
  • 21
  • 30
Loading
added 2899 characters in body
Source Link
user9433424
  • 6.2k
  • 2
  • 21
  • 30
Loading
added 2 characters in body
Source Link
user9433424
  • 6.2k
  • 2
  • 21
  • 30
Loading
added 314 characters in body
Source Link
user9433424
  • 6.2k
  • 2
  • 21
  • 30
Loading
added 22 characters in body
Source Link
user9433424
  • 6.2k
  • 2
  • 21
  • 30
Loading
deleted 7 characters in body
Source Link
user9433424
  • 6.2k
  • 2
  • 21
  • 30
Loading
added 391 characters in body
Source Link
user9433424
  • 6.2k
  • 2
  • 21
  • 30
Loading
deleted 8 characters in body
Source Link
user9433424
  • 6.2k
  • 2
  • 21
  • 30
Loading
Source Link
user9433424
  • 6.2k
  • 2
  • 21
  • 30
Loading